Install Tensorflow in wsl2 Ubuntu virtual system GPU compatible

Dear all
I have troubles making Tensorflow to rexognise the GPU installed i my machine.
. I have followed instalation guidelines for Windows WSL2 .

I have followed the instructions in the above link but I still I can not make tensorflow recognize the GPU of my compyter.

When I run nvidia-smi in wsl2 it returns my GPU information.
I checked also with conda search cudnn
Loading channels: done

Name Version Build Channel

cudnn 7.0.5 cuda8.0_0 pkgs/main
cudnn 7.1.2 cuda9.0_0 pkgs/main
cudnn 7.1.3 cuda8.0_0 pkgs/main
cudnn 7.2.1 cuda9.2_0 pkgs/main
cudnn 7.3.1 cuda10.0_0 pkgs/main
cudnn 7.3.1 cuda9.0_0 pkgs/main
cudnn 7.3.1 cuda9.2_0 pkgs/main
cudnn 7.6.0 cuda10.0_0 pkgs/main
cudnn 7.6.0 cuda10.1_0 pkgs/main
cudnn 7.6.0 cuda9.0_0 pkgs/main
cudnn 7.6.0 cuda9.2_0 pkgs/main
cudnn 7.6.4 cuda10.0_0 pkgs/main
cudnn 7.6.4 cuda10.1_0 pkgs/main
cudnn 7.6.4 cuda9.0_0 pkgs/main
cudnn 7.6.4 cuda9.2_0 pkgs/main
cudnn 7.6.5 cuda10.0_0 pkgs/main
cudnn 7.6.5 cuda10.1_0 pkgs/main
cudnn 7.6.5 cuda10.2_0 pkgs/main
cudnn 7.6.5 cuda9.0_0 pkgs/main
cudnn 7.6.5 cuda9.2_0 pkgs/main
cudnn 8.2.1 cuda11.3_0 pkgs/main
cudnn 8.9.2.26 cuda11_0 pkgs/main

When I import tensorflow as tf for a example in a jupyter notebook I get the message below

2023-10-05 16:26:25.001261: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-10-05 16:26:25.417745: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-10-05 16:26:25.417798: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-10-05 16:26:25.420745: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-10-05 16:26:25.671635: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-10-05 16:26:25.673640: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-10-05 16:26:27.620975: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

Finally when I run the below line
tf.config.list_physical_devices('GPU')

2023-10-05 17:14:42.129409: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:880] could not open file to read NUMA node: /sys/bus/pci/devices/0000:65:00.0/numa_node
Your kernel may have been built without NUMA support.
2023-10-05 17:14:42.623531: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2211] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at Install TensorFlow with pip for how to download and setup the required libraries for your platform.
Skipping registering GPU devices…

I hope this can help.
Are there any ideas of what I am doing wrong here.
Thanks in advance

Hi @Vaggelis_Di

Welcome to the TensorFlow Forum!

Could you please verify if all the Hardware/Software requirements are satisfied for the WSL2 setup and ensure that you are installing the correct version of CUDA, cuDNN compatible to the installed TensorFlow Version as per this tested build configuration.

Let us know if the issue still persists. Thank you.

Dear Reny,
Thank you for your reply. I checked hardware/software requirements.
I have installed tensorflow tensorflow-2.14.0
and asks for Cudnn8.7 Conda 11.8.
If you check in my first message unisder conda search cudnn the above version is not available in the list.
Should I follow the instructions in this website to install cudnn 8.7 and conda 11.8 (Overview — NVIDIA cuDNN v9.2.1 documentation) ?
My concern is that in this page Overview — NVIDIA cuDNN v9.2.1 documentation
It is mentioned in bold letters, users must not install any NVIDIA GPU Linux driver within WSL 2
So I am confused how I can install cudnn 8.7 and conda 11.8 in wsl2
Thanks in advance

1 Like