Reputation: 368
Tensorflow 2.4.1 doesn't recognize my GPU, even though I followed the official instructions from Tensorflow as well as the ones from NVIDIA for CUDA and NVIDIA for cuDNN to install it in my computer. I also installed it in conda (which I'm not sure if it is needed?).
When I try the official way to check if TF is using GPUs, I get 0:
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
Num GPUs Available: 0
My NVIDIA fulfills the requirements specified by Tensorflow.
I installed CUDA (with CUPTI) and cuDNN as mentioned above, so I got:
ubuntu 20.04 LTS
NVIDIA driver = 460.39
CUDA (+CUPTI) = 11.2
cuDNN = 8.1.1
In a conda environment I have:
python = 3.8
tensorflow = 2.4.1
(which I understand is the new way of having the GPU support)and I installed extra the cudatoolkit==11.0
and cudnn==8.0
for conda
as mentioned here.
It did not work when I didn't have the conda
extra packages, and it still doesn't work even though I installed those extra packages.
Upvotes: 2
Views: 2479
Reputation: 368
After quite a bit of extensive research, it finally works on my computer: the latest versions of the components (i.e. CUDA 11.2
, cuDNN 8.1.0
) are not tested and not ensure a working result in TF 2.4.1. Therefore, this is my final configuration:
nvidia-drivers-460.39
have CUDA 11.2
drivers. However, you can still install CUDA 11.0
runtime and get it from the official NVIDIA archive for CUDA. Following the installing instructions is still mandatory (i.e. adding the path variables and so on).cuDNN
library needs to be on the version 8.0.4. You can get it also from the official NVIDIA archive for cuDNNAfter installing both components on these specific versions, I successfully get:
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
Num GPUs Available: 1
with a few debut messages indicating that the GPU libraries were correctly imported.
By the way! For the folks out there who use Pycharm, either you include the environment variables also in PyCharm, or make them system-wide. Otherwise you won't still get your TF to get the GPUs.
Upvotes: 2