NVIDIA Jetson Nano學習筆記(二):進行深度學習

1. Jetson-inference(Tensor RT)

玩转Jetson Nano(四)跑通jetson-inference

Jetson Nano配置與使用(7)Hello AI World( Inference Only)

由於全部model都在jetson-inference/build/aarch64/bin的關係,我們必須先切換至該目錄下,再執行jetson-inference的相關指令

範例有主要三項:
(1)imgenet用於圖像識別,識別出圖像為蘋果、橘子等等;
(2)detectnet用於目標檢測,標註行人、瓶子、飛機等等;
(3)segnet用於圖像、語義分割等。

#下載加編譯
cd ~
sudo apt-get install git cmake
git clone https://github.com/dusty-nv/jetson-inference
cd jetson-inference
git submodule update --init
mkdir build
cd build
cmake ../
make
sudo make install
#全部的model都在 ~/jetson-inference/build/aarch64/bin
cd ~/jetson-inference/build/aarch64/bin

ImageNet 的檢測

./imagenet-console orange_0.jpg output_0.jpg Detectnet#偵測臉部./detectnet-console subway.jpg subway_detect.jpg facenet

2.安裝Darknet(執行YOLOv3)

可參考之前在TX2上的測試

讓Jetson Nano可以訓練或透過Darknet推論YOLO model。

$ nano ~/.bashrc
$ source ~/.bashrc
#將下列兩行加到 ~/.bashrc後方export PATH=${PATH}:/usr/local/cuda/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64

下載與安裝

git clone https://github.com/pjreddie/darknetcd darknet/nano Makefile

將Makefile中的下列參數內容更改為1

GPU=1CUDNN=1OPENCV=1#更改後存檔,執行 sudo make 即完成。

4.Caffe

玩轉Jetson Nano(六)安裝caffe

Jetson Nano配置與使用(6)Xshell6下caffe安裝

#安裝依賴套件
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

sudo apt-get install --no-install-recommends libboost-all-dev

sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

sudo apt-get install git cmake build-essential
#下載caffe
git clone https://github.com/BVLC/caffe.git
#複製Makefile.config.exampleMakefile.config
cd caffe
sudo cp Makefile.config.example Makefile.config
#修改Makefile.config
sudo nano Makefile.config
【1】将以下内容前的注释符号去掉,分别位于第5行、23行、92行;
5 USE_CUDNN := 1
23 OPENCV_VERSION := 3
92 WITH_PYTHON_LAYER := 1
【2】将第39行 CUDA_ARCH中的20、21内容去掉;
39 CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
40 -gencode arch=compute_35,code=sm_35 \
41 -gencode arch=compute_50,code=sm_50 \
42 -gencode arch=compute_52,code=sm_52 \
43 -gencode arch=compute_60,code=sm_60 \
44 -gencode arch=compute_61,code=sm_61 \
45 -gencode arch=compute_61,code=compute_61
【3】将95、96行修改为以下内容;
95 INCLUDE_DIRS :=
$(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial96 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial#修改Makefile
sudo nano Makefile
【1】修改第181行为以下内容;
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
【2】修改第425行为以下内容;
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
#編譯
sudo make
#測試
進入Python環境
import caffe

5.Pytorch

#安裝pytorch
mkdir pytorch
wget https://nvidia.box.com/shared/static/j2dn48btaxosqp0zremqqm8pjelriyvs.whl -O torch-1.1.0-cp36-cp36m-linux_aarch64.whlsudo pip3 install torch-1.1.0-cp36-cp36m-linux_aarch64.whl#測試
import torch
#安裝torchvision
sudo apt-get install libjpeg-dev zlib1g-dev
git clone -b v0.3.0 https://github.com/pytorch/vision torchvisioncd torchvision
sudo python3 setup.py install
#測試
import torchvision

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store