python - Issues with getting Tensorflow to work with RTX 4060 Laptop - Stack Overflow

时间: 2025-01-06 admin 业界

I am trying to build a CNN model but have noticed that the epoch rates were incredibly slow at 2 seconds per step. I double checked my task manager and noticed that my GPU usage was at 0% and triple checked that Tensorflow was detecting 0 GPUs on the device.

I did some research online and tried building from source by installing the required python version, CuDNN, and CUDA based on the version of Tensorflow installed. However this still didn't work. It turns out that I needed to install WSL2 as I was using Windows 11 which was very easy to do by using the command wsl --install. I was hoping for the best and thought this may fix the issue, but it didn't. Finally I tried modifying my paths in the environment variable and double checking on the bin, include, and lib directories in my CUDA v12.5 directory.

My final approach to attempting to resolve this issue was all found in this github discussion.

As for the code I have ran on VSC to check my GPU:

import tensorflow as tf
print("Num GPUs Available: ",len(tf.config.list_physical_devices('GPU')))

The output:

Num GPUs Available:  0

Tensorflow: 2.18.0

Python version: 3.12.8

CuDNN: 9.3

CUDA: 12.5

OS: Windows 11 with WSL2 installed

Method of installing python: Online

Method of installing CuDNN: Windows -> x86_64 -> Tarball -> 12

Method of installing CUDA: Windows -> x86_64 -> 11 -> exe (network)

Method of installing WSL2: running wsl --install on windows powershell

Any further questions such as hardware specifications, please let me know. Thank you!

Edit: Running the exact same code to test how many readily available GPUs there are on my computer seemed to work on Google Colab by showing that 1 GPU was available. If no solutions work on my local IDE, I may have to rely on using Kaggle API instead and use Google Colab.