我有一个Dockerfile如下:
FROM tensorflow/tensorflow:1.13.2-gpu-py3
COPY src/ /
WORKDIR /Mask_RCNN
RUN pip install --upgrade pip setuptools wheel
RUN pip install -r requirements.txt
RUN pip install .
RUN pip install slidingwindow
ENTRYPOINT ["python3","/Mask_RCNN/inference_docker.py"]
和这样的需求文件:numpy
scipy
Pillow
cython
matplotlib
tensorflow>=1.3.0
scikit-image
opencv-python
h5py
imgaug
IPython[all]
因此,拉出tf 1.13.2
可以满足tensorflow>=1.3.0
的要求,但是在创建镜像时,docker尝试下载最新的tf=2.3
,如requirements.txt
所示。但是,此行为破坏了我的代码,因为它只能在tf>1.3 and tf<2
上运行。我应该通过删除requirements.txt
来修改tensorflow>=1.3.0
,还是有任何命令可以避免这种冲突?
最佳答案
如果查看Tensorflow上的DockerFile,您会看到tenstflow Docker镜像是由installing Tensorflow by pip在Ubuntu之上构建的。如果您使用更高版本的TensorFlow> = 1.3重新安装TensorFlow。它将为您下载最新版本,即tensorflow 2.3。因此,要么从需求文件中删除tensorflow,否则它将始终被最新版本覆盖。
关于python - 基本镜像满足tensorflow版本,但docker仍然从requirements.txt下载tensorflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63529866/