重新配置语义分割实验环境遇到的坑

新的框架是semseg, by hs-z

1. 安装apex报错:fatal error: gnu-crypt.h: No such file or directory

本质上是cryptacular的pip源有问题,使用conda install cryptacular即可

 

2. pip install总是安装到别的虚拟环境里

这是因为当前正在使用的pip并非当前虚拟环境里的。这里conda install会默认安装到当前虚拟环境,但是pip并不会。

所以使用 whereis pip查看想要的当前虚拟环境的pip程序的位置,然后使用绝对路径来执行pip install即可

 

3. 关于pip和conda的源

今天是2019年6月10日,目前conda的清华源因为版权问题已经关闭,而pip的清华源仍可以正常使用。

 

4. ModuleNotFoundError: No module named 'yaml'

应该是

conda install pyaml

 

 

5. TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead

首先切换当前的CUDA版本与pytorch的CUDA版本一致

然后卸载已经安装过的apex。

然后: 

git clone https://github.com/NVIDIA/apex.git && cd apex && pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .

 

对于多虚拟环境,可能会有些错乱。此时使用 

whereis pip

来找到你当前虚拟环境的pip执行程序的位置。然后使用pip的绝对路径进行操作。

包括apex上面的最后一步的python也可以使用其绝对路径来安装,保证一定安装到了正确的位置

 

不应该使用下面的这行命令来安装apex:

git clone https://github.com/NVIDIA/apex.git && cd apex && python setup.py install --cuda_ext --cpp_ext

原因可能是我在conda虚拟环境中

 

参考:https://github.com/NVIDIA/apex/issues/214#issuecomment-476399539

 

6. 什么报错都没有,用PDB也没有。在 x = self.layer0(x) 处消失

batch size和输入图片尺寸小一些就好了

 

7. Warning:  apex was installed without --cpp_ext.  Falling back to Python flatten and unflatten.

在已经正确安装的前提下,还坚持报这个错误,说明是个有深度的错误。

 

根据:https://discuss.pytorch.org/t/undefined-symbol-when-import-lltm-cpp-extension/32627/2

两个解决方法:

  1. build cpp extensions with -D_GLIBCXX_USE_CXX11_ABI=1.
  2. build pytorch with -D_GLIBCXX_USE_CXX11_ABI=0

但是apex如何设置额外的编译参数我也不会。根据他们提供的export方法,即:

export CFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1 $CFLAGS"

然后再编译apex,发现在编译过程中这个参数还是等于0,没有效果。

 

最终根据下面这段话:

The best way to solve this problem in any case is to compile Pytorch from source and use that same compiler for the extension. Then all problems go away.

 

决定还是把pytorch和apex都在本机上从源代码编译一遍得了。

 

然后发现pytorch从源代码编译很有困难……遇到了一堆找不到解决办法的BUG,最后想了想把pytorch安装回去吧。

之前安装pytorch和这次的途径不同:

 

之前的方式是:

conda install pytorch torchvision cudatoolkit=10.0

为了加快下载速度,就不想从pytorch官方源下载,而是选择了从conda源下载。

然而在python中,使用:

torch._C._GLIBCXX_USE_CXX11_ABI

发现是True,也就是说

-D_GLIBCXX_USE_CXX11_ABI=1

不满足要求

 

这次使用了pytorch官方的源:

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

神奇的事情发生了,这次

-D_GLIBCXX_USE_CXX11_ABI=0了

还是pytorch官方靠谱……conda上是收录的官方的编译包,更新的不够及时。

 

然后就OK了……………………

 

总结一下,

1. 靠谱的还是官方,不要图省事,也不要总想着自己去编译,那样子问题更多。

2. 遇到问题要到github上相应仓库的issue去查询,这也很重要。特别是,要用英文查询。中文查询都是二手信息。

3. Google的搜索能力的确很厉害,尽量用Google!

 

 

8. ValueError: batch_size should be a positive integer value, but got batch_size=0 

在config文件里的

batch_size_val: 8  # batch size for validation during training, memory and speed tradeoff

需要设置为和GPU一样的数量,虽然不知道为什么。

 

9. cv2.error: OpenCV(4.1.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

data_root不正确,没有读取到数据

 

 

10. Exception: process 0 terminated with signal SIGSEGV

内存不足

目前还无法解决

 只能把分布式训练给关了,暂时可以运行,但是很慢

 

11. pip下载速度慢

linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
 

12. 查看pytorch对应的cuda版本

print(torch.version.cuda)

 

13. libSM.so.6: cannot open shared object file: No such file or directory

https://stackoverflow.com/questions/47113029/importerror-libsm-so-6-cannot-open-shared-object-file-no-such-file-or-directo

pip install opencv-python-headless
# also contrib, if needed
pip install opencv-contrib-python-headless

 

 

14. fatal error: gnu-crypt.h: No such file or directory

在安装apex过程中出现的。应该使用

conda install cryptacular

然后再安装apex

 

转载于:https://www.cnblogs.com/QingHuan/p/10999925.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值