亲测解决RuntimeError: CUDA error: invalid device ordinal CUDA kernel errors might be asynchronously repo
这个问题是由选错GPU编号导致,改成正确的就好。
问题
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.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
解决办法
"cuda:2"改成"cuda:0"