In python:
print(torch.cuda.current_device())
Errors:
/home/wireless/anaconda3/lib/python3.12/site-packages/torch/cuda/init.py:129: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 101: invalid device ordinal (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
but run “nvidia-smi”, it can display 3 GPUs.