PyCharm跑项目时遇到的一些问题及解决办法


PyCharm
PyTorch deep learing project
author:zoxiii


问题1

  • 具体问题:
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
  • 解决办法:

  找到Anaconda的虚拟环境的路径,我的路径是D:\Apps\Anaconda3\envs,在虚拟环境的路径对文件libiomp5md.dll进行搜索,会发现多个该文件。保留一个pytorch目录下的即可,另一个可以删除。

问题2

  • 具体问题:
ValueError: num_samples should be a positive integer value, but got num_samples=0
  • 解决办法:
      一般应该是dataset路径设置问题。

问题3

  • 具体问题:
页面文件太小,无法完成操作。 Error loading "D:\Apps\Anaconda3\envs\deblur\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.
  • 问题原因:Python装在D盘,系统没有分配虚拟内存
  • 解决办法:
    在这里插入图片描述

问题4

  • 具体问题:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Apps\Anaconda3\envs\mypytorch\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "D:\Apps\Anaconda3\envs\mypytorch\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
  • 问题原因:文件为空或者其他原因导致文件清空
  • 解决办法:抛出异常
    在这里插入图片描述

问题5

  • 具体问题
    • 该问题是在jupyter notebook使用tensorflow跑CNN遇到的,总是碰到服务挂掉,一开始以为是因为自己的电脑跑不动,但是又觉得不应该啊,按理来说不至于使服务挂掉,就在cmd窗口发现了如下的错误:
Could not load library cudnn_cnn_infer64_8.dll. Error code 126
Please make sure cudnn_cnn_infer64_8.dll is in your library path!

查阅自己的电脑是有这个文件的,但不知为何它查不到(我的cuda和cudnn都是11.5版本是对应的)

在这里插入图片描述
找到了一个大佬写的解决办法

  • 解决办法地址
  • 具体步骤为前往这里如下图所示位置下载一个zlib包,解压缩后找到zlibwapi.dll文件,剪切到C:\Windows\System32位置下面

问题6

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been link
ed into the program. That is dangerous, since it can degrade performance or ca
use incorrect results. The best thing to do is to ensure that only a single Op
enMP runtime is linked into the process, e.g. by avoiding static linking of th
e OpenMP runtime in any library. As an unsafe, unsupported, undocumented worka
round you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow 
the program to continue to execute, but that may cause crashes or silently pro
duce incorrect results. For more information, please see http://www.intel.com/software/products/support/.
  • 具体问题:libiomp5md.dll文件
  • 原因:在Anaconda的虚拟环境中存在两个libiomp5md.dll文件, 其中一个是torch路径下的,另一个是虚拟环境本身路径中的
    在这里插入图片描述
  • 解决办法:删除虚拟环境本身路径中的libiomp5md.dll文件(怕之后出问题也可将该文件备份在其他位置)

问题7

FutureWarning: `multichannel` is a deprecated argument name for `pyramid_gaussian`. It will be removed in version 1.0. Please use `channel_axis` instead.
  • 问题原因:当python的一些工具库更新了新版本而我们使用的还是旧版本,就可能提示FutureWarning说某个功能或者参数已经取消或被替代成别的。
  • 解决办法:FutureWarning不影响项目运行,我们可以设置控制台输出不显示FutureWarning,这样更简洁。
import warnings
warnings.filterwarnings('ignore')

问题8

Can't pickle local object 'MultiSaver.begin_background.<locals>.t'
  • 问题原因:在MultiSaver类中无法存储对象在这里插入图片描述
  • 解决办法:参考地址
    在这里插入图片描述

问题9

  • 当你想要获取当前时刻作为文件名创建文件时
import os
import datetime
logname = os.path.join(log_dir, datetime.datetime.now().isoformat()+'.txt')
with open(logname, 'a') as f:
    f.write('\n')
    ......
  • 问题原因:Windows系统下带有英文冒号的文件无法被创建(Linux可以)
  • 解决办法:
logname = os.path.join(log_dir, datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')+'.txt')

问题10

UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. 
  • 解决办法:调节scheduler.step()的位置,将其放入整个epoch的最后(一般在train.py中)
  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zoxiii

越打赏越生长

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值