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

No comments:

Post a Comment