问题
In the Docker image for Tensorflow with GPU support (for example: tensorflow/tensorflow:2.2.0-gpu
) the installed python package is tensorflow-gpu
(as shown in pip freeze
).
Installing any python package that depends on tensorflow
triggers the installation of tensorflow itself, although it's already installed under a different name (because -- correctly -- tensorflow-gpu
!= tensorflow
).
Is there a way to avoid this?
回答1:
You can add an instruction to install a fake tensorflow
"package" that only writes the metadata without adding the duplicate sources:
$ python -c 'from setuptools import setup; setup(name="tensorflow", version="2.2.0")' install
In the docker image this would look like this:
FROM tensorflow/tensorflow:2.2.0-gpu
RUN python -c 'from setuptools import setup; setup(name="tensorflow", version="2.2.0")' install
RUN pip install my-requirements
RUN pip uninstall -y tensorflow # cleaning up
来源:https://stackoverflow.com/questions/61917703/tensorflow-docker-image-and-gpu-suffix