As of Nov. 2024, the command to install Pytorch this way (take from site: https://pytorch.org/get-started/locally/) is:
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch-nightly -c nvidia
After install, the cuda can be detected.