Python应用运行时报错,部分错误信息如下:
Traceback (most recent call last):
File “\gradio_ootd.py”, line 24, in
openpose_model_dc = OpenPose(1)
File “\run_openpose.py”, line 32, in init
torch.cuda.set_device(gpu_id)
File “lib\site-packages\torch\cuda__init__.py”, line 420, in set_device
torch._C._cuda_setDevice(device)
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设备序号选择错误,我电脑上只有一个显卡,默认设备序号应该是0,但是应用代码里写的是1:
openpose_model_dc = OpenPose(1)
我没有第二个显卡,执行这里显然会报错,将数字1改成0就可以了。
openpose_model_dc = OpenPose(0)