为了跑maskrcnn搭建mxnet,gayhub地址如下:
https://github.com/TuSimple/mx-maskrcnn
源码编译安装参照如下官网:
https://mxnet.incubator.apache.org/install/build_from_source.html
https://mxnet.incubator.apache.org/install/centos_setup.html
下面开始记录各种问题的解决方法:
1.编译空间不足
fatal error: No space left on device
解决:
mkdir ~/tmp
export TMPDIR=~/tmp
参照如下网址:
https://stackoverflow.com/questions/31493663/unable-to-compile-with-make-fatal-error-no-space-left-on-device
2.找不到库
usr/bin/ld: cannot find -l
解决:
ld -lzlib --verbose
会有大概这样的输出:
==================================================
attempt to open /usr/x86_64-linux-gnu/lib64/libzlib.so failed
attempt to open /usr/x86_64-linux-gnu/lib64/libzlib.a failed
attempt to open /usr/local/lib64/libzlib.so failed
attempt to open /usr/local/lib64/libzlib.a failed
attempt to open /lib64/libzlib.so failed
attempt to open /lib64/libzlib.a failed
attempt to open /usr/lib64/libzlib.so failed
attempt to open /usr/lib64/libzlib.a failed
attempt to open /usr/x86_64-linux-gnu/lib/libzlib.so failed
attempt to open /usr/x86_64-linux-gnu/lib/libzlib.a failed
attempt to open /usr/local/lib/libzlib.so failed
attempt to open /usr/local/lib/libzlib.a failed
attempt to open /lib/libzlib.so failed
attempt to open /lib/libzlib.a failed
attempt to open /usr/lib/libzlib.so failed
attempt to open /usr/lib/libzlib.a failed
/usr/bin/ld.bfd.real: cannot find -lzlib
之后这样的命令解决:
sudo ln -s /usr/lib/libz.so.1.2.8 /usr/lib/libzlib.so
参照如下网址:
https://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary
3.找不到模块
undefined reference to imencode()
解决:
修改mxnet的Makefile文件
ifeq ($(USE_OPENCV), 1)
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
ifeq ($(OPENCV_VERSION), 3)
LIBRARIES += opencv_imgcodecs
endif
endif
参照如下两个网址:
https://blog.csdn.net/YhL_Leo/article/details/52150781
https://zhuanlan.zhihu.com/p/29820072
以及opencv的安装参考官网以及如下网址:
https://www.vultr.com/docs/how-to-install-opencv-on-centos-7
4.conda的虚拟环境下无法使用pip
pip freeze # now shows local packages!
pip install # now installs a local package
即可。
参考如下网址:
https://github.com/ContinuumIO/anaconda-issues/issues/1429
5.CUDA相关
Traceback (most recent call last):
File "mxnet/example/image-classification/train_mnist.py", line 1, in
import find_mxnet
File "/home/colin/mxnet/example/image-classification/find_mxnet.py", line 7, in
import mxnet as mx
File "/home/colin/mxnet/example/image-classification/../../python/mxnet/init.py", line 7, in
from .base import MXNetError
File "/home/colin/mxnet/example/image-classification/../../python/mxnet/base.py", line 43, in
_LIB = _load_lib()
File "/home/colin/mxnet/example/image-classification/../../python/mxnet/base.py", line 34, in _load_lib
lib_path = libinfo.find_lib_path()
File "/home/colin/mxnet/example/image-classification/../../python/mxnet/libinfo.py", line 33, in find_lib_path
'List of candidates:\n' + str('\n'.join(dll_path)))
RuntimeError: Cannot find the files.
List of candidates:
/home/colin/mxnet/python/mxnet/libmxnet.so
/home/colin/mxnet/python/mxnet/../../lib/libmxnet.so
解决:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
参考如下网址:
https://github.com/apache/incubator-mxnet/issues/1174
6.opencv又找不到了
error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
解决:
You haven't put the shared library in a location where the loader can find it. look inside the /usr/local/opencv
and /usr/local/opencv2
folders and see if either of them contains any shared libraries (files beginning in lib
and usually ending in .so
). when you find them, create a file called /etc/ld.so.conf.d/opencv.conf
and write to it the paths to the folders where the libraries are stored, one per line.
for example, if the libraries were stored under /usr/local/opencv/libopencv_core.so.2.4
then I would write this to my opencv.conf
file:
/usr/local/opencv/
Then run
sudo ldconfig -v
If you can't find the libraries, try running
sudo updatedb && locate libopencv_core.so.2.4
in a shell. You don't need to run updatedb
if you've rebooted since compiling OpenCV.
参考如下网址:
https://stackoverflow.com/questions/12335848/opencv-program-compile-error-libopencv-core-so-2-4-cannot-open-shared-object-f