我正在尝试使用docker和tensorflow测试我的设置。我使用的是官方的Tensorflow图像tensorflow/tensorflow:1.15.0rc2-gpu-py3
我的项目有最小的结构:
project/
Dockerfile
docker-compose.yml
jupyter/
README.md我有以下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"]和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:运行docker-compose build和docker-compose up成功(如果Dockerfile中的CMD被注释掉),但只是退出。在docker hub repository中,我认为添加音量会自动启动笔记本。
尝试运行jupyter-notebook或jupyter notebook失败。
对如何改正有什么想法?
发布于 2019-10-17 17:25:29
如果您想从添加notebook目录的官方镜像创建自定义镜像,那么docker-compose中的image属性应该是本地镜像的名称,而不是tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter.在本例中,您所需要的只是以下Dockerfile:
FROM tensorflow/tensorflow:1.15.0rc2-gpu-py3-jupyter
ADD ./jupyter /tf/notebooks在这种情况下,docker-compose.yaml文件应如下所示:
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:请注意,该图像是tensorflow。
但是,真的不需要使用自定义Dockerfile。只需使用以下docker-compose.yaml文件:
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'它将直接将您的本地jupyter目录映射到容器,并且无需修改即可使用官方镜像。
但请注意,由于主机目录的映射问题,它在Windows上可能无法按预期工作。
发布于 2021-08-04 06:02:34
尝尝这个
RUN pip3 install nvidia-tensorflow这将安装tf 1.15
https://stackoverflow.com/questions/58419932
复制相似问题