Showing posts with label gpu. Show all posts
Showing posts with label gpu. Show all posts

Sunday, March 3, 2019

Run a dockerized jupyter notebook (with GPU)

Launch the docker container (running a jupyter notebook with unprivileged an user).
This command maps the port 8888 of the container to the port 9999 of the host, mounts the directory /home/foo/docker to /home/foo in the container     
$ docker run --rm -p 9999:8888           \
         -v /home/foo/docker:/home/foo   \
         -it jupyter/tensorflow-notebook \
         jupyter notebook --port=8888
Using the nvidia-docker driver it is possible to assign a GPU to the container:
NV_GPU=1 nvidia-docker run --rm -p 9999:8888 \
         -v /home/foo/docker:/home/foo         \
         -it jupyter/tensorflow-notebook       \
         jupyter notebook --port=8888

To connect as root to a live container for maintenance use the command below. Suppose that the running container ID (from docker ps) is 4f177e045de6,  then call
docker exec -ti 4f177e045de6 --user=root bash

Docker containers with NVIDIA GPUs using nvidia-docker


nvidia-gpu-docker

These are the installation instructions for Ubuntu:



Test the installation running
$ docker run --runtime=nvidia --rm nvidia/cuda:latest nvidia-smi
 or the equivalent nvidia-docker wrapper call
$ nvidia-docker run --rm nvidia/cuda:latest nvidia-smi

The wrapper allows to easily select which of the host's GPUs are visible from the docker instance, in this example only the first two GPUs
$ NV_GPU=0,1 nvidia-docker run --rm -v /home/foo/data:/data -it nvidia/cuda:latest bash