
κ°. ν΄λΉ μ½λ
if device >= 0:
torch._C._cuda_setDevice(device)
λ. Error Log
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.
ordinal : μμ ( 첫째, λμ§Έ μ΄λ° κ²)
μ μ νμ§ μμ device μμλλ€. deviceλ₯Ό μΆλ ₯ν΄λ΄€μ λ, 1μ΄ λμ€λλ° _cuda_setDevice(1)μ΄ μ€νμ΄ μλλκ² κ°λ€.
μ¬μ©κ°λ₯ν GPUμ κ°μκ° 1κ°μΈλ°
torch._C._cuda_setDevice(device)
μ¬κΈ°μ deviceκ° 1μ΄λΌμ μλ¬κ° λ΄λ€.
device = _get_device_index(device)
μλ§λ μμ μ½λμμ μΈλ±μ€λ₯Ό 1μ λ°ννλ보λ€.
λ°λΌμ μλμ κ°μ΄ μμ ν΄μ£Όμλ€.
torch._C._cuda_setDevice(device-1 or 0)