PyTorch 环境配置踩坑记录 – 1

首先配好 Anaconda

参照https://blog.csdn.net/weixin_47525457/article/details/115287373

1.5G的包始终装不上

用镜像。如清华提供的镜像:

 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

CUDA 不匹配

典型报错:

The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_61 sm_70 sm_75 compute_37.
If you want to use the GeForce RTX 3060 Laptop GPU GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

在NVIDIA的控制面板里查看CUDA版本,我是11.6.58,故而在下载Pytorch的时候应当使用这样的指令:

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

OSError: [WinError 1455] 页面文件太小,无法完成操作。

往往体现在。

Error loading “\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll“ or one of its dependencies.

首先需要在控制面板-查看高级系统设置中,给Python的安装盘(我是D盘)配置额外的虚拟内存。

参见https://www.cnblogs.com/blue-lin/p/14982097.html

同时调小 BATCH_SIZE 和 num_workers。

之所以调小后者,可参见:

https://github.com/ultralytics/yolov3/issues/1643#issuecomment-985652432

这个comment讲得鞭辟入里。

具体来说就是,它会载入一个dll文件,尽管这个dll文件里的绝大部分都用不到;windows系统会给它预留非常充分的内存;而多线程运行的时候每次 import torch 都会载入一遍,这就无端占据了巨额的内存,以至于怎么分配都不足够。

无论如何,总算跑起来了!

(希望不会有下一个踩坑记录)