mmcv-full==1.3.8版本安装技巧
问题:当torch版本过高的时候,会出现报错:
使用pip或者mim安装时:
# mim install mmcv-full==1.3.8或者
# pip install mmcv-full==1.3.8
报错:
/tmp/pip-install-2dlg1w3o/mmcv-/tmp/pip-install-2dlg1w3o/mmcv-full_e7921b9ade3a4fe2b0be4d44b13028f9/mmcv/ops/csrc/pytorch/cc_attention_cuda.cu:4:10: fatal error: THC/THC.h: No such file or directory
4 | #include <THC/THC.h>
| ^~~~~~~~~~~
compilation terminated.
这是由于高版本torch中除去了THC.h这个文件
解决方案:
- 在github上下载源码,
- 在mmcv/ops/csrc/pytorch/cc_attention_cuda.cu文件中
- 注释起来 #include <THC/THC.h>
- 将THCudaCheck替换成AT_CUDA_CHECK(有4处)
- 回到源码mmcv的stupy.py路径下,执行:
- 执行安装命令(2选1)
MMCV_WITH_OPS=1 pip install -e . #安装mmcv-full版本
pip install -e . #安装mmcv版本