mxnet環境搭建問題總結
為了跑maskrcnn搭建mxnet,gayhub地址如下:
原始碼編譯安裝參照如下官網:
下面開始記錄各種問題的解決方法:
1.編譯空間不足
fatal error: No space left on device
解決:
mkdir ~/tmp
export TMPDIR=~/tmp
參照如下網址:
2.找不到庫
usr/bin/ld: cannot find -l<nameOfTheLibrary>
解決:
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
參照如下網址:
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
參照如下兩個網址:
以及opencv的安裝參考官網以及如下網址:
4.conda的虛擬環境下無法使用pip
pip freeze # now shows local packages!
pip install # now installs a local package
即可。
參考如下網址:
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
參考如下網址:
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.
參考如下網址: