The network trained on the server is sent to the local desktop computer for infer. As a result, an error is reported
AssertionError: Invalid device id
After careful inspection, it is found that there are multiple GPUs in the original server, and two GPUs were turned on at that time for acceleration.
net1 = nn.DataParallel(net1, device_ids=[0, 1])
However, the local desktop has only one GPU, and the number of calls exceeds, so an error is reported.
net1 = nn.DataParallel(net1, device_ids=)
The above solution to the problem of “assertion error: invalid device ID” in Python is the whole content shared by Xiaobian. I hope it can give you a reference and support developer.