Tensorflow: docker image and -gpu suffix

為{幸葍}努か 提交于 2020-12-06 03:36:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!