Environment Setup Guide
This section describes how to burn an image on OrangePi AIpro, customize the installation of CANN and MindSpore, and configure the runtime environment.
1. Image Burning (Taking Windows as an example)
Image burning can be performed in any operating system. Here we will take Windows as an example to demonstrate how to quickly burn an image to your Micro SD card using the appropriate version of the balenaEtcher tool.
1.1 Preparation
Step 1 Insert the Micro SD card into the card reader and the card reader into the PC.
1.2 Downloading the Ubuntu image
Step 1 Click here to go to the mirror download page.
This is only for illustration. Different power development board image download address is different, please check here.
Step 2 Click the arrow icon in the picture to jump to the Baidu Wangpan download page.
Step 3 Select the desktop version to download, it is recommended to download the 0318 version of the environment.
Step 4 Alternative download method.
If the download from Baidu Wangpan is too slow, you can use this link to download directly.
1.3 Downloading the Tools
There are two card-making tools balenaEtcher, Rufus, and you can choose any one of the tools to burn according to your computer.
balenaEtcher:
Step 1 Download balenaEtcher.
Click here to jump to the official website, and click the green download button to jump to where the software is downloaded.
Step 2 Select to download the Portable version.
The Portable version does not require installation, so double-click it to open it and use it.
Step 3 Alternative download method.
If it is too slow to download from the official website, you can use to this link to download directly the balenaEtcher-Setup-1.18.4 software.
Step 4 Open balenaEtcher.
Rufus:
Step 1 Download Rufus
Click this link to download and install.
1.4 Selecting and Burning Images
Here we introduce balenaEtcher, Rufus to burn the image, you can burn according to the corresponding tool.
balenaEtcher burns images:
Step 1 Select Mirror, TF card, and start burn.
Select the image file to be burned (the path where the Ubuntu image downloaded in 1.2 above is saved).
Select the disk letter of the TF card.
Click Start Burning, as shown below:
It takes about 20 minutes to burn and verify, so please be patient:
Step 2 Burning is complete.
After the completion of burning, balenaEtcher is shown in the following figure, if the green indicator icon shows that the image is burned successfully, at this time you can exit balenaEtcher, pull out the TF card and insert it into the TF card slot on the development board to use:
Rufus burns images:
Step 1 Select Mirror, TF card, and start burn.
Insert the sd card into the card reader, insert the card reader into the computer, select the image and sd card, click “Start”.
Step 2 Burning is complete.
Pull out the card reader directly after the wait is over.
2. CANN Upgrading
2.1 Toolkit Upgrading
Step 1 Open a terminal and switch the root user.
Use CTRL+ALT+T
or click on the icon with $_
at the bottom of the page to open the terminal.
Switch the root user, root user password: Mind@123.
# Open a terminal on the development board and run the following command
(base) HwHiAiUser@orangepiaipro:~$ su - root
Password:
(base) root@orangepiaipro: ~#
Step 2 Remove installed CANN packages from the image to free up disk space and prevent installing new CANN packages from reporting low disk space errors.
(base) root@orangepiaipro: ~# cd /usr/local/Ascend/ascend-toolkit
(base) root@orangepiaipro: /usr/local/Ascend/ascend-toolkit # rm -rf *
Step 3 Open the official website of Ascend CANN to access the community version of the resource download address, download the required version of the toolkit package. Taking 8.0.RC2.alpha003 version as an example, as shown below:
Execute the following commands to select the aarch64 or x86_64 package according to the actual output of the environment.
uname -a
Step 4 Go to the Toolkit package download directory.
(base) root@orangepiaipro: /usr/local/Ascend/ascend-toolkit# cd /home/HwHiAiUser/Downloads
Orange Pi AI Pro browser file default download directory: /home/HwHiAiUser/Downloads, users should synchronize to modify the path in the above command when changing the save path.
Step 5 Add execution permissions to the CANN package.
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads# chmod +x ./Ascend-cann-toolkit_8.0.RC2.alpha003_linux-aarch64.run
Step 6 Execute the following command to upgrade the software.
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads#./Ascend-cann-toolkit_8.0.RC2.alpha003_linux-aarch64.run --install
Type Y when this prompt pops up during installation, then press Enter to continue the installation.
After the upgrade is completed, if the following message is displayed, the software upgrade is successful:
xxx install success
xxx indicates the actual package name of the upgrade.
Path after installing the upgrade (default installation path for root user as an example): “/usr/local/Ascend/ ascend-toolkit/
Step 7 Configure and load environment variables.
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads # echo “source /usr/local/Ascend/ascend-toolkit/set_env.sh” >> ~/.bashrc
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads # source ~/.bashrc
2.2 Kernels Upgrading
The binary arithmetic package Kernels relies on the CANN package Toolkit. To perform the upgrade, the current environment needs to have the matching version of Toolkit installed and installed by the same user.
Step 1 Open a terminal and switch the root user.
Password for root user: Mind@123.
# Open a terminal on the development board and run the following command
(base) HwHiAiUser@orangepiaipro:~$ su - root
Password:
(base) root@orangepiaipro: ~#
Step 2 Execute the following command to get the development board NPU model number.
npu-smi info
Step 3 Open the official website of Ascend CANN to access the community edition resources download address, and download the kernel package that is consistent with the CANN package version and matches the NPU model. As shown in the figure below:
Step 4 Go to the Kernels package download directory.
(base) root@orangepiaipro: /usr/local/Ascend/ascend-toolkit# cd /home/HwHiAiUser/Downloads
Default download directory of Orange Pi AI Pro browser file: /home/HwHiAiUser/Downloads
Step 5 Add execution permissions to the kernels package.
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads# chmod +x ./Ascend-cann-kernels-310b_8.0.RC2.alpha003_linux.run
Step 6 Execute the following command to upgrade the software.
(base) root@orangepiaipro: /home/HwHiAiUser/Downloads#./Ascend-cann-kernels-310b_8.0.RC2.alpha003_linux.run --install
After the upgrade is completed, if the following message is displayed, the software upgrade is successful:
xxx install success
xxx indicates the actual package name of the upgrade.
Path after installing the upgrade (default installation path for root user as an example): "/usr/local/Ascend/ ascend-toolkit/latest/opp/built-in/op_impl/ai_core/tbe/kernel".
3. MindSpore Upgrading
3.1 Installing the Official Version of the Website (Taking MindSpore 2.4.10 as an example)
Please note that both installation methods for MindSpore need to be performed under the HwHiAiUser user. Choose either method for installation.
Method 1: Use the CTRL+ALT+T shortcut key or click on the icon with $_ at the bottom of the page to open the terminal, and run the pip install command directly on the terminal.
Method 1: Open the terminal as HwHiAiUser user and run the pip install command directly in the terminal.
(base) HwHiAiUser@orangepiaipro:~$ pip install mindspore==2.4.10
Method 2: Use the CTRL+ALT+T shortcut key or click on the icon with $_ at the bottom of the page to open the terminal. Refer to MindSpore official website installation tutorial to install.
(base) HwHiAiUser@orangepiaipro:~$ pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.4.10/MindSpore/unified/aarch64/mindspore-2.4.10-cp39-cp39-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# Confirm the operating system and programming language, and the default environment of the Orange Pi development board is linux-aarch64 and python3.9
3.2 Installation Verification
Execute the following command:
(base) HwHiAiUser@orangepiaipro:~$ python -c "import mindspore;mindspore.set_context(device_target='Ascend');mindspore.run_check()"
If the output is as follows, it indicates that MindSpore has been successfully installed.
MindSpore version: 2.4.10
The result of multiplication calculation is correct, MindSpore has been installed on platform [Ascend] successfully!