Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow: docker image and -gpu suffix

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?

like image 617
Nicola Montecchio Avatar asked Dec 07 '25 08:12

Nicola Montecchio


1 Answers

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
like image 174
hoefling Avatar answered Dec 10 '25 02:12

hoefling