Problem with CUDA 11.6 installation

While installing torch with CUDA support from here I was facing an issue where there was a CUDA version mismatch even after running the command specified on the website.

NVIDIA GeForce RTX 3070 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3070 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

  warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
Could not do one pass in your dataloader, there is something wrong in it. Please see the stack trace below:

After a bit of tinkering around, I realized that the CUDA version from torch.version.cuda was actually 10.2 instead of the 11.6 that I had installed. I reinstalled using the Stable>Linux>Pip>Python>CUDA 11.6 command again just to make sure there wasn’t a mistake on my part, and installing using the 11.3 commands seems to have fixed it.

The error message points to a CUDA 10.2 runtime, which you’ve also confirmed.
The install logs would show which binary will be installed and you either had the CUDA 10.2 PyTorch binary already installed or the install command was wrong.

I just reran the same command for the CUDA 11.6 runtime:

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116

and get:

python -c "import torch; import torchvision; import torchaudio; print(torch.__version__); print(torchvision.__version__); print(torchaudio.__version__)"

1.12.0+cu116
0.13.0+cu116
0.12.0+cu116

I tried upgrading my torch CUDA 10.2 to CUDA 11.6 using the command in the pytorch website. But when I check the cuda version using: torch.version cuda, the cuda version is still showing as 10.2.

You have either an older PyTorch installation in your current environment and would have to uninstall it or the command was wrong and the install logs showed that the default CUDA 10.2 runtime will be installed.
In any case, try to create a new virtual environment, install the desired PyTorch version there, and make sure the install log in your terminal also shows CUDA 11.6.