The version of your cuda driver, nvcc, pytorch should be the same. and the compatibility should follow this table.
https://docs.nvidia.com/deploy/cuda-compatibility/#use-the-right-compat-package
In my case i have:
- CUDA Version: 11.2
- gcc g++ 10.3.0
- nvcc 11.1, V11.1.105
- torch.version >>> ‘1.8.0+cu111’
- torch.version.cuda >>> ‘11.1’
This setup works fine for me.