TensorFlow 2.1 doesn’t recognize my GPU,though Cuda 10.1. (with Solution)

Kai
LSC PSD
Published in
3 min readFeb 27, 2020

Tensorflow 2.1 was released on the other day. The major feature is that the pip package includes GPU support by default for both Linux and Windows, and it runs on machines with and without NVIDIA GPUs. Oh my god! I’m so happy!!

Let's install TensorFlow 2.1 in my environment immediately. After I ran conda install tensorflow=2.1, I checked my GPU :)

>from tensorflow.python.client import device_lib
>device_lib.list_local_devices()
[name: “/device:CPU:0”
device_type: “CPU”
memory_limit: 268435456
locality {
}
incarnation: 4003817743788326505
]

Hmm… my GPU wasn’t recognized. Now, I try to fix this bug.

Environment: Windows 10.

Precondition: The version of Cuda is correct.

Tensorflow should be build with CUDA 10.1 and cuDNN 7.6. So I confirm these versions.

>nvcc -Vnvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:12:52_Pacific_Daylight_Time_2019
Cuda compilation tools, release 10.1, V10.1.243

Yes, the version of Cuda is correct. I confirmed the version of cuDNN with checking cudnn.h.

If you didn’t install Cuda 10.1 and CuDNN 7.6, you must install them from:

Let’s consider other causes.

Cause 1: CuDNN build installed in Anaconda doesn’t support.

My conda list is below.

cudnn’s build is cuda10.0!

CuDNN build is cuda10.0. This could not be confirmed from nvcc -V. So we need to update the version to cuda10.1.

You can install with conda install cudnn=7.6.5=cuda10.1_0. If you installed tensorflow with pip, you ought to install it with pip.

Now,were you fixed? I still didn’t because there was the other cause.

Cause 2: tensorflow’s build is bad.

Now, my tensorflow’s build is mkl

In Anaconda, there are three types of tensorflow’s builds: eigen, gpu, and mkl. I tried to install another build.

This is a Windows environment. If you use Linux, the name of build is a little different.
  • eigen:conda install tensorlfow=2.1.0=eigen_py37hd727fc0_0
    ->It doesn’t work.
  • gpu: conda install tensorflow=2.1.0=gpu_py37h7db9008_0
    →Worked!

After this, I tried to downgrade cudnn (build=cuda10.0), I was asked to change the version of tensorflow.

So it turned out if we use tensorflow2.1 in Anaconda, we need to use the build of gpu.

Conclusion

>conda list# Name                    Version                   Build  Channel
cudnn 7.6.5 cuda10.1_0
tensorflow 2.1.0 gpu_py37h7db9008_0
tensorflow-base 2.1.0 gpu_py37h55f5790_0

--

--