Why is Tensorflow not recognizing my GPU after conda install?

Solution 1:

August 2021 Conda install may be working now, as according to @ComputerScientist in the comments below, conda install tensorflow-gpu==2.4.1 will give cudatoolkit-10.1.243 and cudnn-7.6.5

The following was written in Jan 2021 and is out of date

Currently conda install tensorflow-gpu installs tensorflow v2.3.0 and does NOT install the conda cudnn or cudatoolkit packages. Installing them manually (e.g. with conda install cudatoolkit=10.1) does not seem to fix the problem either.

A solution is to install an earlier version of tensorflow, which does install cudnn and cudatoolkit, then upgrade with pip

conda install tensorflow-gpu=2.1
pip install tensorflow-gpu==2.3.1

(2.4.0 uses cuda 11.0 and cudnn 8.0, however cudnn 8.0 is not in anaconda as of 16/12/2020)

Edit: please also see @GZ0's answer, which links to a github discussion with a one-line solution

Solution 2:

The tensorflow build automatically selected by Anaconda on Windows 10 during the installation of tensorflow-gpu 2.3 seems to be faulty. Please find a workaround here (consider upvoting the GitHub answer if you have a GitHub account).

Windows only: Python 3.7: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0

Python 3.8: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0

Solution 3:

@geometrikal solution almost worked for me. But in between installing tensorflow-gpu with conda and installing tensorflow 2.3 with pip, I needed to uninstall the tensorflow parts of the package tensorflow-gpu to avoid conistency warnings by pip. Conda would have uninstalled the whole package. I know Conda does not recommend mixing pip with conda but this is the solution worked that worked and I am tired of spending another day with this issue.

conda create -n tfgpu python=3.7
conda activate tfgpu
conda install tensorflow-gpu=2.1

pip uninstall tensorflow
pip uninstall tensorflow-estimator
pip uninstall tensorboard 
pip uninstall tensorboard-plugin-wit
pip install tensorflow==2.3
pip check

Solution 4:

I also have been unable (yet) to get TF 2.3.0 to recognize my Nvidia Quadro Pro 620 GPU.

Note: I have 2 other 'environments' on this PC (windows Pro) All installed via Anaconda:

  1. Python 3.7.8 TF 2.0.0... recognizes (and uses) the Nvidia GPU
  2. Python 3.6.9 TF 2.1.0... recognizes (and uses) the Nvidia GPU
  3. Python 3.8.6 TF 2.3.0... does NOT see the GPU

My Machine has Cuda 11.1; cuDNN 8.0.5

My next thought is to consider downgrading Python from 3.8.6 to 3.7.8 in the 3rd configuration where TF = 2.3.0

Steve

Solution 5:

You will need to install cuDNN and the CUDA toolkit to use your GPU.

First check for the compatible version here.

cuDNN can be found here (requires free account).

CUDA toolkit can be found here.

Again, check for a compatible version BEFORE installing. Newer versions are not backwards compatible.