Pytorch nonnegative device index with CPU?

Viewed 283

I am trying to run PyTorch with a cpu. I instantiate the device with

device = torch.device( "cuda" if torch.cuda.is_available() else "cpu" , index = 0)

and the output of print(device) is device: cpu:0.

But when I try to send tensors to my device with .to(device), I get the error

RuntimeError: Device index must not be negative

Is there another way to manually set the index of a device?

0 Answers
Related