This is my environment for playing with ML/RL using PyTorch, jupyter-lab, and Anaconda. It also includes CUDA 10.0.
This docker image has Anaconda installed with all packages from the environment.yml
and the requrements.txt
files.
To set-up everything you need execute the following step:
- Create projects directory:
/home/${USER}/projects
- Configure your git - add your name and email
(docker requires/home/${USER}/.gitconfig
directory) - Configure your ssh key to use remote git services inside the container - GitLab example
(docker requires/home/${USER}/.ssh
directory)
If you want to use your CUDA-capable GPU in computations:
-
Make sure you have the latest NVIDIA drivers and Docker 19.03 or higher.
-
Install
nvidia-container-toolkit
:# Add the package repositories $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) $ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list $ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit $ sudo systemctl restart docker
If you use Ubuntu 19.04 use:
# Add the package repositories $ distribution="ubuntu18.04" $ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list $ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit $ sudo systemctl restart docker
Edit
/etc/docker/daemon.json
by adding:{ "runtimes": { "nvidia": { "path": "nvidia-container-runtime", "runtimeArgs": [] } } }
In case of
docker: Error response from daemon: Unknown runtime specified nvidia.
run:$ sudo systemctl daemon-reload $ sudo systemctl restart docker
To add SSL encryption you can use self-signed certificate as follows:
- ALL THE FOLLOWING STEPS ARE DONE INSIDE THE DOCKER CONTAINER!
- Add password using
$ jupyter notebook password
command. - In the
/root/.jupyter/
directory generate certficate:openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem
- Add following lines to the
/root/.jupyter/jupyter_notebook_config.json
file:"NotebookApp": { "certfile": "/root/.jupyter/mycert.pem", "keyfile": "/root/.jupyter/mykey.key" }
Everything will be perserved because of the jupyter jupyter-gpu-config
volume.
To start run docker-compose up -d
in the repo directory.
Jupyter-lab can be found under the following path http://localhost:8889/
To stop run docker-compose down
in the repo directory.
If you want to change some of the installed packages you can modify file environment.yml
and build new image
docker build -t jupyter .
You also need to edit docker-compose.yml
file and change following lines:
services:
vs-code:
image: jacekplocharczyk/jupyter:latest
to
services:
vs-code:
image: jupyter:latest