Tested with the following Host :
- Ubuntu 18.04
- Installed Nvidia driver = 390.67
No need for cuda on the Host. It will be installed inside the docker image.
- Install nvidia docker 2
Follow those instructions : https://github.com/NVIDIA/nvidia-docker#quickstart
- Build the docker image
sudo docker build --build-arg http_proxy=$http_proxy -t cuda9.1 .
- Execute jupyter within the docker
Let's say :
- your user is
user
- your home is
/home/user
- your jupyter path is
/home/user/anaconda3/bin/jupyter
And that you already created a configuration file for jupyter with the user
user :
jupyter notebook --generate-config
jupyter notebook password
Then you can launch it with:
sudo docker run -p 4242:8888 --runtime=nvidia -v /usr/local/cuda:/usr/local/cuda -v /usr/local/cuda-9.1/:/usr/local/cuda-9.1/ -v /usr/bin/nvidia-smi:/usr/bin/nvidia-smi -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group -v /etc/shadow:/etc/shadow -v /home/user:/home/user -it cuda9.1 /sbin/runuser -l user -s /bin/bash -c "/home/user/anaconda3/bin/jupyter lab --notebook-dir='/home/user' --config='/home/user/.jupyter/jupyter_notebook_config.py'"
Your Jupyter will be accessible from all the local network from http://your_ip:4242
.