ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

在PC端的Ubuntu中安装RKNN Toolkit 1.6.0开发环境

2021-03-07 23:04:22  阅读:894  来源: 互联网

标签:RKNN 1.6 venv whl sudo Toolkit apt install 安装


文章目录

前言

  • 实验室的项目需要用到Firefly的AIO-3399 ProC开发板,在PC端可安装RKNN Toolkit开发套件,总体思路就是,在本地使用PC电脑框架跑相关模型,通过官网相关模型转换代码,将tensorflow/pytorch/mxnet/keras 模型转换成rknn模型,从而可以直接拷贝到嵌入式设备RK3399 pro板子上直接使用。
    安装过程繁琐,故记录下部署过程及遇到的问题,以供自己和各位参考。

一、开发部署环境

PC系统版本:Ubuntu 18.04LTS
RKNN Toolkit版本:1.4.0&1.6.0
Python版本:Python3.6

二、安装过程

sudo apt-get update #检查可更新文件
sudo apt-get upgrade #安装可更新软件

2.1 安装Python3.6

sudo apt update #检查可更新文件
sudo apt install software-properties-common  #安装可添加源的工具
sudo add-apt-repository ppa:deadsnakes/ppa #添加源,否则会无法找到python3.7-dev软件包
sudo apt install python3.6-dev #安装python3.6
sudo apt install python3-tk

2.2 用virtualenv管理python版本

#创建 virtualenv环境
sudo apt install virtualenv #安装virtualenv软件
virtualenv -p /usr/bin/python3.6 venv  #创建虚拟环境
source venv/bin/activate  #激活venv环境
(venv) firefly@firefly:~$  pip3 -V #查看当前pip3所在Python的路径
pip 21.0.1 from /home/firefly/venv/lib/python3.6/site-packages/pip (python 3.6)

至此Python3.6环境配置完成。

2.3 进入目录,列出已下载的离线whl包

离线whl包均从rockcip官方源下载,链接如下:http://repo.rock-chips.com/pypi/simple/
可按自己需要下载对应版本的whl包

ls
mxnet-1.7.0.post2-py2.py3-none-manylinux2014_x86_64.whl
rknn_toolkit-1.6.0-cp36-cp36m-linux_x86_64.whl
tensorflow-1.14.0-cp36-cp36m-manylinux1_x86_64.whl
tensorflow_gpu-1.14.0-cp36-cp36m-manylinux1_x86_64.whl
torch-1.5.1-cp36-cp36m-manylinux1_x86_64.whl

2.4 安装 TensorFlow、 python-opencv等依赖库

(venv) user@admin-machine:~/RKNN1.6.0PC$ pip3 install tensorflow-1.14.0-cp36-cp36m-manylinux1_x86_64.whl 
pip3 install mxnet==1.5.0
pip3 install gluoncv -i https://pypi.tuna.tsinghua.edu.cn/simple

gluoncv依赖关系暂时没搞好,pip自动安装的pillow和matplotlib包的版本不满足RKNN1.6.0所需的版本,后面再说吧

#出现了一下错误
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for ConfigSpace
Failed to build ConfigSpace
ERROR: Could not build wheels for ConfigSpace which use PEP 517 and cannot be installed directly#

 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rknn-toolkit 1.6.0 requires Pillow==5.3.0, but you have pillow 8.1.2 which is incompatible.

2.5 安装相关依赖包和RKNN1.6.0

sudo apt-get install gcc python3-dev
pip3 install rknn_toolkit-1.6.0-cp36-cp36m-linux_x86_64.whl 
Successfully installed Pillow-5.3.0 dill-0.2.8.2 flask-1.0.2 flatbuffers-1.10 h5py-2.8.0 lmdb-0.93 networkx-1.11 onnx-tf-1.2.1 ply-3.11 psutil-5.6.2 rknn-toolkit-1.6.0

#安装完成,测试各模块是否正常
(venv) user@admin-machine:~/RKNN1.6.0PC$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from rknn.api import RKNN
>>> import cv2
>>> import tensorflow
>>> 

2.6 运行官方提供的demo,测试RKNN是否安装成功

(venv) user@admin-machine:~/RKNN1.6.0PC/examples/tensorflow/ssd_mobilenet_v1$ python3 test.py
--> Config model
done
--> Loading model
W The target_platform is not set in config, using default target platform rk1808.
W:tensorflow:From /home/user/venv/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py:1814: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
    options available in V2.
    - tf.py_function takes a python function which manipulates tf eager
    tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
    an ndarray (just call tensor.numpy()) but having access to eager tensors
    means `tf.py_function`s can use accelerators such as GPUs as well as
    being differentiable using a gradient tape.
    - tf.numpy_function maintains the semantics of the deprecated tf.py_func
    (it is not differentiable, and manipulates numpy arrays). It drops the
    stateful argument making all functions stateful.
    
done
--> Export RKNN model
done
--> Init runtime environment
done
--> Running model
done
--> Evaluate model performance
W When performing performance evaluation, inputs can be set to None to use fake inputs.
========================================================================
                               Performance                              
========================================================================
Layer ID    Name                                         Time(us)
57          openvx.tensor_transpose_3                    125
117         convolution.relu.pooling.layer2_2            204
115         convolution.relu.pooling.layer2_2            404
112         convolution.relu.pooling.layer2_2            416
110         convolution.relu.pooling.layer2_2            597
107         convolution.relu.pooling.layer2_2            245
105         convolution.relu.pooling.layer2_2            503
...         ...                                          ...
23          fullyconnected.relu.layer_3                  13
29          fullyconnected.relu.layer_3                  8
Total Time(us): 10218
FPS(600MHz): 73.40
FPS(800MHz): 97.87
Note: Time of each layer is converted according to 800MHz!
========================================================================

done

测试效果对比图
在这里插入图片描述在这里插入图片描述
在这里插入图片描述

三、总结

不同平台,RKNN提供的基于不同Python版本的安装包,安装时不同平台对应的依赖关系需要处理好,具体如下:
1.Windows只提供 Python3.6的安装包。
2. MacOS提供 python3.6和 python3.7的安装包。
3. ARM64平台(安装 Debian 9或 10操作系统)提供 Python3.5 Debain 9)和 Python3.7Debian10)的安装包。
4. Linux_x64平台提供基于 python3.5和 python3.6的安装包。

标签:RKNN,1.6,venv,whl,sudo,Toolkit,apt,install,安装
来源: https://blog.csdn.net/foreverey/article/details/114500003

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有