rknn(1) 準(zhǔn)備
????SDK中有,github上也有
????RK1808/RK1806/RV1109/RV1126:rknpu、rknn-toolkit
????RK3566/RK3568/RK3588/RK3588S/RV1103/RV1106:rknpu2、rknn-toolkit2
????https://github.com/rockchip-linux/rknn-toolkit 比較慢
????You can also download all packages, docker image, examples, docs and platform-tools from baidu cloud:?rknn-toolkit, fetch code: rknn
????百度云:https://eyun.baidu.com/s/3bqgIr0N,rknn
? ??
????目前rknn-toolkit v1.7.3
????進(jìn)入rknn-toolkit-v1.7.3/packages查看,有requirements-cpu.txt、requirements-cpu-ubuntu20.04_py38.txt、requirements-gpu.txt
????requirements-cpu.txt、requirements-gpu.txt需要python3.6
????
? ? 暫時(shí)不想安裝cuda、cudnn,選requirements-cpu-ubuntu20.04_py38.txt
????requirements-cpu-ubuntu20.04_py38.txt需要python3.8
????在ubuntu22.04上默認(rèn)只能安裝python3.10/3.11
????執(zhí)行sudo?add-apt-repository ppa:deadsnakes/ppa?-y 添加源
????sudo apt install python3.8 python3.8-distutils python3.8-dev 網(wǎng)絡(luò)不同,速度也不同,在家里太慢了
????使用virtualenv
????sudo apt install virtualenv
????virtualenv -p /usr/bin/python3.8 py3.8venv
????
????使用py3.8venv環(huán)境
????source py3.8venv/bin/activate?
????pip3 config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple設(shè)置為華為源
????pip3 install -r?requirements-cpu-ubuntu20.04_py38.txt安裝依賴
????pip3 install rknn_toolkit-1.7.3-cp38-cp38-linux_x86_64.whl
????
會(huì)有個(gè)cmake編譯錯(cuò)誤 Protobuf compiler not found
sudo apt install libprotobuf-dev protobuf-compiler
有一個(gè)錯(cuò)誤
Could not find a package configuration file provided by "pybind11"
? ? ? ? (requested version 2.2) with any of the following names:
? ? ? ? ? pybind11Config.cmake
? ? ? ? ? pybind11-config.cmake
是cmake出錯(cuò),不是python模塊
哪里有pybind11 2.2 的?pybind11Config.cmake/pybind11-config.cmake
git clone https://github.com/pybind/pybind11.git
git checkout v2.2.0
mkdir build &&?cd build/ && cmake ..
提示/opt/rknn/py3.8venv/bin/python -m pip install pytest
pip3 install pytest
繼續(xù)提示添加-DDOWNLOAD_CATCH=1
cmake .. -DDOWNLOAD_CATCH=1
make -j16
在新環(huán)境下繼續(xù)出錯(cuò)
/opt/rknn/pybind11/build/catch/catch.hpp:6465:33: error: size of array ‘a(chǎn)ltStackMem’ is not an integral constant-expression
static char altStackMem[SIGSTKSZ];
在asm/signal.h: #define SIGSTKSZ 8192
但是添加include會(huì)有問題,直接添加定義
sudo make install
繼續(xù)出錯(cuò)?--python_out: onnx/onnx-ml.proto: Unknown generator option: dllexport_decl
????dllexport_decl這不是windows的東西嗎?怎么會(huì)在linux下?
放棄
既然不用GPU,直接弄個(gè)ubuntu20.04虛擬機(jī)來安裝使用吧
(裝虛擬機(jī)留個(gè)心:就像物理硬盤一樣,設(shè)置兩個(gè)虛擬盤,一個(gè)系統(tǒng)盤,一個(gè)資料盤)
(當(dāng)然有條件的話,直接使用物理硬盤)
又出來個(gè)問題 joblib>=1.1.1,Ubuntu20.04.06 也就1.1.0
看了下http://mirrors.aliyun.com/pypi/simple有
[global]
timeout=40
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
? ? ? ? http://mirrors.aliyun.com/pypi/simple/
? ? ? ? http://pypi.douban.com/simple
? ? ? ? http://pypi.mirrors.ustc.edu.cn/simple/
[install]
trusted-host=
? ? ? ? pypi.tuna.tsinghua.edu.cn
? ? ? ? mirrors.aliyun.com
? ? ? ? pypi.douban.com
? ? ? ? pypi.mirrors.ustc.edu.cn
檢查 RKNN-Toolkit 是否安裝成功
$ python3
>>> from rknn.api import RKNN
>>>
如果導(dǎo)入 RKNN 模塊沒有失敗,說明安裝成功。
在 PC 上仿真運(yùn)行示例
????Linux x86_64 上的 RKNN-Toolkit 自帶 Rockchip NPU 模擬器,可以模擬 RKNN 模型在Rockchip NPU 上運(yùn)行時(shí)的行為。
(同樣是使用CPU,感覺在虛擬機(jī)里比直接運(yùn)行慢,看來還是得把物理機(jī)換成ubuntu20.04)
