TX2入门教程软件篇-安装MXNet(jetpack3.3)
TX2入门教程软件篇-安装MXNet(jetpack3.3)
说明:
- 介绍如何在tx2下安装MXNet
- 测试环境:jetpack3.3
步骤:
- 新建目录
mkdir -p ~/dl/Mxnet
cd ~/dl/Mxnet
- 安装依赖:
sudo apt-get update
sudo apt-get -y install git build-essential libatlas-base-dev libopencv-dev graphviz python-pip
sudo pip install pip --upgrade
sudo pip install setuptools numpy --upgrade
sudo pip install graphviz jupyter
- 下载mxnet:
git clone https://github.com/dmlc/mxnet.git --recursive
cd mxnet
- 修改配置增加CUDA支持,无CUDA可不改:
- 进入mxnet里面的make文件夹,更改config.mk
cp make/config.mk .
echo "USE_CUDA=1" >> config.mk
echo "USE_CUDA_PATH=/usr/local/cuda" >> config.mk
echo "USE_CUDNN=1" >> config.mk
- 修改3rdparty/mshadow/make/mshadow.mk
vim 3rdparty/mshadow/make/mshadow.mk
- 修改内容:
- 先找到122行,增加如下
MSHADOW_CFLAGS += -DMSHADOW_USE_PASCAL=1
- 回到mxnet文件夹里面:
make -j $(nproc)
- Python2安装MXNet Python Bindings
cd python
pip install -e . --user
- Python3安装MXNet Python Bindings
cd python
pip3 install -e . --user
测试:
- python2 执行命令:
python example/image-classification/train_mnist.py
- python3 执行命令:
python3 example/image-classification/train_mnist.py
- 输出:
INFO:root:start with arguments Namespace(batch_size=64, disp_batches=100, gpus=None, kv_store='device', load_epoch=None, lr=0.05, lr_factor=0.1, lr_step_epochs='10', model_prefix=None, mom=0.9, monitor=0, network='mlp', num_classes=10, num_epochs=20, num_examples=60000, num_layers=None, optimizer='sgd', test_io=0, top_k=0, wd=0.0001)
INFO:root:Epoch[0] Batch [100] Speed: 948.66 samples/sec accuracy=0.777692
INFO:root:Epoch[0] Batch [200] Speed: 1030.88 samples/sec accuracy=0.915781
INFO:root:Epoch[0] Batch [300] Speed: 1034.63 samples/sec accuracy=0.931250
INFO:root:Epoch[0] Batch [400] Speed: 983.33 samples/sec accuracy=0.932031
INFO:root:Epoch[0] Batch [500] Speed: 968.70 samples/sec accuracy=0.943906
INFO:root:Epoch[0] Batch [600] Speed: 1004.47 samples/sec accuracy=0.940625
INFO:root:Epoch[0] Batch [700] Speed: 990.10 samples/sec accuracy=0.950313
INFO:root:Epoch[0] Batch [800] Speed: 941.56 samples/sec accuracy=0.951094
INFO:root:Epoch[0] Batch [900] Speed: 992.14 samples/sec accuracy=0.955000
INFO:root:Epoch[0] Train-accuracy=0.957770
INFO:root:Epoch[0] Time cost=64.217
INFO:root:Epoch[0] Validation-accuracy=0.963276
INFO:root:Epoch[1] Batch [100] Speed: 942.83 samples/sec accuracy=0.964728
INFO:root:Epoch[1] Batch [200] Speed: 925.19 samples/sec accuracy=0.962187
参考:
- https://elinux.org/Jetson_Zoo#PyTorch_.28Caffe2.29
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号