Background
I am trying to create a docker image for running both Miniconda and Tensorflow. The Miniconda image has been created and works just fine. The Dockerfile for integrating Tensorflow is as follows:
FROM jedaniels000/miniconda3:py39_4.12.0
RUN conda create -n base2 -c conda-forge tensorflow-gpu=2.8.0
Problem
Attempt 1
When I try to install tensorflow-gpu past version 2.6.0 from a Dockerfile, I get the following conflict message:
UnsatisfiableError: The following specifications were found to be incompatible with your system:
- tensorflow-gpu=2.8.0 -> tensorflow==2.8.0=cuda102py38h32e99bf_0 -> __cuda
Your installed version is: not available
However, when I just create a container from the base Miniconda image docker run -it --rm --name test jedaniels000/miniconda3:py39_4.12.0
and run the exact same command conda create -n base2 -c conda-forge tensorflow-gpu=2.8.0
, everything installs with no conflicts.
Attempt 2
I retried by specifying both the Tensorflow-gpu version and the Tensorflow version in the Dockerfile by replacing the second line with: conda create -n base2 -c conda-forge tensorflow-gpu=2.8.0 tensorflow=2.8.0
and the error changed slightly; possibly more informative.
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Output in format: Requested package -> Available versions
Package tensorflow conflicts for:
tensorflow-gpu=2.8.0 -> tensorflow==2.8.0[build='cuda111py38h2d198b7_0|cuda111py310hffb2d60_0|cuda112py37h01c6645_0|cuda112py39h01bd6f0_0|cuda102py39h30a2e9f_0|cuda110py310h5096daf_0|cuda110py38h502d20a_0|cuda102py37ha17b477_0|cuda102py38h32e99bf_0|cuda110py39hcfb7b87_0|cuda110py37h68f1ac2_0|cuda102py310hcf4adbc_0|cuda112py310he87a039_0|cuda112py38hded6998_0|cuda111py39hd57d6a4_0|cuda111py37h7cf2244_0']
tensorflow=2.8.0The following specifications were found to be incompatible with your system:
- feature:/linux-64::__glibc==2.35=0
- tensorflow=2.8.0 -> tensorflow-base==2.8.0=cuda110py39h3c9bc52_0 -> __glibc[version='>=2.17']
Your installed version is: 2.35
I could be reading this wrong, but it looks like Tensorflow needs a __glibc version greater than (or equal to) 2.17, but I have version 2.35 installed (which is obviously greater than 2.17).
Any help or pointers are greatly appeciated.
Edit: Add second attempt
CodePudding user response:
TL;DR
Use the environmental variable CONDA_OVERRIDE_CUDA (source)
More Explanation
As Anaconda's solver is sometimes difficult to decipher, I tried using Mamba instead in the Dockerfile:
FROM jedaniels000/miniconda3:py39_4.12.0
SHELL ["/bin/bash", "-c"]
RUN source ~/miniconda3/etc/profile.d/conda.sh \
&& conda activate base \
&& conda install -c conda-forge mamba \
&& mamba install -c conda-forge tensorflow-gpu=2.8.0
which yields:
Encountered problems while solving:
- nothing provides __cuda needed by tensorflow-2.8.0-cuda102py310hcf4adbc_0
This leads to the conda-forge documentation discussing the installation of CUDA-enabled packages. A run dependecy, __cuda, checks if the machine has a GPU; however, as the docker build process is not aware of the presence of a GPU, this check fails. An override for this check exists that solves the problem using the environmental variable CONDA_OVERRIDE_CUDA. The Dockerfile that successfully installs the package is as follows:
FROM jedaniels000/miniconda3:py39_4.12.0
RUN CONDA_OVERRIDE_CUDA="11.2" conda install tensorflow-gpu==2.8.0 -c conda-forge