Using a Jupyter Notebook within a Docker Container

Hello,

I successfully installed NGC container for tensorflow by using the follower command: docker pull nvcr.io/nvidia/tensorflow:18.03-py3

Could some one please guide me as to how can I:

  1. Upload my data to this container, and
  2. Use a Jupyter Notebook from within the container to analyze the data?

Thanks,
Akhil

Yes! This is very important to data scientists, I hope we hear soon - I’ll keep trying, and post here if I can work it out :) Thanks for raising this Akhil.

Yes, I’m also looking on how to achieve this.

Any ideas on how to combine the tensorflow docker image together with Jupyter Notebooks, Tensorboard and Keras?

For all of you struggling with this as well. I solved it by building my own container and adding some flags when running the container.

An example, adding Keras to the nvidia tensorflow container.

  1. Create a file called "Dockerfile"
  2. Enter the following
    FROM nvcr.io/nvidia/tensorflow:18.08-py3
    WORKDIR /my-ml-files
    RUN pip install jupyter
    EXPOSE 8888
    RUN pip install keras
    
  3. Run the following in a terminal inside of the folder where you saved the "Dockerfile"
    docker build -t my-nvidia-container .
    
  4. The container is now built. To run it run the following
    docker run --runtime=nvidia -it my-nvidia-container
    

If you’re looking to add a folder with files to the docker container
Run the following command when starting the docker container instead

docker run --runtime=nvidia -it -v "/my-local-computer-files/:/my-docker-container/" my-nvidia-container

. Where if you change directory to

/my-docker-container/

inside of the container, your files in

/my-local-computer-files/

should be visible and accessible.

Access jupyter notebook
Add the flag

-p 8888:8888

to the command. You may combine this with the one above (

-v "/my-local-computer-files/:/my-docker-container/"

).
Example:

docker run --runtime=nvidia -it -p "8888:8888" -v "/my-local-computer-files/:/my-docker-container/" my-nvidia-container

And when you’re inside of the docker container run

jupyter notebook --port=8888 --ip=0.0.0.0 --allow-root --no-browser .

and then you’ll be able to access it from your local browser at http://localhost:8888

Hope that helps.
Victor

2 Likes

Wow … awesome … I will soon give this a try. Thanks a lot for this.

Just a quick question: does the host need the Nvidia drivers installed to use the above docker base image? (nvcr.io/nvidia/tensorflow:18.08-py3)

With your instructions I was able to launch a jupyter notebook from within a docker image. Also, the instructions you gave are spot on! Thanks a lot.

With your instructions I was able to launch a jupyter notebook from within a docker image. Also, the instructions you gave are spot on! Thanks a lot.

I think you have to install the drivers prior to using the docker image.

In followup – FYI, we now include Jupyter (and JupyterLab) by default in our DL Frameworks containers, so you can skip many of the steps that used to be required as documented in this thread. See [url]https://devtalk.nvidia.com/default/topic/1049001/container-nvcaffe/how-to-use-jupyter-notebook-with-nvcaffe/post/5323778/#5323778[/url] for updated instructions.

Awesome … even better. Can’t wait to give it a try. Thanks for iterative progress / updates on this.