To install cuda compatible pytorch, we need to install:
Before installing CUDA Toolkit and cuDNN, please double check if you have already installed it previously. If you have please skip! If you have, skip straight to installing Pytorch-CUDA version!
To check CUDA version:
nvidia-smi
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 536.45 Driver Version: 536.45 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
Installing CUDA Toolkit:
Based on your CUDA Version, download appropriate CUDA Toolkit from: https://developer.nvidia.com/cuda-toolkit

Follow the installation instructions in the page.
Install cuDNN:
Make sure you do this step AFTER installing CUDA Toolkit.
For Downloading cuDNN we need to register our account on the NVIDIA website: