Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
BERT_pytorch
Commits
def08010
Commit
def08010
authored
Aug 28, 2024
by
shantf
Browse files
update README.md and Dockerfile
parent
cbfb5481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
27 deletions
+34
-27
Dockerfile
Dockerfile
+2
-2
README.md
README.md
+32
-25
No files found.
Dockerfile
View file @
def08010
FROM
image.sourcefind.cn:5000/dcu/admin/base/pytorch:
1
.1
0
.0-
centos7.6-dtk-22.10.1-py37-latest
FROM
image.sourcefind.cn:5000/dcu/admin/base/pytorch:
2
.1.0-
ubuntu20.04-dtk24.04.1-py3.10
COPY
requirements.txt requirements.txt
COPY
requirements.txt requirements.txt
RUN
source
/opt/dtk-2
2.10
.1/env.sh
RUN
source
/opt/dtk-2
4.04
.1/env.sh
RUN
cp
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
RUN
cp
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
ENV
LANG C.UTF-8
ENV
LANG C.UTF-8
RUN
pip
install
-r
requirements.txt
-i
http://mirrors.aliyun.com/pypi/simple/
--trusted-host
mirrors.aliyun.com
RUN
pip
install
-r
requirements.txt
-i
http://mirrors.aliyun.com/pypi/simple/
--trusted-host
mirrors.aliyun.com
...
...
README.md
View file @
def08010
...
@@ -30,41 +30,42 @@ BERT并没有采用整个的Transformer结构(Encoder+Decoder),仅仅使
...
@@ -30,41 +30,42 @@ BERT并没有采用整个的Transformer结构(Encoder+Decoder),仅仅使
### Docker(方式一)
### Docker(方式一)
```
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:
1
.1
0
.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
进入docker安装没有的依赖
进入docker安装没有的依赖
docker run -dit --network=host --name=bert-pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/pytorch:
1
.1
0
.0-
centos7.6-dtk-22.10.1-py37-latest
docker run -dit --network=host --name=bert-pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G
-v /opt/hyhal:/opt/hyhal:ro
--group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/pytorch:
2
.1.0-
ubuntu20.04-dtk24.04.1-py3.10
docker exec -it
llama-tencentpretrain
/bin/bash
docker exec -it
bert-pytorch
/bin/bash
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
#tensorflow安装包参考conda方式下载地址
#tensorflow安装包参考conda方式下载地址,tensorflow安装包在光合社区中下载
pip install tensorflow-2.7.0+git67f0ade9.dtk2210-cp37-cp37m-manylinux2014_x86_64.whl
wget https://cancon.hpccube.com:65024/directlink/4/tensorflow/DAS1.1/tensorflow-2.13.1+das1.1.git56b06c8.abi1.dtk2404-cp310-cp310-manylinux_2_31_x86_64.whl
pip install tensorflow-2.13.1+das1.1.git56b06c8.abi1.dtk2404-cp310-cp310-manylinux_2_31_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
```
```
### Dockerfile(方式二)
### Dockerfile(方式二)
```
```
docker build -t bert:latest .
docker build -t bert:latest .
docker run -dit --network=host --name=bert-pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 bert:latest
docker run -dit --network=host --name=bert-pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G
-v /opt/hyhal:/opt/hyhal:ro
--group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 bert:latest
docker exec -it bert-pytorch /bin/bash
docker exec -it bert-pytorch /bin/bash
#tensorflow安装包参考conda方式下载地址
#tensorflow安装包参考conda方式下载地址
pip install tensorflow-2.
7.0+git67f0ade9
.dtk2
210
-cp3
7
-cp3
7m
-manylinux
2014
_x86_64.whl
pip install tensorflow-2.
13.1+das1.1.git56b06c8.abi1
.dtk2
404
-cp3
10
-cp3
10
-manylinux
_2_31
_x86_64.whl
-i https://pypi.tuna.tsinghua.edu.cn/simple
```
```
### Conda(方式三)
### Conda(方式三)
```
```
#创建虚拟环境
#创建虚拟环境
conda create -n bert-pytorch python=3.
7
conda create -n bert-pytorch python=3.
10
```
```
关于本项目DCU显卡所需的工具包、深度学习库等均可从
[
光合
](
https://developer.hpccube.com/tool/
)
开发者社区下载安装。
关于本项目DCU显卡所需的工具包、深度学习库等均可从
[
光合
](
https://developer.hpccube.com/tool/
)
开发者社区下载安装。
[
apex
](
https://cancon.hpccube.com:65024/directlink/4/apex/
dtk22
.1
0
/apex-
0
.1
+
git
db7007a.dtk221
0-cp3
7
-cp3
7m
-manylinux
2014
_x86_64.whl
)
[
apex
](
https://cancon.hpccube.com:65024/directlink/4/apex/
DAS1
.1/apex-
1.1.0+das1
.1
.
git
f477a3a.abi1.dtk2404.torch2.1.
0-cp3
10
-cp3
10
-manylinux
_2_31
_x86_64.whl
)
[
pytorch1.
1
0
](
https://cancon.hpccube.com:65024/directlink/4/pytorch/
dtk22
.1
0
/torch-
1
.1
0
.0
a0+git2040069
.dtk2
210
-cp3
7
-cp3
7m
-manylinux
2014
_x86_64.whl
)
[
pytorch
2.
1.0
](
https://cancon.hpccube.com:65024/directlink/4/pytorch/
DAS1
.1/torch-
2
.1.0
+das1.1.git3ac1bdd.abi1
.dtk2
404
-cp3
10
-cp3
10
-manylinux
_2_31
_x86_64.whl
)
[
tensorflow2.
7
](
https://cancon.hpccube.com:65024/directlink/4/tensorflow/
dtk22
.1
0
/tensorflow-2.
7.0+git67f0ade9
.dtk2
210
-cp3
7
-cp3
7m
-manylinux
2014
_x86_64.whl
)
[
tensorflow2.
13.1
](
https://cancon.hpccube.com:65024/directlink/4/tensorflow/
DAS1
.1/tensorflow-2.
13.1+das1.1.git56b06c8.abi1
.dtk2
404
-cp3
10
-cp3
10
-manylinux
_2_31
_x86_64.whl
)
[
DTK2
2.10
](
https://cancon.hpccube.com:65024/directlink/1/DTK-2
2.10.1/CentOS7.6/DTK-22.10.1-CentOS7.6
-x86_64.tar.gz
)
[
DTK2
4.04.1
](
https://cancon.hpccube.com:65024/directlink/1/DTK-2
4.04.1/Ubuntu20.04.1/DTK-24.04.1-Ubuntu20.04.1
-x86_64.tar.gz
)
其它依赖库参照requirements.txt安装:
其它依赖库参照requirements.txt安装:
...
@@ -171,21 +172,27 @@ python3 tf_to_torch/convert_tf_checkpoint.py --tf_checkpoint uncased_L-24_H-1024
...
@@ -171,21 +172,27 @@ python3 tf_to_torch/convert_tf_checkpoint.py --tf_checkpoint uncased_L-24_H-1024
```
```
#单卡
#单卡
./
bert_squad.sh #单精度 (按自己路径对single_squad.sh里APP设置进行修改)
bash
bert_squad.sh #单精度 (按自己路径对single_squad.sh里APP设置进行修改)
./
bert_squad_fp16.sh #半精度 (按自己路径对single_squad_fp16.sh里APP设置进行修改)
bash
bert_squad_fp16.sh #半精度 (按自己路径对single_squad_fp16.sh里APP设置进行修改)
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
tips:
1、如提示类似bert_squad.sh等shell脚本不能执行,可执行如下命令:
bash bert_squad.sh
2、倘若运行提示:遇到非法的节点名字K100_AI等,可以使用如下方法改正,在容器里面操作
sudo hostname xxx 改正不包含下划线的名字,比如k21,然后退出容器,重新进入即可。
```
```
```
```
#多卡
#多卡
./
bert_squad4.sh #单精度 (按自己路径对single_squad4.sh里APP设置进行修改)
bash
bert_squad4.sh #单精度 (按自己路径对single_squad4.sh里APP设置进行修改)
./
bert_squad4_fp16.sh #半精度 (按自己路径对single_squad4_fp16.sh里APP设置进行修改)
bash
bert_squad4_fp16.sh #半精度 (按自己路径对single_squad4_fp16.sh里APP设置进行修改)
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
```
```
```
```
#多机多卡
#多机多卡
#进入节点1,根据环境修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
#进入节点1,根据环境
编写
修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
cd 2node-run-squad
cd 2node-run-squad
sh run_bert_squad_4dcu.sh (需要fp16可以在相应single文件APP中增加 --fp16 与 --amp参数)
sh run_bert_squad_4dcu.sh (需要fp16可以在相应single文件APP中增加 --fp16 与 --amp参数)
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
--init_checkpoint使用model.ckpt-28252.pt或者自己转换好的model.ckpt.pt
...
@@ -222,11 +229,11 @@ sh run_bert_squad_4dcu.sh (需要fp16可以在相应single文件APP中增加 -
...
@@ -222,11 +229,11 @@ sh run_bert_squad_4dcu.sh (需要fp16可以在相应single文件APP中增加 -
```
```
#单卡
#单卡
./
bert_pre1.sh #单精度 (按自己路径对single_pre1_1.sh里APP设置进行修改)
bash
bert_pre1.sh #单精度 (按自己路径对single_pre1_1.sh里APP设置进行修改)
./
bert_pre1_fp16.sh #半精度 (按自己路径对single_pre1_1_fp16.sh里APP设置进行修改)
bash
bert_pre1_fp16.sh #半精度 (按自己路径对single_pre1_1_fp16.sh里APP设置进行修改)
#多卡
#多卡
./
bert_pre1_4.sh #单精度 (按自己路径对single_pre1_4.sh里APP设置进行修改)
bash
bert_pre1_4.sh #单精度 (按自己路径对single_pre1_4.sh里APP设置进行修改)
./
bert_pre1_4_fp16.sh #半精度 (按自己路径对single_pre1_4_fp16.sh里APP设置进行修改)
bash
bert_pre1_4_fp16.sh #半精度 (按自己路径对single_pre1_4_fp16.sh里APP设置进行修改)
#多机多卡
#多机多卡
#进入节点1,根据环境修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
#进入节点1,根据环境修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
...
@@ -238,11 +245,11 @@ sh run_bert_pre1_4dcu.sh (需要fp16可以在相应single文件APP中增加 --
...
@@ -238,11 +245,11 @@ sh run_bert_pre1_4dcu.sh (需要fp16可以在相应single文件APP中增加 --
```
```
#单卡
#单卡
./
bert_pre2.sh #单精度 (按自己路径对single_pre2_1.sh里APP设置进行修改)
bash
bert_pre2.sh #单精度 (按自己路径对single_pre2_1.sh里APP设置进行修改)
./
bert_pre2_fp16.sh #半精度 (按自己路径对single_pre2_1_fp16.sh里APP设置进行修改)
bash
bert_pre2_fp16.sh #半精度 (按自己路径对single_pre2_1_fp16.sh里APP设置进行修改)
#多卡
#多卡
./
bert_pre2_4.sh #单精度 (按自己路径对single_pre2_4.sh里APP设置进行修改)
bash
bert_pre2_4.sh #单精度 (按自己路径对single_pre2_4.sh里APP设置进行修改)
./
bert_pre2_4_fp16.sh #半精度 (按自己路径对single_pre2_4_fp16.sh里APP设置进行修改)
bash
bert_pre2_4_fp16.sh #半精度 (按自己路径对single_pre2_4_fp16.sh里APP设置进行修改)
#多机多卡
#多机多卡
#进入节点1,根据环境修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
#进入节点1,根据环境修改hostfile,保证两节点文件路径一致,配置相同,按需修改hostfile改为ip a命令后对应节点ip的网卡名,numa可以根据当前节点拓扑更改绑定
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment