python下mxnet 编译安装遇到问题汇总(一)

首先说一下为什么编译安装

通过pip install  mxnet 安装遇到 Illegal instruction (core dumped)

已经过一番查找,原来是因为服务器cpu 指令集sse 不支持,mxnet pip安装支持编码集是avx,

查看命令:cat /proc/cpuinfo
flags        : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology pni cx16 x2apic hypervisor lahf_lm kaiser

最后下定决心进行编译安装。由于编译安装并没有想象中的那么顺利,于是就对遇到的问题进行汇总,以便帮助跟我一样遇到此类问题的同学们。

编译安装mxnet 1.5.1遇到问题汇总

【问题描述】


/bin/sh: 1: cmake: not found
mkldnn.mk:48: recipe for target '/home/***/mxnet/3rdparty/mkldnn/build/install/lib/libdnnl.a' failed
make: *** [/home/***/mxnet/3rdparty/mkldnn/build/install/lib/libdnnl.a] Error 127
make: *** Waiting for unfinished jobs....
make[1]: Entering directory '/home/***/mxnet/3rdparty/dmlc-core'
make[1]: 'libdmlc.a' is up to date.
make[1]: Leaving directory '/home/***/mxnet/3rdparty/dmlc-core'

发现cmake未安装, 

sudo apt-get install cmake

【问题描述】

/build/install/lib/libdnnl.a /home/***/mxnet/3rdparty/dmlc-core/libdmlc.a /home/***/mxnet/3rdparty/tvm/nnvm/lib/libnnvm.a -pthread -ldl -lm -lcblas -fopenmp -lrt  -lopencv_highgui -lopencv_imgproc -lopencv_core -llapack 
a - build/src/executor/eliminate_common_expr_pass.o
a - build/src/executor/graph_executor.o
a - build/src/executor/infer_graph_attr_pass.o
a - build/src/executor/attach_op_execs_pass.o
a - build/src/executor/attach_op_resource_pass.o
a - build/src/kvstore/gradient_compression.o
a - build/src/kvstore/kvstore_utils.o
a - build/src/kvstore/kvstore.o
a - build/src/resource.o
a - build/src/base.o
a - build/src/libinfo.o
a - build/src/initialize.o
/tmp/ccWjRTZm.o: In function `main':
im2rec.cc:(.text.startup+0x2994): undefined reference to `cv::imencode(std::string const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'
collect2: error: ld returned 1 exit status
Makefile:643: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1

经过查验发现:

tool/im2rec.cc 中imencode 方法中传四个参数, 而libopencv-dev 中的imencode接口传五个参数, 然后查了一下g++与gcc的版本是4.9 所以我就把版本升级到5,就能顺利编译了。

【问题描述】

creating 'dist/mxnet-1.5.1-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing mxnet-1.5.1-py2.7.egg
creating /usr/local/lib/pythonpy2.7/dist-packages/mxnet-1.6.0-pypy2.7.egg
Extracting mxnet-1.5.1-pypy2.7.egg to /usr/local/lib/pythonpy2.7/dist-packages
Adding mxnet 1.5.1 to easy-install.pth file

发现安装的mxnet是python2.7的版本,这怎么能行呢?于是乎想一定是操作系统自带的python编译的,反正其他环境已经编译好了,只是在python setup.py install 时,python 的版本不对, 于是乎,把环境切到python3.6.4, 找到mxnet/python/ 执行

python setup.py install

  正式编译通过,也算完美编译安装mxnet.

还有就是mxnet-mkl 这个加速版本以及mxnet-cuXX 版本安装参数该怎么配置,还需要再研究研究,时间有限,下次有时间再将安装心得分享。

你可能感兴趣的:(机器学习与人工智能,mxnet)