实验环境:Ubuntu 16.04
- python 3.7.7
- cuda 10.1
- pytorch 1.5.0
- torchvision 0.6.0
- mmcv 1.0.4
因为跑的代码里面用到了mmdet库,出现了以上问题,查询后发现是因为mmdetection用到了pycocotools,本来接口是pycocotools.coco.getCatds,但是mmdetection又在外包了一层,变成了get cat ids,而pycocotools.coco又没有这个成员函数,导致出错。(参考https://blog.csdn.net/happyday_d/article/details/107388511)
github上的解决办法是重装pycocotools,通过命令:
pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
但是!!实验室的服务器没法访问外网,所以我直接在github上进入 GitHub - open-mmlab/cocoapi: COCO API - Dataset @ http://cocodataset.org/,把整个项目download下来传到服务器上,然后在实验环境下进入cocoapi-api/pycocotools这个目录,然后运行
make
然后!!就又出现了错误
gcc: error: ../common/maskApi.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 1
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1
以下是在github上找到的解决办法:
1.安装cython
pip3 install cython
2.修改makefile文件中的python 为python3或者环境对应版本
其实试了前两种方法都没成功,最后!!我试了这个天才办法:
3.卸载cython,安装cython==0.29.33
pip uninstall cython
pip install cython==0.29.33
重新make即可。