Install CUDA, cuDNN, TensorFlow, PyTorch on RTX 30xx using Ubuntu 20.04 in 2022

Опубликовано: 22 Март 2026
на канале: Talha Anwar
30,705
291

In this tutorial we will learn How to install CUDA, cuDNN, TensorFlow, PyTorch using Ubuntu 20.04 in 2022

Here are commands to install
first step install gcc
sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev
sudo apt install gcc

install cuda
wget https://developer.download.nvidia.com... sh cuda_11.0.3_450.51.06_linux.run

add cuda path
nano ~/.bashrc
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}$
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

install cudnn
tar -xvf cudnn-11.0-linux-x64-v8.0.5.39.tg
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

check installation
nvcc --version

#install pytorch and tensorflow
sudo apt install python3.8-venv
python3 -m venv venv
source venv/bin/activate

check pytorch and tensorflow is picking gpu or not

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

import torch
torch.cuda.is_available()
torch.cuda.get_device_name(0)