Your NVIDIA driver might be too old, which is displayed in the output of nvidia-smi
.
However, even updating it won’t help, since your GeForce GT 540M
uses the Fermi architecture with compute capability 2.1 and is not supported anymore.
PyTorch supports compute capabilities between 3.7 to 9.0 in its current release.