Commit ff4871ee authored by dcuai's avatar dcuai
Browse files

Update README.md

parent d4792f44
...@@ -16,9 +16,9 @@ Vision Transformer先将图像用卷积进行分块以降低计算量,再对 ...@@ -16,9 +16,9 @@ Vision Transformer先将图像用卷积进行分块以降低计算量,再对
## 环境配置 ## 环境配置
### Docker(方法一) ### Docker(方法一)
```plaintext ```plaintext
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10.1-py37-latest docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10
# <your IMAGE ID>用以上拉取的docker的镜像ID替换 # <your IMAGE ID>用以上拉取的docker的镜像ID替换
docker run --shm-size 10g --network=host --name=nit-pytorch --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/vit-pytorch:/home/vit-pytorch -it <your IMAGE ID> bash docker run --shm-size 10g --network=host --name=nit-pytorch --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /opt/hyhal:/opt/hyhal:ro -v $PWD/vit-pytorch:/home/vit-pytorch -it <your IMAGE ID> bash
pip install -r requirements.txt pip install -r requirements.txt
``` ```
...@@ -26,7 +26,7 @@ pip install -r requirements.txt ...@@ -26,7 +26,7 @@ pip install -r requirements.txt
```plaintext ```plaintext
cd ViT-PyTorch/docker cd ViT-PyTorch/docker
docker build --no-cache -t ViT-PyTorch:latest . docker build --no-cache -t ViT-PyTorch:latest .
docker run --rm --shm-size 10g --network=host --name=megatron --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/../../ViT-PyTorch:/home/ViT-PyTorch -it megatron bash docker run --rm --shm-size 10g --network=host --name=megatron --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /opt/hyhal:/opt/hyhal:ro -v $PWD/../../ViT-PyTorch:/home/ViT-PyTorch -it megatron bash
# 若遇到Dockerfile启动的方式安装环境需要长时间等待,可注释掉里面的pip安装,启动容器后再安装python库:pip install -r requirements.txt # 若遇到Dockerfile启动的方式安装环境需要长时间等待,可注释掉里面的pip安装,启动容器后再安装python库:pip install -r requirements.txt
``` ```
...@@ -49,6 +49,7 @@ pip install -r requirements.txt ...@@ -49,6 +49,7 @@ pip install -r requirements.txt
## 数据集 ## 数据集
[cifar10](http://113.200.138.88:18080/aidatasets/project-dependency/cifar) [cifar10](http://113.200.138.88:18080/aidatasets/project-dependency/cifar)
默认会自动下载数据集到data文件夹,可将cifar-10-python.tar.gz放置在data文件夹下
``` ```
├── batches.meta ├── batches.meta
...@@ -70,17 +71,17 @@ wget https://storage.googleapis.com/vit_models/imagenet21k/ViT-B_16.npz ...@@ -70,17 +71,17 @@ wget https://storage.googleapis.com/vit_models/imagenet21k/ViT-B_16.npz
### 单机单卡 ### 单机单卡
``` ```
export HIP_VISIBLE_DEVICES=0 export HIP_VISIBLE_DEVICES=0
python3 -m torch.distributed.launch --nproc_per_node=1 train.py --name cifar10-100_500 --dataset cifar10 --model_type ViT-B_16 --pretrained_dir checkpoint/ViT-B_16.npz --train_batch_size 64 --num_steps 500 python3 -m torch.distributed.launch --nproc_per_node=1 --use-env train.py --name cifar10-100_500 --dataset cifar10 --model_type ViT-B_16 --pretrained_dir checkpoint/ViT-B_16.npz --train_batch_size 64 --num_steps 500
``` ```
### 单机多卡 ### 单机多卡
``` ```
python3 -m torch.distributed.launch --nproc_per_node=8 train.py --name cifar10-100_500 --dataset cifar10 --model_type ViT-B_16 --pretrained_dir checkpoint/ViT-B_16.npz --train_batch_size 64 --num_steps 500 python3 -m torch.distributed.launch --nproc_per_node=8 --use-env train.py --name cifar10-100_500 --dataset cifar10 --model_type ViT-B_16 --pretrained_dir checkpoint/ViT-B_16.npz --train_batch_size 64 --num_steps 500
``` ```
## result ## result
![1695381570003](image/README/1695381570003.png) ![1695381570003](image/README/1695381570003.png)
## 精度 ### 精度
测试数据使用的是cifar10,使用的加速卡是DCU Z100L。 测试数据使用的是cifar10,使用的加速卡是DCU Z100L。
| 卡数 | 精度 | | 卡数 | 精度 |
...@@ -92,10 +93,10 @@ python3 -m torch.distributed.launch --nproc_per_node=8 train.py --name cifar10-1 ...@@ -92,10 +93,10 @@ python3 -m torch.distributed.launch --nproc_per_node=8 train.py --name cifar10-1
图像分类 图像分类
### 热点行业 ### 热点行业
制造能源交通网安 制造,能源,交通,网安
### 源码仓库及问题反馈 ### 源码仓库及问题反馈
- https://developer.hpccube.com/codes/modelzoo/vit-pytorch - https://developer.hpccube.com/codes/modelzoo/vit_pytorch
### 参考 ### 参考资料
- https://github.com/jeonsworld/ViT-pytorch - https://github.com/jeonsworld/ViT-pytorch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment