-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
9ba888f
commit 732552c
Showing
5 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# 示例 - Model | ||
## 模型运行说明 | ||
+ 在 GPU 平台上默认使用 Kernel Primitive API 编写的算子。 | ||
+ 在昆仑芯 2 代(XPU2)平台上使用 Kernel Primitive API 编写的算子需要开启FLAGS\_run\_kp\_kernel环境变量。 | ||
|
||
### XPU Kernel Primitive API Paddle模型运行 | ||
|
||
以 resnet50 为例展示昆仑芯 2 代(XPU2)平台 KP 模型运行的基本流程。</br> | ||
+ 1. 安装 PaddlePaddle XPU2 KP 安装包,当前仅支持 python3.7</br> | ||
``` | ||
pip install https://paddle-wheel.bj.bcebos.com/2.3.0/xpu2/kp/paddlepaddle_xpu-2.3.0-cp37-cp37m-linux_x86_64.whl | ||
``` | ||
+ 2. 下载模型库并安装</br> | ||
``` | ||
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git | ||
cd PaddleClas | ||
python -m pip install -r requirements.txt | ||
``` | ||
+ 3. 下载数据集<br> | ||
``` | ||
cd dataset | ||
rm -rf ILSVRC2012 | ||
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar | ||
tar xf whole_chain_CIFAR100.tar | ||
ln -s whole_chain_CIFAR100 ILSVRC2012 | ||
cd ILSVRC2012 | ||
mv train.txt train_list.txt | ||
mv test.txt val_list.txt | ||
``` | ||
+ 4. 模型运行</br> | ||
``` | ||
cd ../.. | ||
export FLAGS_selected_xpus=0 | ||
export FLAGS_run_kp_kernel=1 | ||
export XPUSIM_DEVICE_MODEL=KUNLUN2 | ||
nohup python tools/train.py \ | ||
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \ | ||
-o Global.device=xpu > ResNet50_xpu2.log & | ||
``` | ||
+ 5. 成功截图如下:</br> | ||
![Model](./images/example_model.png) | ||
|
||
### XPU2 Kernel Primitive API 模型列表 | ||
|
||
序号 | 模型名称 | 类别 | ||
-- | -- | -- | ||
1 | resnet50 | 图像分类 | ||
2 | deepfm | 推荐网络 | ||
3 | wide&deep | 推荐网络 | ||
4 | yolov3-darknet53 | 目标检测 | ||
5 | ssd-resnet34 | 目标检测 | ||
6 | orc-db | 文本检测 | ||
7 | bert-base | 自然语言 | ||
8 | transformer | 自然语言 | ||
9 | gpt-2 | 自然语言 | ||
10 | unet | 图像分割 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Model | ||
## Description | ||
+ On the GPU platform, the operator written by the kernel primitive API is used by default. | ||
+ Operators written using the kernel primitive API on the XPU platform need to enable FLAGS\_run\_kp\_kernel environment variables. | ||
|
||
### XPU kernel primitive API model example | ||
|
||
Take resnet50 as an example to show the basic process of XPU2 KP model operation.</br> | ||
+ 1. Install PaddlePaddle XPU2 KP package. Currently, only python3.7 is supported.</br> | ||
``` | ||
pip install https://paddle-wheel.bj.bcebos.com/2.3.0/xpu2/kp/paddlepaddle_xpu-2.3.0-cp37-cp37m-linux_x86_64.whl | ||
``` | ||
|
||
+ 2. Download model library and install</br> | ||
``` | ||
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git | ||
cd PaddleClas | ||
python -m pip install -r requirements.txt | ||
``` | ||
|
||
+ 3. Downloading datasets <br> | ||
|
||
``` | ||
cd dataset | ||
rm -rf ILSVRC2012 | ||
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar | ||
tar xf whole_chain_CIFAR100.tar | ||
ln -s whole_chain_CIFAR100 ILSVRC2012 | ||
cd ILSVRC2012 | ||
mv train.txt train_list.txt | ||
mv test.txt val_list.txt | ||
``` | ||
|
||
+ 4. Model operation</br> | ||
``` | ||
cd ../.. | ||
export FLAGS_selected_xpus=0 | ||
export FLAGS_run_kp_kernel=1 | ||
export XPUSIM_DEVICE_MODEL=KUNLUN2 | ||
nohup python tools/train.py \ | ||
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \ | ||
-o Global.device=xpu > ResNet50_xpu2.log & | ||
``` | ||
+ 5. Creenshot is as follows: </br> | ||
![Model](./images/example_model.png) | ||
|
||
### XPU2 Kernel Primitive API Model List | ||
Number | Model Name | Category | ||
-- | -- | -- | ||
1 | resnet50 | Image Classification | ||
2 | deepfm | Recommendation Network | ||
3 | wide&deep | Recommendation Network | ||
4 | yolov3-darknet53 | Object Detection | ||
5 | ssd-resnet34 | Object Detection | ||
6 | orc-db | Text Detection | ||
7 | bert-base | Natural Language Processing | ||
8 | transformer | Natural Language Processing | ||
9 | gpt-2 | Natural Language Processing | ||
10 | unet | Image Segmentation |