# Nvidia Nano + Tensor RT + YOLOv3 主要資料來源:https://medium.com/@penolove15/nvidia-jetson-nano-%E7%94%A8-tensorrt-%E8%B7%91-yolov3-a87ebb0036a7 內容幾乎都一樣, 只是記錄自己實際跑起來的流程 ---- 裝完OS之後, 系統更新 & 裝相關套件 ```` sudo apt-get update sudo apt-get upgrade # setup python3 related library sudo apt-get install python3-dev python3-pip # install jetson monitor tool (這個應該可有可無) sudo -H pip3 install jetson-stats # required by onnx sudo apt-get install cmake protobuf-compiler libprotoc-dev # required by scipy sudo apt-get install libopenblas-dev gfortran # others libs sudo apt-get install libjpeg8-dev libxslt1-dev libfreetype6-dev ```` 設定swap ```` sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile sudo swapon -show ```` 這個swap設定重開機後會消失, 所以要加到 /etc/fstab 裡 ```` echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab ```` 下載yolov3 tensorrt ```` git clone https://github.com/penolove/yolov3-tensorrt.git cd yolov3-tensorrt # download the weights mkdir weights wget -O weights/yolov3.weights https://pjreddie.com/media/files/yolov3.weights # requirement for pycuda, please check your own cuda path export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} # install required libs, `scipy`, `lxml` will take a long time to be installed pip3 install cython pip3 install -r requirements.txt # convert darknet weight into onnx format python3 yolov3_to_onnx.py # max_workspace_size這個參數改不改都可以 # edit the following line in the onnx_to_tensorrt.py # builder.max_workspace_size = 1 << 28 # ori 30(1GB)->28(256MB) # to reduce gpu mem usage from 1GB to 256MB # this script already detect a example image python3 onnx_to_tensorrt.py # wrapper of the detector with eyewitness python3 naive_detector.py --engine yolov3.engine ```` 範例的naive_detector.py有內建偵測 dog.jpg, 結果如下: ```` # builder.max_workspace_size = 1 << 30 result1: ...Running inference on image demo/test_image.jpg... => time: 0.8821 ...Running inference on image demo/test_image.jpg... done in 0:00:20.329890 # builder.max_workspace_size = 1 << 28 # ori 30(1GB) result2: ...Running inference on image demo/test_image.jpg... => time: 0.9913 ...Running inference on image demo/test_image.jpg... done in 0:00:12.393595 ```` 這份python只能跑YOLOv3, 不能跑tiny YOLOv3, 需要找另一份code來用