You could run:
import torch
x = torch.randn(1).cuda()
print(x)

If this code snippet is showing a random tensor on a cuda device, your environment looks alright.
Also, if that’s the case, we would need to get more information about the error you are seeing.
Could you post the complete stack trace here, please?