目录
- 1.(Install Packages Failed)PackagesNotFoundError: The following packages are not available from current channels: - torch==1.1.0
- 2.编译错误:ModuleNotFoundError: No module named '模块名
- 3.ImportError: cannot import name 'imread'
- 4.TypeError: new() received an invalid combination of arguments - got (numpy.intc, int, int, int), but expected one of:
- 5.ImportError: fast_slic is not configured with avx2 support. Compile it again with flag USE_AVX2.
- 6.在pycharm的terminal输入conda activate时提示出错:CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
- 7. 用户 is not in the sudoers file(linux)
- 8. AttributeError: 'DataParallel' object has no attribute 'attention_block'
1.(Install Packages Failed)PackagesNotFoundError: The following packages are not available from current channels: - torch==1.1.0
解决方法:
1.打开Anaconda3 Prompt,先创建python=3.6的虚拟环境(torch1.1.0是基于python3.6的)
conda create -n python36 python=3.6
2.进入新环境
conda activate python36
3.安装torch1.1.0(cpu版本)
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly -c pytorch
(安装成功后会显示done)
2.编译错误:ModuleNotFoundError: No module named '模块名
解决方法:
此模块找不到,因此需要手动安装:
pip install 模块名
3.ImportError: cannot import name ‘imread’
解决方法:
有两种原因:
1.可能是scipy版本过高,先查看scipy版本,如图
一般要装1.2.1版本,可见此时版本过高,卸载重装即可:
2.不再通过scipy导入imread,通过imageio库来导入:
将from scipy.misc import imread换成
from imageio import imread
4.TypeError: new() received an invalid combination of arguments - got (numpy.intc, int, int, int), but expected one of:
解决方法:
如图,由于此处numpy.int不能与int组合,应该将in_channels的类型修改为int。
5.ImportError: fast_slic is not configured with avx2 support. Compile it again with flag USE_AVX2.
解决方法:
from fast_slic.avx2 import SLICAVX2 as SLIC的时候出错,可能是主机不支持avx2指令集,可以换成from fast_slic import SLIC。
6.在pycharm的terminal输入conda activate时提示出错:CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’.
解决方法:
source activate #可进入base虚拟环境
这可能是因为上次进入conda时未正常退出。使用完conda后输入conda deactivate退出conda,下次就可以直接用conda activate进入环境而不会报错。
7. 用户 is not in the sudoers file(linux)
解决方法:
需要把该用户加入到sudo配置文件中。
1.先输入su -进入root,然后输入visudo进入sudo配置文件。
2.将用户添加进去,按照如图格式:用户名 ALL=…
3.输入完成后:按ctrl+o保存,然后会出现File Name to Write:/etc/sudoers.tmp ,回车,再按ctrl+x退出visudo。(输入exit可退出root)
8. AttributeError: ‘DataParallel’ object has no attribute ‘attention_block’
解决方法:
1.这是因为代码中使用了DataParallel,它相当于对model进行了封装
(1)使用DataParallel前:
(2)使用DataParallel后:原model变成了新model里的module,新model在原model的基础上添加了一些设备信息,如设备序号等。
2.因此只需把self.model.attention_block改成self.model.module.attention_block即可。