运行时报错:
ImportError: No module named 'libs.box_utils.cython_utils.cython_bbox' 或
ImportError: No module named 'libs.box_utils.cython_utils.cython_nms'
需要先进入 libs/box_utils/cython_utils,
运行 python setup.py build_ext --inplace,显示
Traceback (most recent call last):
File "setup.py", line 55, in <module>
CUDA = locate_cuda()
... ...
AttributeError: 'dict' object has no attribute 'iteritems'
此处需要对cuda进行一些配置,如果暂未安装cuda,可以先将55行: CUDA = locate_cuda() 注释掉,之后再运行 python setup.py build_ext --inplace,此时显示:
{'gcc': ['-Wno-cpp', '-Wno-unused-function']}
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -m64 -fPIC -fPIC -I/home/lishixiang/anaconda2/envs/py3.5/lib/python3.5/site-packages/numpy/core/include -I/home/lishixiang/anaconda2/envs/py3.5/include/python3.5m -c bbox.c -o build/temp.linux-x86_64-3.5/bbox.o -Wno-cpp -Wno-unused-function
creating build/lib.linux-x86_64-3.5
gcc -pthread -shared -L/home/lishixiang/anaconda2/envs/py3.5/lib -Wl,-rpath=/home/lishixiang/anaconda2/envs/py3.5/lib,--no-as-needed build/temp.linux-x86_64-3.5/bbox.o -L/home/lishixiang/anaconda2/envs/py3.5/lib -lpython3.5m -o build/lib.linux-x86_64-3.5/cython_bbox.cpython-35m-x86_64-linux-gnu.so
skipping 'nms.c' Cython extension (up-to-date)
building 'cython_nms' extension
{'gcc': ['-Wno-cpp', '-Wno-unused-function']}
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -m64 -fPIC -fPIC -I/home/lishixiang/anaconda2/envs/py3.5/lib/python3.5/site-packages/numpy/core/include -I/home/lishixiang/anaconda2/envs/py3.5/include/python3.5m -c nms.c -o build/temp.linux-x86_64-3.5/nms.o -Wno-cpp -Wno-unused-function
gcc -pthread -shared -L/home/lishixiang/anaconda2/envs/py3.5/lib -Wl,-rpath=/home/lishixiang/anaconda2/envs/py3.5/lib,--no-as-needed build/temp.linux-x86_64-3.5/nms.o -L/home/lishixiang/anaconda2/envs/py3.5/lib -lpython3.5m -o build/lib.linux-x86_64-3.5/cython_nms.cpython-35m-x86_64-linux-gnu.so
安装成功!
此时再运行相关程序,可以正确运行。
补充:如需运行 libs/setup.py,除了需要将第59行:CUDA = locate_cuda() 注释掉,还需要将以下的176-192行与cuda相关的内容注释掉,方能运行成功:
Extension('rotation.rbbox_overlaps', ['rotation/rbbox_overlaps_kernel.cu', 'rotation/rbbox_overlaps.pyx'], library_dirs=[CUDA['lib64']], libraries=['cudart'], language='c++', runtime_library_dirs=[CUDA['lib64']], # this syntax is specific to this build system # we're only going to use certain compiler args with nvcc and not with # gcc the implementation of this trick is in customize_compiler() below extra_compile_args={'gcc': ["-Wno-unused-function"], 'nvcc': ['-arch=sm_35', '--ptxas-options=-v', '-c', '--compiler-options', "'-fPIC'"]}, include_dirs = [numpy_include, CUDA['include']] ),