Very easy after you installed the drivers as I explained here:
https://acassis.wordpress.com/2023/02/14/getting-started-to-cuda/
$ pip install torch
Testing it:
$ python
>>> import torch
>>> use_cuda = torch.cuda.is_available()
>>> if use_cuda:
... print('__CUDNN VERSION:', torch.backends.cudnn.version())
... print('__Number CUDA Devices:', torch.cuda.device_count())
... print('__CUDA Device Name:',torch.cuda.get_device_name(0))
... print('__CUDA Device Total Memory [GB]:',torch.cuda.get_device_properties(0).total_memory/1e9)
...
__CUDNN VERSION: 8500
__Number CUDA Devices: 1
__CUDA Device Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU
__CUDA Device Total Memory [GB]: 4.094164992
>>>
Bingo! We have CUDA support!!!