NPU Setup on the Orange Pi 6 Plus

The OrangePi includes an NPU. But to take advantage of it, there are hardware specific components that must be installed to take advantage of it. Some code, such as ONNX modules, may require some conversion to be usable. But before one gets this far, they may want to just see the device work, such as through example code. The Orange Pi 6 Plus manual contains the information that is needed to make use of the NPU. But I have some criticisms in the way they conveyed the information for doing so. The way it is presented in the manual has decision points. I see decision points as possible opportunities to get something wrong in matters where someone is just getting started.

Having installed the Ubuntu image onto my Orange Pi 6 Plus, all of the hardware-specific bits that someone needs are already there as part of the image. However, to use them (in Python), one needs to create a new Python environment and do some configuration so that Python scripts will use those components instead of standard ones that don’t take advantage of Orange Pi-specific hardware. I present an approach to performing these steps in a GitHub repository. Using these scripts, one has fewer decision points. I followed the instructions of the manual and made some decisions, encoding them into a set of scripts. You can find the scripts here: https://github.com/j2inet/OrangePi/tree/main/SixPlus/RunNPUTest

You will need to install Conda for managing your Python environment. If you haven’t already installed it (or your Python environment manager of choice), the commands in install-conda.sh will be of interest ( https://github.com/j2inet/OrangePi/blob/main/SixPlus/RunNPUTest/install-conda.sh ). Create an environment for Python 3.11. (see activate-environment.sh and create-environment.sh if you are using Conda). Once you have your environment activated, run setup.sh to perform the rest of the steps.

This script addresses several concerns. There were some typos in the instructions from Orange Pi. I’ve corrected them in the script that I provide. The script will install other needed components and deactivate some that don’t take advantage of the NPU, replacing them with ones that do. After setup is complete, the script will run two AI scripts from the Whisper examples. It will run the first test using the CPU. When this test runs, you’ll know it. You will hear the fan on the Orange Pi run at full speed. It will then run the example using the NPU. There will be a noticeable drop in fan noise. If that runs, then you can start taking advantage of the NPU in your Python scripts.

There are other environments in which I would like to start using the NPU and may refine this script over time as I have time to explore them.


Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Bluesky: @j2i.net

Swap File and Stability::OrangePi

In my exploration of other SBCs, I was using an OrangePi with 1 gig of ram. I had problems with it locking up. Over the course of a day, I started to realize that I could reliably cause a lockup by starting specific applications or performing specific actions. The lockups were less likely to occur if I did something from the command line vs if I tried to do it using a UI tool. Having already ensured that I had a capable and stable power supply, next up on problems that could lead to the system locking up was running out of memory.

Adding more memory to an SBC isn’t generally an option. When I’ve used a Raspberry Pi, I’ve generally had about 4 gigs of RAM, but no less than 2 gigs (at least not since the Pi 4). Running a Linux OS with the UI enabled (Ubuntu) is new territory for me. I took a recommendation from someone and increased the size of my swap file. The performance meter showed that my swap file was about 512 MB. This may be a reasonable default that allows someone with a small amount of storage to still run the OS. I had a 128 Gig SD card and wasn’t concerned with storage capacity conflicts. I increased the swap file to 2048 MB (2 gigs).

#Turn off the swap file
sudo swapoff -a
#Create a new file that will be our swap file. It will be initialized as being
#populated with zeros. We allocate 2048 blocks of 1 megabyte each (2 gigs)
sudo dd if=/dev/zer0 of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
#Turn the swap file back on and make it permanent
sudo swap /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Another suggestion was to also set the CPU to not throttle its speed. I probably don’t need to do this. It may be more relevant for power supplies that don’t do well with a sudden change in power demands when a CPU switches frequency under heavy load. Nevertheless, I applied it anyway.

sudo apt install cpufrequtils
echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
sudo systemctl restart cpufrequtils

It has been about 48 hours since I applied these changes, and the system has been much more stable! I’m going to remember this setting moving forward, as I have one more OrangePi to setup. I also recommend that if someone is considering this board that they get at least the board with 1.5 gigs (which only cost 4-5 USD more).


Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Bluesky: @j2i.net
YouTube: @j2inet
Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
Telegram: j2inet