Toybrick EN

中文 / EN
Toybrick EN Wiki TB-RK1808S0 Linux host environment install
Linux host environment install

This section describes an example of how the RK1808 AI compute stick can run mobilenet_v1 quickly on a Ubuntu 18.04 PC based on python 3.6 using RKNN-Toolkit.

Environment preparation

• A computer with ubuntu 18.04.

• RK1808 AI compute stick.

• Plug RK1808 AI compute stick into the USB port of PC,and input lsusb command to view the results (The line be marked in red , 2207:0018 is TB-RK1808S0's ID):

1)Enter the following command:


2)The execution result as shown below:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 003 Device 009: ID 2207:0018

RKNN-Toolkit installation

RKNN-Toolkit is a software development kit for users to perform model conversion, inference and performance evaluation base on python interface.

In this section, we will show how to install RKNN-Toolkit in a X86_64 PC with ubuntu 18.04 and python 3.6. perform the following command:

• Install Python3.6

sudo apt-get install python3.6

• Install OpenCV

 sudo apt-get install -y  python3-opencv

• Install pip3

sudo apt-get install python3-pip

• Plug the RK1808 AI compute stick into the USB port of PC, and the usb device will be displayed on the PC. The root directory structure of the usb device is as follows:


Perform the following steps:

1. In the current user directory, create an rknn directory and enter the rknn directory:

mkdir ~/rknncd ~/rknn

2. Install wget:

sudo apt-get install -y wget

3. Download RKNN-Toolkit from the official FTP file server


4. Install Python dependencies. The minimum version requirement for tensorflow is 1.11.0.Take installing 1.13.1 as an example:

pip3 install --user tensorflow==1.13.1

5. Install RKNN-Toolkit:

pip3 install --user rknn_toolkit-1.2.0-cp36-cp36m-linux_x86_64.whl

Notice: RKNN-Toolkit must match with python version, the default version for ubuntu18.04 is python3.6.

6. Check whether the rknn-toolkit has been successfully installed:

  1)Enter the following command:


  2)Enter the following code in python3 running environment to import RKNN module.

from rknn.api import RKNN

(a)If RKNN has been imported successfully:

$ python3>>> from rknn.api import RKNN>>>

(b)Input quit(), quit from the Python, and Skip the following (3) steps.

(c)If report the following error after import RKNN, it was because the installation package for Tensorflow that RKNN relies on uses the SSE4.2 instruction set and the CPU can’t support those instruction set. So please change a computer which supports SSE4.2 instruction set.

$ python3>>> from rknn.api import RKNN2019-06-25 20:10:25.255397: F tensorflow/core/platform/] The TensorFlow library was compiled to use SSE4.2 instructions, but these aren't available on your machine.

Device access permission modification

1. Plug RK1808 AI compute stick into the USB port of PC, follow these steps to modify the USB device access permissions

(1)Back to U disk root directory, copy “tool/” to “~/rknn” directory. Modify with executable permission.

cp tool/ ~/rknn -f
chmod +x ~/rknn/

(2)Back to ~/rknn directory, must be executed with root authority.

cd  ~/rknn
sudo ./

Notice: This step only need to be executed once during installation and does not need to be executed later.

2. After executing the script, use the lsusb command to view the device number of the TB-1808S0.

(1) Input the following command:


(2)The execution result as shown below:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 003 Device 009: ID 2207:0018

Notice: 'Bus 003 Device 009', '003' and '009' represent bus and device number.

3. We can check the read and write permissions of the RK1808 AI compute stick.

(1)Input the following command:

ls -l /dev/bus/usb/003/009

Notice: “003/009”it's not fixed, please get right bus&device number by lsusb command according to your own situation.

(2)The execution result as shown below (The correct read and write permissions are shown in the red mark):

crw-rw-rw- 1 root root 189, 264 6月 14 16:02 /dev/bus/usb/003/009

Running demo on RK1808 AI compute stick

This section we will take mobilenet_v1 for example, to show how to use RK1808 AI compute stick. Mobilenet_v1 can realize feature extraction of an image and identification of the classification of the image.

The mobilenet_v1 demo directory structure and description are as follow:


l  dataset.txt: a text file containing the test image path.

l  dog_224x224.jpg: test image.

l  mobilenet_v1.tflite: TensorFlow Lite model file.

l  mobilenet_v1.rknn: rknn model file. Generated by non-rknn modelthere is TensorFlow Lite modelthrough the rknn-toolkit convert.

l running script(include rknn model conversion script).

l running scriptonly use to load the rknn model for inference.

Running this demo on RK1808 AI compute stick follow below steps:

1. Download the mobilenet_v1.tar.gz from the official FTP file server and decompress it :

tar xvf mobilenet_v1.tar.gz

2. Enter the mobilenet_v1 directory and execute the

cd mobilenet_v1/

3. Get the following result:

--> config model
--> Loading model
--> Building model
--> Export RKNN model
--> Init runtime environment
--> Running model
-----TOP 5-----
[156]: 0.8837890625
[155]: 0.0677490234375
[188 205]: 0.00867462158203125
[188 205]: 0.00867462158203125
[263]: 0.0057525634765625

--> Begin evaluate model performance
Total Time(us): 7140
FPS: 140.06


According to the above execution results, TOP5 represents the results of the top 5 classifications predicted by the model, wherein [156] indicates the dog's label, and 0.8837890625 indicates the probability of predicting the label. It can be seen that  the predicted result is the most likely for the dog. From the test picture (dog_224x224.jpg), we can see that the prediction result is accurate.

Notice:For more detailed usage and interface instructions of the RKNN-Toolkit, please refer to RKNN-Toolkit user guide _v1.1.0.

Products Store Community Wiki Download About TB

To Top