验证 大神的 faster-mobile-retinaface 算法需要 mxnet , 在这里也是跌了不少坑,跳坑通关过程
记录一下:
参考:
https://mxnet.cdn.apache.org/get_started/jetson_setup
一 下载 1.8.x release 版本
1.8 版本可以跟 cuda-10.02 兼容, 同时兼容 faster-mobile-retinaface
# 科鞋上网
git clone -b v1.8.x --recursive https://github.com/apache/incubator-mxnet.git mxnet_1.8
二 安装 依赖
sudo apt-get update
sudo apt-get install -y \
build-essential \
git \
libopenblas-dev \
libopencv-dev \
python3-pip \
python-numpy
sudo pip3 install --upgrade \
pip \
setuptools \
numpy
#注 mxnet 安装时强制要求有 opencv-dev , 被迫安装, 然后再删掉, 还原我编译安装 的 opencv-4.5
# 我的opencv 安装目录(/usr/)跟 apt 安装的(/usr/local/)不一样
三 更新 cmake
mxnet 需要 3.13 以上 cmake , jetpack 4.4 带的系统是 3.10 。很多开源模型对 cmake 要求版本不一致,且向下兼容也比较难, 所以我选择安装 cmake 到独立位置,使用时通过环境变量切换:
下载 cmake-3.18.4.tar.gz 解压
cd cmake-3.18.4 && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/opt/cmake_3_18_4 -DCMAKE_BUILD_TYPE=Release ../
make -j4
make install
四 编译 mxnet
4.1 进入代码目录:
#cd mxnet_1.8
4.2 新建环境变量脚本 env.build
内容如下:
export PATH=/opt/cmake_3_18_4/bin/:/usr/local/cuda/bin:$PATH
export MXNET_HOME=$PWD/
export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH
4.3 定制 config.mk
cp $MXNET_HOME/make/config_jetson.mk config.mk
jetson nano 下 编辑 config.mk 修改如下:
CUDA_ARCH=-gencode arch=compute_53,code=sm_53
4.4 编译:
比较漫长,我编译了四个小时左右 (swap 一定要有)
source env.build
make -j4
4.5 安装
# 官司推荐安装到代码目录
cd python
pip3 install -e .
# 安装到系统 目录, 使用方便
# 在 python 目录
python3 setup.py install
五 验证
到这里的前提是前几步没有错误, 摘抄官方的测试步骤:
Conclusion and Next Steps
You are now ready to run MXNet on your NVIDIA module. You can verify your MXNet Python installation with the following:
import mxnet
mxnet.__version__
You can also verify MXNet can use your GPU with the following test:
import mxnet as mx
a = mx.nd.ones((2, 3), mx.gpu())
b = a * 2 + 1
b.asnumpy()
If everything is working, it will report the version number. For assistance, head over to the MXNet Forum.
来源: https://mxnet.cdn.apache.org/versions/1.7.0/get_started/jetson_setup.html