Running NPU Sample Programs on Solus and Setting Up NFS Environment to Run NPU Programs on YY3568
After the operation in the previous chapters, we are now delving into the development and testing related to the Neural Processing Unit (NPU). In this chapter, I document the simulation of NPU sample programs on Solus and the practical testing of NPU programs on the YY3568 board. The focus of this chapter is on setting up the simulation environment on Solus and overcoming challenges in establishing an NFS environment for seamless file transfer between YY3568 and Solus. I encountered several issues during this process, which are documented below.
- Building the simulation environment encountered an issue when installing the bfloat16 package using pip, resulting in an error (error: ‘unique_ptr’ in namespace ‘std’ does not name a template type). The solution was to download the latest source code, create an sdist package, and install it locally using pip.
- During the setup of the NFS environment, an unexpected error occurred. Checking the status with systemctl status nfs-server.service revealed an error (rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)). After a step-by-step investigation, it was determined that the issue was caused by an incorrect /etc/netconfig file (which was surprisingly empty). Copying sample content found online into the file resolved the problem.
- Additionally, it was discovered that the default root filesystem compiled by buildroot lacked mount.nfs support and needed to be enabled.
Setting up the NPU simulation environment on Solus
The main references for this process are:
- Rockchip_Quick_Start_RKNN_SDK_V1.3.0_CN.pdf
- Rockchip_RKNPU_User_Guide_RKNN_API_V1.3.0_CN.pdf
- Rockchip_Quick_Start_RKNN_Toolkit2_CN-1.3.0.pdf
- Rockchip_User_Guide_RKNN_Toolkit2_CN-1.3.0.pdf
Since Solus already has Python 3.8, the installation was performed according to the dependencies of Python 3.8.
python3.8 -m pip install -r requirements_cp38-1.3.0.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
Due to issues with the 'bfloat16' package on PyPI, as shown in the screenshot below:
The latest version of 'bfloat16' has already fixed this issue. Initially, I attempted to modify the source code downloaded by pip, but I couldn't find the source code. Later, I found the upstream repository's source code on GitHub. Below are the steps on how to package and install it. After researching, I learned about Source Distribution. I tried running 'python setup.py sdist' in the bfloat16 source code, successfully creating a package. Then, I used 'pip install xxxx' to install it. After resolving this issue, I followed the documentation for model testing. I selected the 'external/rknn-toolkit2/examples/tflite/mobilenet_v1' sample, and the result screenshot is as follows:
From the image, you can see the Top 5 results displayed by the simulation results. Subsequently, you can compare these results with the actual execution on YY3568.
2. Setting up the NFS Environment on Solus and Testing the Same NPU Example on YY3568
This article has been delayed for so long due to the issue with the NFS service, which troubled me for nearly two days. Otherwise, the article would have been published yesterday. Initially, I tried to install the nfs-utils package from the official repository using eopkg install nfs-utils. Surprisingly, the nfs-server.service could not start properly. I found this quite astonishing, so I posted a thread "start nfs-server.service failed." Fortunately, there were enthusiastic community members who replied. I attempted to manually install the latest version of nfs-utils-2.6.3, but still, the nfs service couldn't start properly. I tried to examine the nfs-utils code based on the systemd error prints. In this process, I gained further insights into using journalctl to view logs, such as:
- To view more detailed print information, you can use sudo journalctl -x, which provides additional content compared to the regular user's journalctl.
- Additionally, journalctl -p xx allows filtering logs based on priority level. If a single digit is specified, it prints logs with a priority less than or equal to that level. If a range is given (e.g., 1...2), it prints logs within the specified range.
Thanks to journalctl, it gradually helped me solve this problem. Firstly, I learned from this source that the nfs-server needs to start the rpcbind service. I attempted to start the rpcbind service using systemd and checked the logs with journalctl. I discovered that it was trying to open the /etc/netconfig file, which was unexpectedly empty. I searched for a sample of this file and found relevant content, which I then copied into the file as follows:
1. udp6 tpi_clts v inet6 udp - -
2. tcp6 tpi_cots_ord v inet6 tcp - -
3. udp tpi_clts v inet udp - -
4. tcp tpi_cots_ord v inet tcp - -
5. rawip tpi_raw - inet - - -
6. local tpi_cots_ord - loopback - - -
7. unix tpi_cots_ord - loopback - - -
After starting rpcbind and resolving the issue, I successfully started nfs-server. I then tested the local mount, and it passed. The screenshot is as follows:
The next step was to test it on YY3568, and I found that it surprisingly did not have the mount.nfs tool by default. So, I had to enable NFS utils compilation in Buildroot, copy the necessary mount.nfs and the dependency library libtirpc.so.3.0.0 to the YY3568, and then I could successfully mount NFS. I tested the external/rknpu2/examples/rknn_mobilenet_demo program, and the screenshot is as follows:
Comparing the simulation results on Solus, it's evident that the testing results on YY3568's NPU exhibit significant consistency.
Comments
Please log in or sign up to comment.