目录
1. Please use torch.load with map_location to map your storages to an existing device.
RuntimeError: Attempting to deserialize object on CUDA device x but torch.cuda.device_count() is 1. Please use torch.load with map_location to map your storages to an existing device.
原因:这个错误常见于模型加载过程中,主要有以下两种情况
- 在 x 号卡上训练模型,在 y 号卡上预测;
- 在 n张卡上并行训练模型,在m张卡上预测,其中m小于n;
解决方案:指定map_location参数,具体设备号视情况而定。
torch.load(f, map_location='cuda:0') # 单卡
torch.load(f, map_location={'cuda:0', 'cuda:1') # 多卡
2. RuntimeError: CUDA error: out of memory?
解决方案,点击跳转。
3. An HTTP error occurred when trying to retrieve this URL.
这个错误一般是在安装torch、cudatoolkit等包时,由于网络不稳定所导致的,这时候我们可以选择离线下载,再进行手动安装即可。具体的做法是把无法正常的安装包链接复制下来,如下所示:
然后,我们Anaconda或Miniconda对应的文件夹位置,找到pkgs这个文件夹,搜索url这个txt文件:
点击,将所复制的链接黏贴进去:
然后,再启动训练下载这个链接,把它放置到pkgs这个目录下进行手动替换,最后再重新运行安装命令即可。
持续更新ing,欢迎补充推荐。