1 Star 0 Fork 1

ApulisPlatform / model-gallery

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Model-Gallery

Model-Gallery is a developer community built on the basis of aiarts. It provides the sharing of models, algorithms, datasets and other contents.

English | 简体中文

镜像管理

测试环境

mindspore训练使用训练卡的逻辑id,tensorflow使用物理id

裸机测试

裸机

  • 裸机安装环境tensorflow相关依赖包(更新驱动之后,需要重新安装相关依赖包)
    • arm的tensorflow包到【 \\192.168.2.71\public\AIarts算法部署\算法镜像 】寻找tensorflow-1.15.0-cp37-cp37m-linux_aarch64.whl
    • amd的tensorflow包使用pip install tensorflow-cpu==1.15.0安装
  python3 -m pip config set global.index-url http://mirrors.aliyun.com/pypi/simple && python3 -m pip config set install.trusted-host mirrors.aliyun.com && python3 -m pip install --upgrade pip \
    && python3 -m pip install /home/HwHiAiUser/Ascend/tfplugin/latest/tfplugin/bin/npu_bridge-1.15.0-py3-none-any.whl \
    /home/HwHiAiUser/Ascend/nnae/latest/fwkacllib/lib64/hccl-0.1.0-py3-none-any.whl /home/HwHiAiUser/Ascend/nnae/latest/fwkacllib/lib64/te-0.4.0-py3-none-any.whl  \
    /home/HwHiAiUser/Ascend/nnae/latest/fwkacllib/lib64/topi-0.4.0-py3-none-any.whl sympy --force-reinstall
  • 克隆model-gallery
    cd ~
    git config --global credential.helper store
    git clone -b v1.0 --depth 1 https://apulis-gitlab.apulis.cn/apulis/model-gallery.git
    cd ~/model-gallery/models/npu/testcase/single
    bash test_single.sh

    cd ~/model-gallery/models/npu/testcase/distributed
    bash test_distributed.sh

镜像

  • 启动镜像(测试代码已经打入镜像中)
  docker run -it  --privileged --rm tf-torch-ms-nni-npu:1.15.0-1.5.0-1.1.1-1.9-arm /bin/bash 
  • 单算子测试(判断驱动单算子是否正常)

如果训练卡的位置不是从0开始,通过testcase验证tf环境时,不能直接执行test_single.sh,可使用python tf_case.py验证

    cd /home/testcase/single
    bash test_single.sh
  • 单机多卡训练测试(判断驱动是否正常)
    cd /home/testcase/distributed
    bash test_distributed.sh

平台测试

单机多卡测试(判断平台环境变量是否正常)

代码开发

  • 在jupyterlab中执行测试脚本
```shell script
    cd /tmp
    bash /data/model-gallery/models/testcase/npu/distributed/test_distributed.sh 
    bash /data/model-gallery/models/testcase/npu/single/test_single.sh 


    cd ~
    git config --global credential.helper store
    git clone -b v1.0 --depth 1 https://apulis-gitlab.apulis.cn/apulis/model-gallery.git
    cd ~/code/model-gallery/models/npu/testcase/single
    bash  test_single.sh
```
  • 在jupyterlab中直接执行示例代码
```bash
cd ~/code/model-gallery-master/models/npu/tensorflow/resnet
bash train.sh --data_path /data/dataset/storage/tiny_imagenet/ --train_steps 1000 --eval False --iterations_per_loop 1 --eval False --output_path ./
```

模型训练(经典模式)

  • 启动文件 model-gallery/models/npu/testcase/distributed/test_distributed.sh

  • 输出路径 work_dirs/testcase

  • 数据集 mnist("/data/dataset/storage/mnist/") 可任意数据集

模型训练(命令行模式)命令行启动(v1.5版本才会有):

     bash ~/model-gallery/models/npu/testcase/distributed/test_distributed.sh

多机多卡测试 (判断worker、master节点是否正常)

代码开发方式

  • NPU 在每个jupyter中的每个worker都执行启动脚本命令
    ssh worker-0 
    cd ~/code/model-gallery/models/npu/testcase/distributed/
    bash test_distributed.sh

    ssh worker-1 
    cd ~/model-gallery/models/npu/testcase/distributed/
    bash test_distributed.sh
  • GPU 在代码开发启动horovod引擎后(直接在master(ps-0)的jupytermaster(ps-0)中执行以下脚本)
#    tensorflow 如果集群机器没有ib卡则去掉 ib0 参数
    horovodrun  --network-interface ib0 -np 4 -hostfile /job/hostfile python /examples/tensorflow2_keras_mnist.py
#    4表示2机4卡
#    pytorch
    horovodrun  --network-interface ib0 -np 2 -hostfile /job/hostfile python /examples/pytorch_mnist.py
#    2表示1机2卡
#    mindspore
    cd ~/code/resnet_mindspore && bash run.sh
#    mindspore要求不能分布在同一个节点,训练框架的bug

模型训练方式

  • NPU Worker 节点命令填入(使用预置训练参数)
    bash ~/model-gallery/models/npu/testcase/distributed/test_distributed.sh

Image text

  • GPU 创建多机训练(需在master节点命令中填写)
  • docker pull harbor.apulis.cn:8443/algorithm/apulistech/horovod:0.20.0-tf2.3.0-torch1.6.0-mxnet1.6.0.post0-py3.7-cuda10.1-nni2.4
#    tensorflow
    horovodrun  --network-interface ib0 -np 4 -hostfile /job/hostfile python /examples/tensorflow2_keras_mnist.py

#    pytorch
    horovodrun  --network-interface ib0 -np 2 -hostfile /job/hostfile python /examples/pytorch_mnist.py

#    mindspore
    cd ~/code/resnet_mindspore && bash run.sh

预置模型管理

部署预置模型

  • 进入部署服务器AIArts平台对应/data的路径中,克隆仓库(目的是为了平台能找到预置模型的启动文件:/data/model-gallery/models/npu/ssd_mindspore/train.sh)
    #如:代码路径/data/model-gallery/models 对应 /mnt/local/pvc/aiplatform-model-data/model-gallery/models
    # /data/model-gallery/models/gpu/lenet_mxnet/train.py

    #数据集路径/data/dataset/storage 对应 /mnt/local/pvc/aiplatform-model-data/dataset/storage
    # /data/dataset/storage/coco/2017/mindrecord
    cd /mnt/local/pvc/aiplatform-model-data/
    git clone -b v1.0 --depth 1 https://apulis-gitlab.apulis.cn/apulis/model-gallery.git
  • 从存储服务器中下载数据集,地址 【\\192.168.2.71\public\AIarts算法部署\dataset】 文件夹,并放至【/mnt/local/pvc/aiplatform-model-data/】下 (目的是为了平台能找到预置模型的数据集文件 【/data/dataset/storage/coco】)

  • 运行deploy.sh

    cd model-gallery
    #postgresql
    bash deploy.sh
    
    #mysql
    bash deploy-mysql.sh

算法开发

平台算法预置

  • 代码开发并测试完成

  • 在代码目录中新建gallery_config.json,编写模型信息(详见下页)

  • 将数据集上传至存储服务器 地址 【\\192.168.2.71\public\AIarts算法部署\model_data\dataset】

  • 预训练模型文件存放路径【\\192.168.2.71\public\AIarts算法部署\dataset\storage\pretrained_models】

  • 更新代码至远程仓库

    git pull
    git add . 
    git commit -m "xxx"
    git push
  • 进入atlas集群启动多卡代码开发环境
    cd ~
    git config --global credential.helper store
    git clone -b v1.0 --depth 1 https://apulis-gitlab.apulis.cn/apulis/model-gallery.git
    cd ~/model-gallery
#    如git pull有冲突
    git reset --hard    
  • 使用tensorflow/mindspore训练模板 ~/model-gallery/models/npu/mindspore_train.sh
    cp ~/model-gallery/models/npu/mindspore_train.sh ~/model-gallery/models/npu/{your_model}/train.sh
  • 替换train.sh中的启动文件为相应的启动文件(非必须)STARTFILE="train.py "

  • 需要注意将py文件中args = parse_args() 解析修改为 args, _ = parser.parse_known_args()

  • 相关数据集放在/data/dataset/storage/目录下

    cp -r mnist /data/dataset/storage/
  • 启动训练脚本,查看是否成功
    bash train.sh

算法配置字段说明

  • gallery_config.json
{
    "created_at": "2020-10-28 03:35:29",
    "updated_at": "2020-10-28 03:35:29",
    "version": "0.0.1",
    "status": "normal",
    //   默认为normal

    "platform": "AIArts",
    //   目前可选值 AIArts Avisualis Segmentation...

    "models": [
        {
            "name": "LeNet_TensorFlow_GPU_scratch",
            "framework":"tensorflow",
            "model_name":"lenet",
            "description": "lenet-mxnet",
            "size": "20165368",
            //   默认单位为Bytes,18M

            "type": "CV/Classfication",
            //   目前可选值 CV/ObjectDetection NLP/BERT CV/Segmentation...

            "dataset": {
                "name": "mnist",
                "path": "mnist",
                //   数据集目录名
                //   存储服务器真实存放路径 /data/dataset/storage/mnist
                //   dataset path传入启动文件的命令 python train.py --dataset mnist
                "size":"123123",
                //数据集大小单位bytes
                "format": "TFRecord"
            },
            "params": {
                "batch_size": "50",
                "epochs":"10",
                "lr":"0.1",
            },
            //   params传入启动文件的命令为 python train.py --batch_size 50 --optimizer sgd
            //   params的值都需要使用双引号

            "engine": "apulistech/mxnet:2.0.0-gpu-py3",

            //apulistech/tensorflow-nni-npu:1.15.0-20.2-arm
            //apulistech/mindspore-nni-npu:1.1.1-20.2-arm

            "precision": "-",
          //   模型评估精度

            "output_path": "work_dirs/lenet_mxnet",
            //   work_dirs/{模型名称}
            //   相对路径 /home/admin/work_dirs/lenet_mxnet
            //   output_path传入启动文件的命令 python train.py --output_path work_dirs/lenet_mxnet

            "startup_file": "train.py",
            //   训练启动文件命名都为 train.py / train.sh 或者 main/train.py
            //   评估启动文件命名都为 eval.py / eval.py  或者 main/eval.py


            "device_type": "nvidia_gpu_amd64",
            //   目前可选值 nvidia_gpu_amd64 huawei_npu_amd64 huawei_npu_arm64 空

            "device_num": 1
            //   是否支持多卡、多机训练
            //   目前可选值 0 1 ...
        }
    ]
}
  • 所有名称、路径名、配置参数名称、统一用下划线表示间隔

  • 模型名称统一为 {模型名称}{框架名称}{版本号}{计算设备}_{是否从零开始训练} 如: LeNet_TensorFlow_GPU_scratch

  • 数据集和模型文件需要放在存储服务器上

  • 利用jetkins,使用dockerfile通过pipeline生成image,提供给部署人员save后进行部署。镜像管理中,从公用harbor中导入。

模型管理框架

Image text

The MIT License (MIT) Copyright © 2021 <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Model-Gallery is a developer community built on the basis of aiarts. It provides the sharing of models, algorithms, datasets and other contents. 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/apulisplatform/model-gallery.git
git@gitee.com:apulisplatform/model-gallery.git
apulisplatform
model-gallery
model-gallery
v1.6.0

搜索帮助