欢迎光临散文网 会员登陆 & 注册

rknn(1) 准备

2023-04-22 18:56 作者:FineClassFuture  | 我要投稿

    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

    进入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

    

    暂时不想安装cuda、cudnn,选requirements-cpu-ubuntu20.04_py38.txt


    requirements-cpu-ubuntu20.04_py38.txt需要python3.8

    在ubuntu22.04上默认只能安装python3.10/3.11

    执行sudo add-apt-repository ppa:deadsnakes/ppa -y 添加源

    sudo apt install python3.8 python3.8-distutils python3.8-dev 网络不同,速度也不同,在家里太慢了


    使用virtualenv

    sudo apt install virtualenv

    virtualenv -p /usr/bin/python3.8 py3.8venv

    

    使用py3.8venv环境

    source py3.8venv/bin/activate 

    pip3 config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple设置为华为源

    pip3 install -r requirements-cpu-ubuntu20.04_py38.txt安装依赖

    pip3 install rknn_toolkit-1.7.3-cp38-cp38-linux_x86_64.whl

    

会有个cmake编译错误 Protobuf compiler not found

sudo apt install libprotobuf-dev protobuf-compiler


有一个错误

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出错,不是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

继续提示添加-DDOWNLOAD_CATCH=1

cmake .. -DDOWNLOAD_CATCH=1

make -j16

在新环境下继续出错

/opt/rknn/pybind11/build/catch/catch.hpp:6465:33: error: size of array ‘altStackMem’ is not an integral constant-expression

static char altStackMem[SIGSTKSZ];

在asm/signal.h: #define SIGSTKSZ 8192

但是添加include会有问题,直接添加定义

sudo make install


继续出错 --python_out: onnx/onnx-ml.proto: Unknown generator option: dllexport_decl

    dllexport_decl这不是windows的东西吗?怎么会在linux下?


放弃

既然不用GPU,直接弄个ubuntu20.04虚拟机来安装使用吧

(装虚拟机留个心:就像物理硬盘一样,设置两个虚拟盘,一个系统盘,一个资料盘)

(当然有条件的话,直接使用物理硬盘)

又出来个问题 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

>>>

如果导入 RKNN 模块没有失败,说明安装成功。


在 PC 上仿真运行示例

    Linux x86_64 上的 RKNN-Toolkit 自带 Rockchip NPU 模拟器,可以模拟 RKNN 模型在Rockchip NPU 上运行时的行为。

(同样是使用CPU,感觉在虚拟机里比直接运行慢,看来还是得把物理机换成ubuntu20.04)



rknn(1) 准备的评论 (共 条)

分享到微博请遵守国家法律