RuntimeError: CUDA error: invalid device ordinal
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
解决:
device = torch.device(‘cuda:1’)
如果是别的代码,可能把1改成0就行。
DAZLE
# idx_GPU = 4
idx_GPU = 0#改
device = torch.device("cuda:{}".format(idx_GPU) if torch.cuda.is_available() else "cpu")