ImportError:..mmcv/_ext.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor6deviceEv解决

ERROR:

 File "/home/wsx/.local/lib/python3.6/site-packages/mmdet/apis/inference.py", line 6, in 
    from mmcv.ops import RoIPool
  File "/home/wsx/anaconda3/envs/pvt/lib/python3.6/site-packages/mmcv/ops/__init__.py", line 2, in 
    from .assign_score_withk import assign_score_withk
  File "/home/wsx/anaconda3/envs/pvt/lib/python3.6/site-packages/mmcv/ops/assign_score_withk.py", line 6, in 
    '_ext', ['assign_score_withk_forward', 'assign_score_withk_backward'])
  File "/home/wsx/anaconda3/envs/pvt/lib/python3.6/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/wsx/anaconda3/envs/pvt/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/wsx/anaconda3/envs/pvt/lib/python3.6/site-packages/mmcv/_ext.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor6deviceEv

原因:

mmcv-full版本和pytorch不匹配 

Solution:

先卸载之前的版本

pip uninstall mmcv-full

安装新的:

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.8.1/index.html

tip:
确认cuda版本,上面是cuda=10.1, torch=1.8.1,根据自己需要安装相应版本
nvcc -v确认cuda版本
pip list | grep torch确认torch的版本

结果又报错:

AssertionError: MMCV==1.5.0 is used but incompatible. Please install mmcv>=1.3.2, <=1.4.0

解决:

pip install mmcv-full==1.3.15 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.8.1/index.html

O了

个人ubuntu 下pvt环境构建

conda install -c pytorch pytorch torchvision  #torch==1.7.0

pip install mmcv-full==1.3.15  -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7.0/index.html 

你可能感兴趣的:(linux,运维,服务器)