-
Notifications
You must be signed in to change notification settings - Fork 873
[MLU] add mlu docs for r2.4 #5432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,21 @@ | ||
| .. _cn_mlu_information: | ||
|
|
||
| #################### | ||
| 寒武纪 MLU 芯片运行飞桨 | ||
| #################### | ||
|
|
||
| 寒武纪 MLU370 系列是一款专门用于深度学习的加速卡。Paddle MLU 版当前可以支持在寒武纪 MLU370 系列板卡上进行模型训练。 | ||
|
|
||
| 参考以下内容可快速了解和体验在寒武纪板卡上运行飞桨: | ||
|
|
||
| - `飞桨框架寒武纪 MLU 版安装说明 <./paddle_install_cn.html>`_ : 飞桨框架寒武纪 MLU 版安装说明 | ||
| - `飞桨框架寒武纪 MLU 版训练示例 <./train_example_cn.html>`_ : 飞桨框架寒武纪 MLU 版训练示例 | ||
| - `飞桨框架寒武纪 MLU 版支持模型 <./paddle_mlu_cn.html>`_ : 飞桨框架寒武纪 MLU 版支持模型列表 | ||
|
|
||
|
|
||
| .. toctree:: | ||
| :hidden: | ||
|
|
||
| paddle_install_cn.md | ||
| train_example_cn.md | ||
| paddle_mlu_cn.md |
131 changes: 131 additions & 0 deletions
131
docs/guides/hardware_support/mlu_docs/paddle_install_cn.md
This file contains hidden or 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,131 @@ | ||
| # 飞桨框架寒武纪 MLU 版安装说明 | ||
|
|
||
| 飞桨框架支持基于 python 的训练和原生预测,当前最新版本为 2.4.0,提供两种安装方式: | ||
|
|
||
| - 通过预编译的 wheel 包安装 | ||
| - 通过源代码编译安装 | ||
|
|
||
| ## 前置条件 | ||
|
|
||
| ### 板卡安装 | ||
|
|
||
| 寒武纪 MLU370 系列板卡安装,可以参见 [寒武纪官网板卡安装教程](https://developer.cambricon.com/index/curriculum/details/id/38/classid/7.html)。 | ||
|
|
||
| ### 驱动安装 | ||
|
|
||
| 寒武纪驱动安装,可以参见 [寒武纪官网驱动安装](https://www.cambricon.com/docs/sdk_1.6.0/driver_4.20.12/user_guide_4.20.12/index.html)。 | ||
|
|
||
| **注意**:建议安装寒武纪驱动版本高于 `v4.20.11`。 | ||
|
|
||
|
|
||
| ## 镜像准备 | ||
|
|
||
| **注意**:当前仅提供基于 Ubuntu18.04 & CNToolkit3.0 的 docker 镜像环境。 | ||
|
|
||
| 首先需要准备支持寒武纪板卡运行环境的 docker 镜像,可以直接从 Paddle 的官方镜像库拉取预先装有 CNToolkit3.0 的 docker 镜像来准备相应的运行环境。 | ||
|
|
||
| ```bash | ||
| # 拉取镜像 | ||
| docker pull registry.baidubce.com/device/paddle-mlu:cntoolkit3.0.2-cnnl1.13.0 | ||
|
|
||
| # 启动容器,注意这里的参数,例如 shm-size, device 等都需要配置 | ||
| # 可以通过 `-v` 参数来挂载训练所需的数据集目录,例如 -v /datasets:/datasets | ||
| docker run --shm-size=128G \ | ||
| --net=host \ | ||
| --cap-add=sys_ptrace \ | ||
| -v /usr/bin/cnmon:/usr/bin/cnmon \ | ||
| -v `pwd`:/workspace | ||
| -it --privileged \ | ||
| --name paddle_mlu_$USER \ | ||
| -w=/workspace | ||
| registry.baidubce.com/device/paddle-mlu:cntoolkit3.0.2-cnnl1.13.0 \ | ||
| /bin/bash | ||
|
|
||
| # 检查容器是否可以正确识别寒武纪 MLU 设备 | ||
| cnmon | ||
|
|
||
| # 预期得到以下结果(如下是一台 3 卡机器的信息): | ||
| Sat Oct 8 11:22:22 2022 | ||
| +------------------------------------------------------------------------------+ | ||
| | CNMON v4.20.11 | | ||
| +-------------------------------+----------------------+-----------------------+ | ||
| | Card VF Name Firmware | Inited Driver | Util Ecc-Error | | ||
| | Fan Temp Pwr:Usage/Cap | Memory-Usage | vMemory-Usage | | ||
| |===============================+======================+=======================| | ||
| | 0 / MLU370-X4 v1.1.6 | On v4.20.11 | 0% N/A | | ||
| | 0% 32C 30 W/ 150 W | 0 MiB/ 23308 MiB | 10240 MiB/1048576 MiB | | ||
| +-------------------------------+----------------------+-----------------------+ | ||
| | 1 / MLU370-X4 v1.1.6 | On v4.20.11 | 0% N/A | | ||
| | 0% 33C 25 W/ 150 W | 0 MiB/ 23308 MiB | 10240 MiB/1048576 MiB | | ||
| +-------------------------------+----------------------+-----------------------+ | ||
| | 2 / MLU370-X4 v1.1.6 | On v4.20.11 | 0% N/A | | ||
| | 0% 30C 26 W/ 150 W | 0 MiB/ 23308 MiB | 10240 MiB/1048576 MiB | | ||
| +-------------------------------+----------------------+-----------------------+ | ||
|
|
||
| +------------------------------------------------------------------------------+ | ||
| | Processes: | | ||
| | Card VF PID Command Line MLU Memory Usage | | ||
| |==============================================================================| | ||
| | No running processes found | | ||
| +------------------------------------------------------------------------------+ | ||
| ``` | ||
|
|
||
| ## 安装方式一:通过 wheel 包安装 | ||
|
|
||
| **注意**:当前仅提供 Python 3.7 的 wheel 安装包。 | ||
|
|
||
| **第一步**:下载 Python3.7 wheel 安装包 | ||
|
|
||
| ```bash | ||
| pip install https://paddle-device.bj.bcebos.com/mlu/paddlepaddle_mlu-2.4.0-cp37-cp37m-linux_x86_64.whl | ||
| ``` | ||
|
|
||
| **第二步**:验证安装包 | ||
|
|
||
| 安装完成之后,运行如下命令。如果出现 PaddlePaddle is installed successfully!,说明已经安装成功。 | ||
|
|
||
| ```bash | ||
| python -c "import paddle; paddle.utils.run_check()" | ||
| ``` | ||
|
|
||
| ## 安装方式二:通过源码编译安装 | ||
|
|
||
| **注意**:环境准备参见 [镜像准备](./paddle_install_cn.md#jingxiangzhunbei) | ||
|
|
||
| **第一步**:下载 Paddle 源码并编译,CMAKE 编译选项含义请参见 [编译选项表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#Compile) | ||
|
|
||
| ```bash | ||
| # 下载源码,默认 develop 分支 | ||
| git clone -b release/2.4 https://github.com/PaddlePaddle/Paddle.git | ||
| cd Paddle | ||
|
|
||
| # 创建编译目录 | ||
| mkdir build && cd build | ||
|
|
||
| # 执行 cmake | ||
| export PADDLE_VERSION=2.4.0 | ||
| cmake .. -DPY_VERSION=3.7 -DWITH_MLU=ON -DCMAKE_BUILD_TYPE=Release -DWITH_DISTRIBUTE=ON -DWITH_CNCL=ON | ||
|
|
||
| # 使用以下命令来编译 | ||
| make -j$(nproc) | ||
| ``` | ||
|
|
||
| **第二步**:安装与验证编译生成的 wheel 包 | ||
|
|
||
| 编译完成之后进入`Paddle/build/python/dist`目录即可找到编译生成的.whl 安装包,安装与验证命令如下: | ||
|
|
||
| ```bash | ||
| # 安装命令 | ||
| python -m pip install -U paddlepaddle_mlu-2.4.0-cp37-cp37m-linux_x86_64.whl | ||
|
|
||
| # 验证命令 | ||
| python -c "import paddle; paddle.utils.run_check()" | ||
| ``` | ||
|
|
||
| ## 如何卸载 | ||
|
|
||
| 请使用以下命令卸载 Paddle: | ||
|
|
||
| ```bash | ||
| pip uninstall paddlepaddle-mlu | ||
| ``` | ||
This file contains hidden or 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,63 @@ | ||
|
|
||
| # 飞桨框架寒武纪 MLU 版支持模型 | ||
|
|
||
| 目前 Paddle MLU 版基于寒武纪 MLU370 系列板卡支持以下模型的单机单卡/单机多卡的训练。 | ||
|
|
||
| ## 图像分类 | ||
|
|
||
| | 模型 | 领域 | 模型链接 | 编程范式 | 训练单机多卡支持 | 训练多机多卡支持 | 推理支持 | | ||
| | ----------------- | -------- | ------------------------------------------------------------ | ------------- | -------------- | -------------- | -------------- | | ||
| | ResNet50 | 图像分类 | [模型链接](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/ResNet/ResNet50.yaml) | 动态图 | 支持 | 支持 | 支持 | | ||
| | VGG16/19 | 图像分类 | [模型链接](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/VGG/VGG16.yaml) | 动态图 | 支持 | 支持 | 支持 | | ||
| | InceptionV4 | 图像分类 | [模型链接](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/Inception/InceptionV4.yaml) | 动态图 | 支持 | 支持 | 支持 | | ||
| | MobileNetV3 | 图像分类 | [模型链接](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x1_0.yaml) | 动态图 | 支持 | 支持 | 支持 | | ||
|
|
||
|
|
||
| ## 目标检测 | ||
|
|
||
| | 模型 | 领域 | 模型链接 | 编程范式 | 训练单机多卡支持 | 训练多机多卡支持 | 推理支持 | | ||
| | ----------------- | -------- | ------------------------------------------------------------ | ------------- | -------------- | -------------- | -------------- | | ||
| | YOLOv3 | 目标检测 | [模型链接](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/yolov3) | 动态图 | 支持 | 支持 | 支持 | | ||
| | PP-YOLO | 目标检测 | [模型链接](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/ppyolo) | 动态图 | 支持 | 支持 | 支持 | | ||
| | SSD | 目标检测 | [模型链接](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/ssd) | 动态图 | 支持 | 支持 | 支持 | | ||
| | Mask R-CNN | 目标检测 | [模型链接](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn) | 动态图 | 支持 | 支持 | 支持 | | ||
| | Mask R-CNN + FPN | 目标检测 | [模型链接](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn) | 动态图 | 支持 | 支持 | 支持 | | ||
|
|
||
|
|
||
| ## 图像分割 | ||
|
|
||
| | 模型 | 领域 | 模型链接 | 编程范式 | 训练单机多卡支持 | 训练多机多卡支持 | 推理支持 | | ||
| | ----------------- | -------- | ------------------------------------------------------------ | ------------- | -------------- | -------------- | -------------- | | ||
| | DeepLabV3+ | 图像分割 | [模型链接](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/configs/deeplabv3p) | 动态图 | 支持 | 不支持 | 支持 | | ||
| | U-Net | 图像分割 | [模型链接](https://github.com/PaddlePaddle/PaddleSeg/tree/develop/configs/unet) | 动态图 | 支持 | 不支持 | 支持 | | ||
|
|
||
| ## 自然语言处理 | ||
|
|
||
| | 模型 | 领域 | 模型链接 | 编程范式 | 训练单机多卡支持 | 训练多机多卡支持 | 推理支持 | | ||
| | ----------------- | -------- | ------------------------------------------------------------ | ------------- | -------------- | -------------- | -------------- | | ||
| | BERT | NLP | [模型链接](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/language_model/bert) | 动态图 | 支持 | 支持 | 支持 | | ||
| | Transformer | NLP | [模型链接](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/machine_translation/transformer) | 动态图 | 支持 | 支持 | 支持 | | ||
| | Bi-LSTM | NLP | [模型链接](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/text_classification/rnn) | 动态图 | 支持 | 支持 | 支持 | | ||
|
|
||
|
|
||
| ## 字符识别 | ||
|
|
||
| | 模型 | 领域 | 模型链接 | 编程范式 | 训练单机多卡支持 | 训练多机多卡支持 | 推理支持 | | ||
| | ----------------- | -------- | ------------------------------------------------------------ | ------------- | -------------- | -------------- | -------------- | | ||
| | OCR-DB | 文本检测 | [模型链接](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/detection.md) | 动态图 | 支持 | 支持 | 支持 | | ||
| | CRNN-CTC | 文本识别 | [模型链接](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/recognition.md) | 动态图 | 支持 | 支持 | 支持 | | ||
| | OCR-Clas | 角度分类 | [模型链接](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/angle_class.md) | 动态图 | 支持 | 支持 | 支持 | | ||
| | OCR-E2E | 字符识别 | [模型链接](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/pgnet.md) | 动态图 | 支持 | 支持 | 支持 | | ||
|
|
||
|
|
||
| ## 模型套件 | ||
|
|
||
| 模型放置在飞桨模型套件中,各领域套件是 github.com/PaddlePaddle 下的独立 repo,git clone 下载即可获取所需的模型文件: | ||
|
|
||
| | 领域 | 套件名称 | 分支/版本 | | ||
| | ----------- | --------------- | ---------------- | | ||
| | 图像分类 | PaddleClas | develop | | ||
| | 目标检测 | PaddleDetection | develop | | ||
| | 图像分割 | PaddleSeg | develop | | ||
| | 自然语言处理 | PaddleNLP | develop | | ||
| | 字符识别 | PaddleOCR | dygraph | |
This file contains hidden or 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,31 @@ | ||
| # 飞桨框架 MLU 版训练示例 | ||
|
|
||
| 使用寒武纪 MLU370 进行训练与使用 Intel CPU/Nvidia GPU 训练相同,当前 Paddle MLU 版本完全兼容 Paddle CUDA 版本的 API,直接使用原有的 GPU 训练命令和参数即可。 | ||
|
|
||
| #### ResNet50 训练示例 | ||
|
|
||
| **第一步**:安装 MLU 支持的 Paddlepaddle | ||
|
|
||
| Paddle MLU 版的 Python 预测库请参考 [飞桨框架 MLU 版安装说明](./paddle_install_cn.html) 进行安装或编译。 | ||
|
|
||
|
|
||
| **第二步**:下载 ResNet50 代码,并准备 ImageNet1k 数据集 | ||
|
|
||
| ```bash | ||
| cd path_to_clone_PaddleClas | ||
| git clone https://github.com/PaddlePaddle/PaddleClas.git | ||
| ``` | ||
| 也可以访问 PaddleClas 的 [GitHub Repo](https://github.com/PaddlePaddle/PaddleClas) 直接下载源码。请根据[数据说明](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.4/docs/zh_CN/data_preparation/classification_dataset.md)文档准备 ImageNet1k 数据集。 | ||
|
|
||
| **第三步**:运行训练 | ||
|
|
||
| 使用飞桨 PaddleXXX 套件运行 MLU 可以通过设置 Global.device 参数为 mlu 来指定设备,其他模型也可以参考该使用方式 | ||
|
|
||
| ```bash | ||
| export MLU_VISIBLE_DEVICES=0,1,2,3 | ||
|
|
||
| cd PaddleClas/ | ||
| python3.7 -m paddle.distributed.launch --mlus="0,1,2,3" tools/train.py \ | ||
| -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml \ | ||
| -o Global.device=mlu | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.