Working with GPU for Windows using The Latest CUDA 12.3
Published:
Today, I updated my NVIDIA-driver version to get the most out of my GPU. I quote from this page: Not only can it unlock higher resolutions and increase your fps rates for high-end games, but it can also boost your device’s performance overall.
I am working with NVIDIA GeForce RTX 2060, this GPU might have some limitations to work with complex and large deep learning models and tasks. However, this GPU is still sufficient for most deep learning tasks, and I use it when working with 2D data. Therefore, it is still beneficial to keep up with the latest version of tensorflow in order to work with latest AI framework or libraries. And when we want the most updated tensorflow, we need newer version of CUDA, and by that, we need the latest NVIDIA-driver.
At first, my NVIDIA-driver version was 385.54, which was only suitable for CUDA 10.1, and therefore only suitable for Tensorflow no later than 2.3.0
This blog offers how to upate our nvidia-drivers for windows.
https://www.trustedreviews.com/how-to/how-to-update-nvidia-drivers-4321848
After the update, I got this NVIDIA-driver version: 546.33, which according to CUDA compatibility https://docs.nvidia.com/deploy/cuda-compatibility/, this driver version is suitable with CUDA 12.x.
And just before we install CUDA, we should also see the compatibility between CUDA, cudNN, tensorflow, and python. Which you can see here: https://www.tensorflow.org/install/source#tested_build_configurations. When you are sure with these configurations. You can start to download and install everything again one by one.
To summarize, here is the specific configuration that works for me:
- NVIDIA-driver version 546.33
- Cuda 12.3 (Download here: https://developer.nvidia.com/cuda-downloads)
- cudNN 8.9 (Download here: https://developer.nvidia.com/rdp/cudnn-archive, choose the one for CUDA 12.x)
- Python 2.9.0 (Download here: https://www.python.org/downloads)
- Tensorflow 2.15.0* (see Notes)
- Numpy 1.23.1
I have previously made a detailed step-by-step on how to successfully install CUDA on windows 10 and make use of GPU when working with tensorflow. Please feel free to check this link: https://djrumala.medium.com/an-attempt-to-use-cuda-and-cudnn-for-tensorflow-gpu-on-windows-10-2a824a6c847e)
💡 Notes regarding Tensorflow:
Starting from 2.11.0 version, Tensorflow no longer supports the use of GPU on native windows. Some references why:
- https://stackoverflow.com/questions/75481527/how-make-tensorflow-use-gpu
- https://www.youtube.com/watch?v=Np11T5-_KhA
- https://discuss.tensorflow.org/t/tensorflow-gpu-not-working-on-windows/13120
The simplest solution related to this absence of GPU support on native windows for Tensorflow later than 2.11.0 is to install tensorflow-directml . The installation can be done by pip.
python -m pip install tensorflow-directml-plugin
Please refer to for tensorflow-directml https://github.com/microsoft/tensorflow-directml-plugin#tensorflow-directml-plugin-
Before installing this tensorflow-directml, my tensorflow failed to detect GPU and I almost gave up. This installation is the key solution to this related problem.
Checking Installation Success
Once you are done with all the setups, you can check the status of your installation. You can run python and import tensorflow. After that, write this code to check whether your tensorflow finally can detect the GPU.
tf.config.list_physical_devices('GPU')
You should get this output if all configurations and settings work for you
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'),
PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU')]