本文將安裝 DIGITS 2.0 於 Jetson TX1, 作業環境為 JetPack 2.1.

DIGITS 需要使用 NVIDIA Caffe 分支, 可由 GitHub 下載. Caffe 安裝說明請参考 Caffe 與 cuDNN 一文.

下載 NVIDIA Caffe 分支

$ git clone https://github.com/NVIDIA/caffe.git nvcaffe
$ cd nvcaffe/
$ cp Makefile.config.example Makefile.config

(编譯前請確認 USE_CUDNN := 1 是開啟的)
$ make all -j4

安裝 Python 與所需元件

$ sudo apt-get install python python-pip python-numpy python-pydot
$ sudo pip install flask-socketio
$ sudo pip install flask-wtf
$ sudo pip install pyparsing==1.5.7
$ sudo pip install lmdb

编譯 Python Wrapper

$ make pycaffe -j4

由官網下載 DIGITS 2.0

https://developer.nvidia.com/digits

安裝 DIGITS

$ tar xvf digits-2.0.0-prod.tar.gz
$ cd digits-2.0
$ gedit ./install.sh
#venv/bin/python mnist/main.py
python mnist/main.py
$ ./install.sh

調整 DIGITS 配置檔以使用安装於 Jetson TX1 上的 Python, NVIDIA Caffe 與 CUDA Toolkit, 而不是 DIGITS 中預先编譯的

$ cp runme.sh runme_jetsontx1.sh
$ gedit runme_jetsontx1.sh
#!/bin/bash

CAFFE_HOME=~/nvcaffe
CUDA_LIBS=/usr/local/cuda/lib
BOOST_LIBS=$(pwd)/lib/boost
CNMEM_LIBS=$(pwd)/lib/cnmem
#VENV_PATH=$(pwd)/venv

cd digits

CAFFE_HOME=$CAFFE_HOME LD_LIBRARY_PATH=$CUDA_LIBS:$BOOST_LIBS:$CNMEM_LIBS \
    python digits-devserver $@
    #$VENV_PATH/bin/python digits-devserver $@

調整 lmdb map_size ( 1GB)

$ gedit ./digits/tools/create_db.py

     if backend == 'lmdb':
            self.backend = 'lmdb'
            self.db = lmdb.open(self.output_path,
                    map_size= 1000000000, #~1GB
                    map_async=True,
                    max_dbs=0)

啟動 DIGITS

$ ./runme_jetsontx1.sh
  ___ ___ ___ ___ _____ ___
 |   \_ _/ __|_ _|_   _/ __|
 | |) | | (_ || |  | | \__ \
 |___/___\___|___| |_| |___/

 

参考 GitHUB DIGITS 說明, 建立 Dataset 與訓練模型.

https://github.com/NVIDIA/DIGITS/blob/master/docs/GettingStarted.md

建立 MNIST Dataset

DIGITS_NEW_MNIST.png

DIGITS_RESULT_MNIST.png

訓練模型

DIGITS_NEW_TRAIN_MODEL.png

使用 cuDNN (USE_CUDNN := 1) 花费時間為 8 分 2 秒.

DIGITS_RESULT_JETSONTX1_20160505.png

 

DIGITS 日誌供参考

~/Desktop/DIGITS_2.0/digits-2.0$ ./mnist/main.py
Reading labels from ./mnist/train-labels.bin ...
Reading images from ./mnist/train-images.bin ...
Reading labels from ./mnist/test-labels.bin ...
Reading images from ./mnist/test-images.bin ...
Dataset directory is created successfully at './mnist'
Done after 38.1899302006 seconds.

(建立 Dataset)

2016-05-05 07:47:46 [20160505-074745-7327] [DEBUG] Parse Folder (train/val) task started.
2016-05-05 07:47:46 [20160505-074745-7327] [INFO ] Parse Folder (train/val) task started.
2016-05-05 07:47:49 [20160505-074745-7327] [INFO ] Parse Folder (train/val) task completed.
2016-05-05 07:47:49 [20160505-074745-7327] [DEBUG] Create DB (train) task started.
2016-05-05 07:47:49 [20160505-074745-7327] [DEBUG] Create DB (val) task started.
2016-05-05 07:47:49 [20160505-074745-7327] [INFO ] Create DB (train) task started.
2016-05-05 07:47:49 [20160505-074745-7327] [INFO ] Create DB (val) task started.
2016-05-05 07:48:20 [20160505-074745-7327] [DEBUG] Total images added: 17500
2016-05-05 07:48:20 [20160505-074745-7327] [INFO ] Create DB (val) task completed.

(訓練模型)

2016-05-05 08:35:31 [20160505-083530-8de6] [DEBUG] Train Caffe Model task started.
2016-05-05 08:35:31 [20160505-083530-8de6] [INFO ] Train Caffe Model task started.
2016-05-05 08:35:37 [20160505-083530-8de6] [DEBUG] Training 0.0% complete.
2016-05-05 08:35:42 [20160505-083530-8de6] [DEBUG] Training 1.28% complete.
2016-05-05 08:35:48 [20160505-083530-8de6] [DEBUG] Training 2.57% complete.
2016-05-05 08:35:51 [20160505-083530-8de6] [DEBUG] Snapshot saved.
...
2016-05-05 08:43:20 [20160505-083530-8de6] [DEBUG] Training 97.51% complete.
2016-05-05 08:43:26 [20160505-083530-8de6] [DEBUG] Training 98.79% complete.
2016-05-05 08:43:31 [20160505-083530-8de6] [DEBUG] Snapshot saved.
2016-05-05 08:43:33 [20160505-083530-8de6] [INFO ] Train Caffe Model task completed.
2016-05-05 08:43:33 [20160505-083530-8de6] [INFO ] Job complete.

(完)

文章標籤
創作者介紹
創作者 版大 的頭像
版大

嵌入式系統

版大 發表在 痞客邦 留言(0) 人氣()