0


【Debug记录】深度学习Pytorch+Anaconda环境下常见报错的原因及解决方案 | 亲测已解决

001.“AssertionError: Torch not compiled with CUDA enabled”

报错原因: 我所使用的虚拟环境没有显卡资源。通过查询发现是Anaconda基础环境下没有安装pytorch的gpu版

解决方案:
方案一:直接改为用cpu训练

方案二:仍然使用GPU
在基础环境中安装pytorch(cuda与自己电脑版本对应),但是出现了错误002,通过升级conda已解决

conda install pytorch torchvision torchaudio cudatoolkit=11.3-c pytorch

参考博文: 这也太南了趴

002.“RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating environment”

解决方案: 升级conda,通过强制升级解决

# 升级conda也会升级模块版本。
conda update conda
# 如果还报这个错误,就执行强制升级
conda update --force conda

参考博文: zhaojiafu666

003.“FileNotFoundError: [WinError 3] 系统找不到指定的路径。”

报错原因: 路径写的不对,要注意所运行的.py文件与所定位的文件之间的目录级别关系
解决方案: 若路径文件的头与.py文件在同一级目录下,则可用“./”表示
参考博文:FileNotFoundError: [WinError 3] 系统找不到指定的路径。: ‘./datasets/train/ trainA’

004.“Cannot determine archive format of C:\Users\Zz\AppData\Local\Temp\pip-req-build-t35bzb_f”

报错原因: 在更换镜像源下载包时,出现该错误
解决方案: 使用阿里云镜像源进行下载,加入trust命令表示对新镜像源的信任。

pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com 模块名

参考博文:解决ERROR: Cannot determine archive format of C:\Users\Zz\AppData\Local\Temp\pip-req-build-t35bzb_f

005.“RuntimeError: CUDA out of memory. Tried to allocate 2.00 GiB (GPU 0; 10.76 GiB total capacity; 7.67 GiB already allocated; 1.73 GiB free; 8.20 GiB reserved in total by PyTorch)”

报错原因: 显存不足。(只是导入一个三维图像,使用unet模型,batchsize为1,numworks为0,在训练每个epoch后释放缓存torch.cuda.empty_cache(),验证数据时不计算梯度with torch.no_grad())
解决方案: 租张更大的卡试试
参考博文:(原创、不是重复文章)xxx GiB reserved in total by PyTorch的问题


本文转载自: https://blog.csdn.net/m0_51141265/article/details/128060698
版权归原作者 liuuu0 所有, 如有侵权,请联系我们删除。

“【Debug记录】深度学习Pytorch+Anaconda环境下常见报错的原因及解决方案 | 亲测已解决”的评论:

还没有评论