---
# System prepended metadata

title: 誠品綠園道-臨時工作筆記

---

# 誠品綠園道-臨時工作筆記
## 1
agx機器上yolor 編譯成功，效率也不錯確認dockerfile可以正常後移植質心追蹤
yolor api 建立成功 待後續編寫docker compose 
### 安裝 docker-compose
```
sudo apt-get install -y libffi-dev
sudo apt-get install -y python-openssl
sudo apt-get install libssl-dev

sudo pip3 install docker-compose
```

### 預設賦予gpu權限 sudo nano /etc/docker/daemon.json 
```
{
    "default-runtime": "nvidia",
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
```
### 使用 jetson-inference
#### 建立 docker
```
git clone https://github.com/dusty-nv/jetson-inference.git
# 修改 Dockerfile ARG BASE_IMAGE=nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3


```
#### 使用 docker-compose
```
  jetson_inference:
    container_name: jetson_inference_agx
    image: raidavid/jetson_inference_agx
    build:
      context: ./jetson-inference
      dockerfile: Dockerfile
    restart: always
    stdin_open: true
    tty: true
    ports:
      - "5125:6858"
    logging:
      options:
        max-size: "10m"
        max-file: "10"

```
#### 換思路 改在 yolor 中編譯(成功!!!!!!!)
```
apt-get update
apt-get install git cmake libpython3-dev python3-numpy
git clone --recursive https://github.com/dusty-nv/jetson-inference
cd jetson-inference
mkdir build
cd build
cmake ../
make -j$(nproc)
make install
ldconfig
```
#### 年齡性別
```
https://github.com/Venus-Solutions/nvidia-jetson-hands-on-training/blob/028829530f147403c2dd3c1d420481275b6fceca/Day%207/age_estimation/age_estimate_jetson_inference.py
```
#### 測試推論速度
```
No face detected.
0.046926259994506836
have face 
0.11062073707580566
0.11894798278808594
0.11177229881286621
0.11629271507263184
0.11476922035217285
0.08691000938415527
0.09487009048461914
0.09502053260803223
```
#### 改寫 yolor 加入安裝jetson 推論功能
```
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
```
### 建立 docker-compse.yaml
1.centroidtracker: # 輔助 reid 
2.saas_yolor:
3.deepface: 進行中
4.deepstream並使用cv2搭配（尚未）

## 2
國美2的deepstream格式轉換進行到Rai-Export-wts image編譯並上傳完成 因為正在訓練所以改到 3090 pull下來中
### 複製必要檔案
```

scp rai@192.83.188.36:/autotrain/runs/train/person_22_01_19/weights/best.pt ./
scp rai@192.83.188.36:/autotrain/tmp/person_22_01_19/person_22_01_19.cfg  ./
scp rai@192.83.188.36:/autotrain/tmp/person_22_01_19/person_22_01_19.names ./

scp -r /Users/davidyang/Desktop/22_01_30  ubuntu@192.168.50.100:/autotrain/wts/tmpfile

python3 gen_wts_yolor.py -w /autotrain/w/tmpfile/person_01_30/best.pt -c /autotrain/w/tmpfile/person_01_30/person_22_01_19.cfg

mv person_22_01_19.cfg /DeepStream-Yolo/person_22_01_30/person_22_01_30.cfg
mv person_22_01_19.wts /DeepStream-Yolo/person_22_01_30/person_22_01_30.wts


```
### 轉換 wts（尚未自動化）
```


python3 gen_wts_yolor.py -w /autotrain/runs/train/person_22_01_19/weights/best.pt -c /autotrain/tmp/person_22_01_19/person_22_01_19.cfg 

mkdir /autotrain/wts/person_22_01_19
mv *.cfg /autotrain/wts/person_22_01_19
mv *.wts /autotrain/wts/person_22_01_19
cp /autotrain/tmp/person_22_01_19/person_22_01_19.names /autotrain/wts/person_22_01_19
```

### wts to engine (過程佔用4g記憶體)
```
CUDA_VER=11.4 make -C nvdsinfer_custom_impl_Yolo
deepstream-app -c deepstream_app_config.txt
mv model_b50_gpu0_fp32.engine /autotrain/wts/person_22_01_19
mv ./nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so /autotrain/wts/person_22_01_19

```
轉換成功並且下載到本地端等待更換現場電腦


scp -r /Users/davidyang/Desktop/wts/person_22_01_19 ubuntu@192.168.10.2:/home/ubuntu/kafka/deepstream-6.0/sources/apps/sample_apps/deepstream-occupancy-analytics/config

移植完畢