Cuda 11.7 with pytorch command including "cuda toolkit 11.6"

Hello, I’ve installed pytorch with the following command

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

However, I’ve installed (from the nvidia website) the nvida CUDA 11.7 toolkit.

I’ve run these commands:

print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.current_device())
print(torch.cuda.device(0))
print(torch.cuda.get_device_name(0))

and they show that my GPU was detected.

So, I assume there are no problems with the fact that my installed version of CUDA is 11.7, whereas I’ve used toolkit 11.6 in the pip command to install pytorch.
Am I right?

Thanks in advance for the help.

Your local CUDA toolkit won’t be used unless you build PyTorch from source or custom CUDA extensions, as the pre-built PyTorch binaries ship with their own CUDA runtime (11.6 in your case).

Yes, there won’t be any issue as only your NVIDIA driver will be used if you just run PyTorch scripts. If you want to build custom extensions, I would recommend to install a matching CUDA toolkit.