Commit b47405b9 authored by hepj's avatar hepj
Browse files

兼容tf2.13

parent 605b67a3
...@@ -80,6 +80,8 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.13.1-ubuntu20.0 ...@@ -80,6 +80,8 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.13.1-ubuntu20.0
docker run -dit --network=host --name=bert_tensorflow --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/tensorflow:2.13.1-ubuntu20.04-dtk24.04.1-py3.10 docker run -dit --network=host --name=bert_tensorflow --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/tensorflow:2.13.1-ubuntu20.04-dtk24.04.1-py3.10
docker exec -it bert_tensorflow /bin/bash docker exec -it bert_tensorflow /bin/bash
pip install -r requirements.txt pip install -r requirements.txt
pip install tf-models-official==2.4.0 tensorflow_addons==0.16.1 tensorflow_hub==0.16.1 typeguard==4.3.0 typing_extensions==4.12.2 --no-deps
``` ```
### Dockerfile(方式二) ### Dockerfile(方式二)
...@@ -89,6 +91,8 @@ docker build -t bert:latest . ...@@ -89,6 +91,8 @@ docker build -t bert:latest .
docker run -dit --network=host --name=bert_tensorflow --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_tensorflow --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 exec -it bert_tensorflow /bin/bash docker exec -it bert_tensorflow /bin/bash
pip install -r requirements.txt pip install -r requirements.txt
pip install tf-models-official==2.4.0 tensorflow_addons==0.16.1 tensorflow_hub==0.16.1 typeguard==4.3.0 typing_extensions==4.12.2 --no-deps
``` ```
### Conda(方式三) ### Conda(方式三)
...@@ -96,6 +100,8 @@ pip install -r requirements.txt ...@@ -96,6 +100,8 @@ pip install -r requirements.txt
``` ```
conda create -n bert_tensorflow python=3.10 conda create -n bert_tensorflow python=3.10
pip install -r requirements.txt pip install -r requirements.txt
pip install tf-models-official==2.4.0 tensorflow_addons==0.16.1 tensorflow_hub==0.16.1 typeguard==4.3.0 typing_extensions==4.12.2 --no-deps
``` ```
安装过程可能顶掉DCU版本的tensorflow,可以到[开发者社区](https://developer.hpccube.com/tool/)下载DCU版本对应包 安装过程可能顶掉DCU版本的tensorflow,可以到[开发者社区](https://developer.hpccube.com/tool/)下载DCU版本对应包
...@@ -118,6 +124,34 @@ return type(a_type) is typing.ClassVar ...@@ -118,6 +124,34 @@ return type(a_type) is typing.ClassVar
## 训练 ## 训练
### tf2.13版本兼容性改动
```
/usr/local/lib/python3.10/site-packages/keras/src/optimizers/optimizer.py 1234
改为:
if (self.weight_decay is None) or self.weight_decay=="AdamWeightDecay":
/usr/local/lib/python3.10/site-packages/official/modeling/performance.py 53
改为:
tf.keras.mixed_precision.set_global_policy('float32')
/usr/local/lib/python3.10/site-packages/official/nlp/keras_nlp/layers/transformer_encoder_block.py 167
改为:
tf.keras.mixed_precision.global_policy()
/usr/local/lib/python3.10/site-packages/official/nlp/modeling/networks/classification.py 70
改为:
policy = tf.keras.mixed_precision.global_policy()
/usr/local/lib/python3.10/site-packages/official/nlp/bert/model_training_utils.py 346
改为:
tf.keras.mixed_precision.LossScaleOptimizer):
```
### 数据转化-MNLI ### 数据转化-MNLI
TF2.0版本读取数据需要转化为tf_record格式 TF2.0版本读取数据需要转化为tf_record格式
......
...@@ -7,10 +7,9 @@ pandas>=0.22.0 ...@@ -7,10 +7,9 @@ pandas>=0.22.0
psutil>=5.4.3 psutil>=5.4.3
py-cpuinfo>=3.3.0 py-cpuinfo>=3.3.0
scipy>=0.19.1 scipy>=0.19.1
tensorflow-hub>=0.6.0
tensorflow-model-optimization>=0.2.1 tensorflow-model-optimization>=0.2.1
tensorflow-datasets tensorflow-datasets==2.1.0
tensorflow-addons # tensorflow-addons==0.14
gin-config gin-config
tf_slim>=1.1.0 tf_slim>=1.1.0
sentencepiece sentencepiece
...@@ -18,5 +17,4 @@ Cython ...@@ -18,5 +17,4 @@ Cython
matplotlib matplotlib
opencv-python-headless opencv-python-headless
pyyaml pyyaml
Pillow Pillow
tf-models-official==2.4.0 \ No newline at end of file
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