From 8c0d0eb42712fa42d5a25a2f595cdb05fcc75fa6 Mon Sep 17 00:00:00 2001 From: zR <2448370773@qq.com> Date: Fri, 9 Aug 2024 13:46:06 +0800 Subject: [PATCH] update multi gpus finetune script --- README.md | 4 ++++ README_zh.md | 2 +- sat/README.md | 11 ++++++++--- sat/README_zh.md | 7 +++++-- sat/data_video.py | 2 +- sat/finetune_multi_gpus.sh | 10 ++++++++++ sat/{finetune.sh => finetune_single_gpu.sh} | 0 7 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 sat/finetune_multi_gpus.sh rename sat/{finetune.sh => finetune_single_gpu.sh} (100%) diff --git a/README.md b/README.md index b85f813..0801638 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ the quality of the generated video. ### SAT +**Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.** + Follow instructions in [sat_demo](sat/README.md): Contains the inference code and fine-tuning code of SAT weights. It is recommended to improve based on the CogVideoX model structure. Innovative researchers use this code to better perform rapid stacking and development. @@ -67,6 +69,8 @@ rapid stacking and development. ### Diffusers +**Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.** + ``` pip install -r requirements.txt ``` diff --git a/README_zh.md b/README_zh.md index bf97f15..5bd0e7e 100644 --- a/README_zh.md +++ b/README_zh.md @@ -93,7 +93,7 @@ pip install -r requirements.txt CogVideoX是 [清影](https://chatglm.cn/video?fr=osm_cogvideox) 同源的开源版本视频生成模型。 -下表战展示目前我们提供的视频生成模型列表,以及相关基础信息: +下表展示目前我们提供的视频生成模型列表,以及相关基础信息: | 模型名 | CogVideoX-2B | |---------------------|-------------------------------------------------------------------------------------------------------------------------------| diff --git a/sat/README.md b/sat/README.md index 7325be0..f55445e 100644 --- a/sat/README.md +++ b/sat/README.md @@ -117,8 +117,12 @@ bash inference.sh ### Preparing the Environment -Please note that currently, SAT needs to be installed from the source code for proper fine-tuning. We will address this -issue in future stable releases. +Please note that currently, SAT needs to be installed from the source code for proper fine-tuning. + +You need to get the code from the source to support the fine-tuning functionality, as these features have not yet been +released in the Pip package. + +We will address this issue in future stable releases. ``` git clone https://github.com/THUDM/SwissArmyTransformer.git @@ -197,7 +201,8 @@ model: 1. Run the inference code to start fine-tuning. ```shell -bash finetune.sh +bash finetune_single_gpu.sh # Single GPU +bash finetune_multi_gpus.sh # Multi GPUs ``` ### Converting to Huggingface Diffusers Supported Weights diff --git a/sat/README_zh.md b/sat/README_zh.md index 61f00f6..3335e52 100644 --- a/sat/README_zh.md +++ b/sat/README_zh.md @@ -112,7 +112,9 @@ bash inference.sh ### 准备环境 -请注意,目前,SAT需要从源码安装,才能正常微调, 我们将会在未来的稳定版本解决这个问题。 +请注意,目前,SAT需要从源码安装,才能正常微调。 +这是因为你需要使用还没发型到pip包版本的最新代码所支持的功能。 +我们将会在未来的稳定版本解决这个问题。 ``` git clone https://github.com/THUDM/SwissArmyTransformer.git @@ -189,7 +191,8 @@ model: 1. 运行推理代码,即可开始微调。 ```shell -bash finetune.sh +bash finetune_single_gpu.sh # Single GPU +bash finetune_multi_gpus.sh # Multi GPUs ``` ### 转换到 Huggingface Diffusers 库支持的权重 diff --git a/sat/data_video.py b/sat/data_video.py index ccfea46..3783340 100644 --- a/sat/data_video.py +++ b/sat/data_video.py @@ -425,7 +425,7 @@ class SFTDataset(Dataset): self.videos_list.append(tensor_frms) # caption - caption_path = os.path.join(root, filename.replace("videos", "labels").replace(".mp4", ".txt")) + caption_path = os.path.join(root, filename.replace(".mp4", ".txt")).replace("videos", "labels") if os.path.exists(caption_path): caption = open(caption_path, "r").read().splitlines()[0] else: diff --git a/sat/finetune_multi_gpus.sh b/sat/finetune_multi_gpus.sh new file mode 100644 index 0000000..d6b6383 --- /dev/null +++ b/sat/finetune_multi_gpus.sh @@ -0,0 +1,10 @@ +#! /bin/bash + +echo "RUN on `hostname`, CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES" + +run_cmd="torchrun --standalone --nproc_per_node=4 train_video.py --base configs/cogvideox_2b_sft.yaml --seed $RANDOM“ + +echo ${run_cmd} +eval ${run_cmd} + +echo "DONE on `hostname`" \ No newline at end of file diff --git a/sat/finetune.sh b/sat/finetune_single_gpu.sh similarity index 100% rename from sat/finetune.sh rename to sat/finetune_single_gpu.sh