原因是下载的torch和torchvision版本不是gpu版本的。 解决方案: 卸载torch和torchvision: pip uninstall torch pip uninstall torchvision 再使用如下命令安装: pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html