GPU-Enabled TensorFlow/PyTorch Setup without Manually Installing CUDA and cuDNN— Conda-Forge

Reza Kalantar
2 min readNov 29, 2022

--

If you have ever tried to install TensorFlow-GPU with the compatible versions of CUDA and cuDNN, you know that it is probably one of every data scientist’s nightmares because of version mismatch! Well, you are in the right place to bypass this headache, because conda-forge have released the builds that include the tested configurations of TensorFlow-GPU/PyTorch, CUDA and cuDNN.

Let’s create a conda environment:

$ conda create -n myenv python=3.9
$ conda activate myenv

Tensorflow-GPU conda-forge installation (similarly, Tensorflow-CPU for CPU default configurations):

$ conda install tensorflow-gpu -c conda-forge

Using ‘conda install tensorflow-gpu’ alone will lead to TensorFlow and cuDNN version mismatch, as cuDNN is no longer installed automatically by Anaconda. More information on version compatibility can be found here.

Check if GPU device is found by TensorFlow:

$ python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
GPU device detected

This configuration includes 12 CUDA-enabled packages, from which the most import are:

python=3.10.8
tensorflow=2.10.0
tensorflow-gpu=2.10.0
cudatoolkit=11.7.0
cudnn=8.4.1.50

The working Nvidia Driver from the shell output:

$ nvidia-smi
Nvidia Driver

More information available here … Happy coding!!

Find me on Github and LinkedIn, or get in touch from my personal website.

--

--

Reza Kalantar

Medical AI Researcher by Profession • Scientist/Engineer by Trade • Investor by Instinct • Explorer by Nature • Procrastinator by Choice