Today’s concert: ONE WORLD : TOGETHER AT HOME. Yup, today, I’ve my previous blog updated. A lot of modifications. Khadas VIM3 is really a good product. With Amlogic’s A311D with 5.0 TOPS NPU, the board itself comes with a super powerful AI inference capability.
- AI inference unit used to be in USB sticks, such as:
- AI inference unit can of course be on board directly, BUT NOT ONLY as an peripheral. For instance:
|Green Timers Lake 1||Green Timers Lake 2||Green Timers Park|
|A Pair of Swans||A Group of Ducks||A Little Stream In The Snow|
After a brief break, I started investigating Khadas VIM3 again.
Khadas VIM3 is a super computer based on Amlogic A311D. Before we start, let’s carry out several simple comparisons.
Please refer to:
Please refer to:
- cnx-software embedded system news - July 29, 2019
- cnx-software embedded system news - August 4, 2019
2. Install Prebuilt Operating System To EMMC Via Krescue
➜ Krescue sudo dd bs=4M if=VIM3.krescue-d41d8cd98f00b204e9800998ecf8427e-1587199778-67108864-279c13890fa7253d5d2b76000769803e.sd.img of=/dev/mmcblk0 conv=fsync
If you really don’t like the WIRED connection, boot into Krescue shell, and use the following commands to set up Wifi:
root@Krescue:~# wifi.config WIFI_NAME WIFI_PASSWORD
Now, let’s try to connect Khadas VIM3 board remotely.
➜ ~ ping 192.168.1.110
Let’s take a look at the SD card device:
root@Krescue:~# ls /dev/mmcblk*
Please refer to the Shell Commands Examples.
curl -sfL dl.khadas.com/.mega | sh -s - -Y -X > /dev/mmcblk? should do.
Let’s bring back Krescue GUI by command
krescue, and select VIMx.Ubuntu-xfce-bionic_Linux-4.9_arm64_V20191231.emmc.kresq and have it flashed onto EMMC.
|Krescue Default||Image Write To EMMC|
|Select Prebuilt OS||Start Downloading OS|
|Start Installation||Installation Complete|
|Krescue Reboot||Ubuntu XFCE Desktop|
Actually, the 8th image in the above just showed Ubuntu XFCE desktop. We can also SSH into it after configuring Wifi successfully.
2.6.1 SSH Into Khadas VIM3
➜ ~ ssh firstname.lastname@example.org
2.6.2 Specs For Khadas VIM3
khadas@Khadas:~$ uname -a
khadas@Khadas:~$ gcc --version
It looks current OpenCV on current VIM3_Ubuntu-xfce-bionic_Linux-4.9_arm64_EMMC_V20191231.img is a kind of outdated. Let’s just remove package opencv3 and have OpenCV-4.3.0 installed manually.
3. Install Manjaro To TF/SD Card
As one of my dreamed operating systems, Manjaro has already provided 2 operating systems for Khadas users to try out.
To flash either of the above systems onto a TF/SD card is simple. However, both are ONLY for SD-USB, instead of EMMC. For instancen:
➜ Manjaro burn-tool -b VIM3 -i ./Manjaro-ARM-xfce-vim3-20.04.img
Before moving on, let’s cite the following word from Boot Images from External Media:
WARNING: Don’t use your PC as the USB-Host to supply the electrical power, otherwise it will fail to activate Multi-Boot!
In this section, we’re testing the computing capability of Khadas VIM3’s NPU.
Before everything starts, make sure you have the galcore module loaded, by using command
Extract the obtained aml_npu_sdk.tgz on your local host. Bear in mind that it is your local host, BUT NOT Khadas VIM3. Relative issues can be found at:
➜ nbg_unify_inception_v3 ll
Do I need to emphasize that I’m using Tensorflow 2.1.0 ? Anyway, check the following:
➜ ~ python
You can of course cross-build the case code on your local host, instead of Khadas VIM3 by referring to Compile the Case Code. (The document seems NOT updated yet.) Instead of using 1 argument, we specify 2 auguments, one for aml_npu_sdk, the other for Fenix.
➜ nbg_unify_inception_v3 ./build_vx.sh ....../aml_npu_sdk/linux_sdk/linux_sdk_220.127.116.11 ....../fenix
inceptionv3 now should be ready to use, but in my case, it’s NOT working properly. It’s probably because Fenix is NOT able to provide/represent the correct cross-compile toolchains for my installed VIMx.Ubuntu-xfce-bionic_Linux-4.9_arm64_V20191231.emmc.kresq. Anyway, this is NOT my preference.
4.3.2 Directly Build on Khadas VIM3
Let’s leave this for the next section 4.4 Run Executable on Khadas VIM3.
4.4 Run Executable on Khadas VIM3
khadas@Khadas:~$ sudo apt install aml-npu
And with command line
dpkg -L aml-npu, you’ll see what’s been installed by aml-npu. However, due to its commercial license, I may NOT be allowed to show anything here in my blog.
khadas@Khadas:~$ sudo apt install aml-npu-demo
Where is the sample to run?
Alright, let’s try it.
khadas@Khadas:~$ cd /usr/share/npu/inceptionv3
The program runs smoothly.
Clearly, ALL (really???) required development files have been provided by aml-npu, in such, we should be able to build this demo inceptionv3 out by ourselves.
18.104.22.168 You STILL Need aml_npu_sdk from Khadas
Besides aml-npu from repo, in order to have the demo inceptionv3 fully and successfully built, you still need aml_npu_sdk from Khadas. In my case, you do need acuity-ovxlib-dev, and let’s do
We don’t need to copy the entire aml_npu_sdk onto Khadas VIM3, but ONLY demo/inceptionv3. Here in my case, ONLY demo/inceptionv3 is copied under
This is almost the same as folder nbg_unify_inception_v3 shown in 4.2 Model Conversion on Host.
Now, The MOST important part is to modify makefile.
khadas@Khadas:~/Programs/inceptionv3$ cp makefile.linux makefile
My makefile is modified as follows.
khadas@Khadas:~/Programs/inceptionv3$ cat makefile
In fact, you still need to modify common.target a little bit accordingly. However, to disclose it in this blog is still NOT allowed I think. Anyway, after the modification, let’s make it.
Don’t worry about the error. It just failed to run the demo, but the executable inceptionv3 has already been successfully built under folder bin_r.
khadas@Khadas:~/Programs/inceptionv3$ ll bin_r
Let’s run inceptionv3 under folder bin_demo.
khadas@Khadas:~/Programs/inceptionv3$ cd bin_demo/
This is the original status of ALL files under bin_demo. Let’s copy and paste our built bin_r/inceptionv3 into this folder bin_demo. The size of the executable seems to be dramatically decreased.
khadas@Khadas:~/Programs/inceptionv3/bin_demo$ cp ../bin_r/inceptionv3 ./
khadas@Khadas:~/Programs/inceptionv3/bin_demo$ ll inception_v3.nb
Finally, let’s run the demo.
khadas@Khadas:~/Programs/inceptionv3/bin_demo$ ./inceptionv3 ./inception_v3.nb ./dog_299x299.jpg
khadas@Khadas:~/Programs/inceptionv3/bin_demo$ ./inceptionv3 ./inception_v3.nb ./goldfish_299x299.jpg
By comparing to imagenet_slim_labels.txt under current folder, let’s take a look at our inference results. Only the FIRST inference is qualified because of the probability.
|Index||Result for dog_299x299.jpg||Result for goldfish_299x299.jpg|
|1||208: ‘curly-coated retriever’,||2: ‘tench’,|
|2||209: ‘golden retriever’,||795: ‘shower cap’,|
|3||223: ‘Irish water spaniel’,||974: ‘cliff’,|
|4||268: ‘miniature poodle’,||408: ‘altar’,|
|5||185: ‘Kerry blue terrier’,||393: ‘coho’,|
5. Dual Boot From Manjaro
5.1 How to Boot Images from External Media?
There are clearly 2 options:
- dual boot by selecting devices: EMMC or TF/SD Card. On Boot Images from External Media, it’s recommended as
Via Keys mode (Side-Buttons) - the easiest and fastest way, which is the FIRST option on page How To Boot Into Upgrade Mode. Therefore, by following 4 steps as follows(cited from How To Boot Into Upgrade Mode), we should be able to boot into SD-USB.
- Power on VIM3.
- Long press the POWER key without releasing it.
- Short press the ‘Reset’ key and release it.
- Count for 2 to 3 seconds, then release the POWER key to enter into Upgrade Mode. You will see the sys-led turn ON when you’ve entered Upgrade Mode.
- multiple boot via grub: Reasonably speaking, 2 operating systems may even have a chance to be installed onto a SINGLE EMMC
5.2 How to flash Manjaro XFCE for Khadas Vim 3 from TF/SD card to EMMC?
ONLY 1 operating system is preferred. Why??? Khadas VIM3 board comes with a large EMMC of size 32G.
After a VERY long time struggling, I would really like to emphasize the quality of Type C cable and power adaptor again. Try to buy things NOT from Taobao.
Finally, I had Manjaro XFCE for Khadas Vim 3 on SD card booted and running, as follows:
➜ ~ ssh email@example.com