Reputation: 5198
I am trying to test my setup using docker and tensorflow. I am using the official Tensorflow image tensorflow/tensorflow:1.15.0rc2-gpu-py3
My project has the minimum structure:
project/
Dockerfile
docker-compose.yml
jupyter/
README.md
I have the following Dockerfile
:
# from official image
FROM tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter
# add my notebooks so they are a part of the container
ADD ./jupyter /tf/notebooks
# copy-paste from tf github dockerfile in attempt to troubleshoot
# https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/dockerfiles/dockerfiles/gpu-jupyter.Dockerfile
WORKDIR /tf
RUN which jupyter
CMD ["jupyter-notebook --notebook-dir=/tf/notebooks --ip 0.0.0.0 --no-browser --allow-root"]
and the docker-compose.yml
version: '3'
services:
tf:
image: tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter
# mount host system volume to save updates from container
volumes:
- jupyter:/tf/notebooks
ports:
- '8888:8888'
# added as part of troubleshooting
build:
context: .
dockerfile: Dockerfile
volumes:
jupyter:
running docker-compose build
and docker-compose up
succeeds (if the CMD
in the Dockerfile
is commented out), but just exits. From the docker hub repository, I thought adding the volume would auto-start a notebook.
Trying to run jupyter-notebook
or jupyter notebook
fails.
Thoughts on how to correct?
Upvotes: 1
Views: 1147
Reputation: 801
try this
RUN pip3 install nvidia-tensorflow
this will install tf 1.15
Upvotes: 0
Reputation: 146
If you want to create a custom image from the official one adding the notebook directory then the image property in the docker-compose should be the name of the your local image not the tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter. All you need is in this case a following Dockerfile:
FROM tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter
ADD ./jupyter /tf/notebooks
In this case the docker-compose.yaml file should look like the following:
version: '3'
services:
tf:
image: tensorflow
# mount host system volume to save updates from container
volumes:
- jupyter:/tf/notebooks
ports:
- '8888:8888'
# added as part of troubleshooting
build:
context: .
dockerfile: Dockerfile
volumes:
jupyter:
Note, that the image is tensorflow.
However, there is really no need to use the custom Dockerfile. Just use the following docker-compose.yaml file:
version: '3'
services:
tf:
image: tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter
# mount host system volume to save updates from container
volumes:
- ./jupyter:/tf/notebooks:Z
ports:
- '8888:8888'
It will directly map your local jupyter directory to the container and will use an official image without modification.
Note though, it might not work as expected on Windows due to issues with mapping of the host directories.
Upvotes: 1