Play with the "Xiao Teng" developer kit Atlas 200I DK A2 and prepare the environment

Insert image description here

0. Background

As we all know, Nvidia's GPUs are in short supply and have various restrictions. Huawei has launched Shengteng AI to provide AI computing power. Let’s play with the “Xiaoteng” developer kit Atlas 200I DK A2 to learn.

1. Burn the image

This step is very simple, prepare a Micro SD card and USB card reader and connect them to the computer.
Then, access the quick start , download the card making tool installation package, select the image, and burn the image to the Micro SD card.

2. Install dependencies

I am using Ubuntu 22.04 and follow this document to install dependencies. (Don’t be lazy, just install and execute the commands inside)

3. Install the Ascend-cann-toolkit software package

Visit https://www.hiascend.com/software/cann/community and download the latest version of the Ascend-cann-toolkit software package.

https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C13SPC703/Ascend-cann-toolkit_7.0.RC1.alpha003_linux-aarch64.run

Insert image description here

Add executable permissions to the software package,

chmod +x 软件包名.run

Using the root user, execute the following command to install the software:

./软件包名.run --install

Reference connection:

4. Install PyTorch

I first tried to install PyTorch 1.11.0 version, but I always got an error when executing the following command. Later, I chose to install PyTorch 2.0.1 version and the execution was successful. Therefore, this article explains how to install PyTorch 2.0.1 version.

python3 -c "import torch;import torch_npu;print(torch_npu.npu.is_available())"

Install PyTorch environment dependencies,

pip3 install pyyaml
pip3 install wheel
pip3 install typing_extensions

Get the installation package,

wget https://download.pytorch.org/whl/torch-2.0.1-cp39-cp39-manylinux2014_aarch64.whl

Install PyTorch,

pip3 install torch-2.0.1-cp39-cp39-manylinux2014_aarch64.whl

5. Install PyTorch plug-in torch_npu

Get the whl package of the PyTorch plug-in,

wget https://gitee.com/ascend/pytorch/releases/download/v5.0.rc2-pytorch2.0.1/torch_npu-2.0.1rc1-cp39-cp39-linux_aarch64.whl

Execute the following command to install:

pip3 install torch_npu-2.0.1rc1-cp39-cp39-linux_aarch64.whl

Execute the following command. If True is returned, the installation is successful.

python3 -c "import torch;import torch_npu;print(torch_npu.npu.is_available())"

Insert image description here
Install torchvision corresponding to the framework version,

pip3 install torchvision==0.15.2

6. Install the APEX mixed precision module

Mixed-precision training uses a mix of single-precision (float32) and half-precision (float16) data types during training, combining the two and using the same hyperparameters to achieve almost the same accuracy as float32. Before the migration is completed and training begins, based on the architectural features of the NPU chip, users need to enable mixed precision to improve model performance. The APEX mixed precision module is a comprehensive optimization library that integrates optimization performance and accuracy convergence, and can provide mixed precision training support in different scenarios.

Due to pep-0440 , we reinstall a specific version of setuptools,

pip install --upgrade pip setuptools==57.5.0

Install dependencies,

apt-get install -y patch build-essential libbz2-dev libreadline-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev m4 dos2unix libopenblas-dev git 

Obtain the APEX source code for Shengteng adaptation,

git clone -b master https://gitee.com/ascend/apex.git

Because I am using version 3.9, modify scripts/build.shthe version number of PY_VERSION to 3.9.


vi scripts/build.sh
---
# PY_VERSION='3.7'
PY_VERSION='3.9'
---

Enter the APEX source code directory of Ascend Adaptation and execute the command to compile and generate a binary installation package.

cd apex
bash scripts/build.sh

Execute the following command to install:

pip3 install apex/dist/apex-0.1_ascend-cp39-cp39-linux_aarch64.whl

end!

Guess you like

Origin blog.csdn.net/engchina/article/details/133053725