Probelm connecting Pycharm (2018.1.4) to nvidia-docker (version 2):

Answered

Dear all, the following action were executed

1) Compose the nvidia-docker-compose.yml by hand

services:
  exampleservice0:
    devices:
    - /dev/nvidia0
    - /dev/nvidiactl
    - /dev/nvidia-uvm
    - /dev/nvidia-uvm-tools
    environment:
    - EXAMPLE_ENV_VARIABLE=example
    image: floydhub/dl-docker
    volumes:
    - ./disk:/disk
    - nvidia_driver_390.59:/usr/local/nvidia:ro
version: '2'
volumes:
  media: null
  nvidia_driver_390.59:
    external: true

2) Under the Add Python Interprete-Docker compose, I add the nvidia-docker-compose.yml  under the Service. However, when confirming the setting, Pycharm give the following error.

 

 

May I know where I do wrong.

Thanks in advance for the time spent.

4 comments

Hi rpb, PyCharm doesn't support nvidia-docker, unfortunately. Please vote for PY-26429.

0

Hi Pavel, thanks for the quick response. I wonder how others are able to connect Pycharm to nvidia-docker. I guess they are using somewhat lower version.

Some of the discussion can be found in the following

1) https://github.com/NVIDIA/nvidia-docker/issues/303 

2) https://zhuanlan.zhihu.com/p/27114995 (maybe use lower version of Pycharm)

3) http://haanjack.github.io/docker/2018/02/21/nvidia-docker2-runtime.html  (although he does not show how specifically on the setup)

4) http://www.icesr.com/archives/3103 

 

These are few limited resources that I can found on the net discussing the setting up between pycharm and nvidia-docker. So, just to verify, are you sure PyCharm doesn't support nvidia-docker, if yes, then I will halt my current effort in dong this setting-up.

0

Hi,

possible answer/workaround:

https://github.com/NVIDIA/nvidia-docker/issues/303#issuecomment-415668695 

simply change docker "default-runtime" to "nvidia" by adding line

"default-runtime": "nvidia"

to your "etc/docker/daemon.json" file

0

Hello, i was able to connect to the remote Python interpreter using Pycharm. I know my solution is a bit clunky (can be optimized, for example create a docker-compose which i prefer to not create).

I'm using Arch Linux with the latest drivers (396.54-3) and Pycharm 2018.02. This guide should be working on every linux distro.

1) You have to import or create a project with a new Virtualenv env (it does not work to create a project with the Remote docker interpreter)

2) Follow this steps to connect to the Remote Docker interpreter: https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html

3) in /etc/docker/daemon.json, change this file as follows:

{
    "default-runtime": "nvidia",
    "runtimes": {
      "nvidia": {
        "path": "/usr/bin/nvidia-container-runtime",
        "runtimeArgs": []
    }
  },
}

4) systemctl daemon-reload and systemctl restart docker to apply the changes (as written here: https://github.com/NVIDIA/nvidia-docker/issues/303)

5) [Arch] Because i have bumblebee (my nvidia drivers are OFF by default), YOU MUST spawn a new docker BEFORE you can run yout code on Pycharm, with:

```optirun nvidia-docker run -it -p 8888:8888 tensorflow/tensorflow:1.10.1-devel-gpu-py3 bash``` (version is an example)

6) Run a TF Hello world on pycharm. It should see that a docker container is already up and use that one to execute your code.

Trick: maybe one can put this: "alias docker=nvidia-docker" somewhere so that actually Pycharm spawn the right container. Right now, it is configured to create a container with docker and not with nvidia-docker. That's why it doesn't work if Pycharm runs your code (don't ask me why it works with the container already created <magic>)

0

Please sign in to leave a comment.