非root用户安装MXNet

时间:2022-08-07 16:06:05

安装MXNet

下载MXNet. 用

git clone: git clone --recursive https://github.com/dmlc/mxnet

本地下载mxnet-master.zip , mshadow, dmlc-core等都是空的…

依据mxnet官方安装文档(http://mxnet.io/get_started/ubuntu_setup.html) k安装mxnet: 用户安装的OpenBLAS和OpenCV, CUDA

cd MXNet
cp make/config.mk . # cmake is for windows. Use config.mk for linux.

将config.mk拷贝至当前路径下. config.mk用来配置Makefile的一些选项和路径等.

1>配置CPU版MXNet:

echo "USE_BLAS=openblas" >>config.mk # 将信息加进config.mk中, >>是定向输出.
echo "ADD_CFLAGS +=-I/PATH/OpenBLAS/include -I/PATH/OpenCV-2.4.13/OpenCV/include" >>config.mk # OpenBLAS和OpenCV安装路径的include路径.
echo "ADD_LDFLAGS += -lopencv_core -lopencv_imgproc -L/PATH/OpenCV-2.4.13/OpenCV/lib -L/PATH/OpenBLAS/OpenBLAS/lib -lopenblas" >>config.mk # 添加库路径和链接选项. imgcodecs是opencv3后才有的, 安装的是OpenCV2.4.13, 没有imgcodecs, 自然就不会生成相应的库. 因此将 -lopencv_imgcoedcs去掉.

配置好这些文件之后, 就可以 make -j$(nproc)了:

make -j12

编译成功.

2>配置GPU版mxnet
首先, /usr/local/cuda /usr/local/cuda-7.5只有在gpu的机器上才有.

config.mk配置如下:

USE_BLAS=openblas
ADD_CFLAGS +=-I/PATH/OpenBLAS/include -I/PATH/OpenCV-2.4.13/OpenCV/include
ADD_LDFLAGS += -lopencv_core -lopencv_imgproc -L/PATH/OpenCV-2.4.13/OpenCV/lib -L/PATH/OpenBLAS/lib -lopenblas
USE_CUDA=1
USE_CUDA_PATH=/usr/local/cuda # CUDA PATH
USE_CUDNN=1
ADD_CFLAGS +=-I/PATH/cuda/include -I/usr/local/cuda/include
ADD_CFLAGS +=-L/PATH/cuda/lib64 -L/usr/local/cuda/lib -L/usr/local/cuda/lib64 # CUDA PATH and LIBRARY.

这些参数的注释别加在config.mk中, 否则会报错:
g++: error: /include: No such file or directory

配置好这些文件之后, 就可以 make -j$(nproc)了:

make -j12