ChatGLM2-6B icon indicating copy to clipboard operation
ChatGLM2-6B copied to clipboard

[BUG/Help] 在windows上做ptuning微调【已解决】

Open cyxdsp opened this issue 1 year ago • 23 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

不能再windows上做ptuning主要还是启用了pytorch的分布式计算特性,所以修改其中几个地方来避免这个问题 【本文使用windows上的单卡训练】

Expected Behavior

No response

Steps To Reproduce

1、移除mian.py代码中的 _mp_fn 函数,这是为了在 TPU 环境中使用的。 #def _mp_fn(index): # For xla_spawn (TPUs) # main()

2、这段代码中使用了 trainer.is_world_process_zero() 来判断是否为分布式计算中的主节点,你可以将该条件语句替换为 True,因为在单机环境中,你的唯一进程就是主节点。 if trainer.is_world_process_zero(): 替换后 if True:

3、在train.sh文件中将torchrun替换为python,并且需要移除--standalone --nnodes=1 --nproc-per-node=$NUM_GPUS这些指向分布式设置的标志。 #torchrun --standalone --nnodes=1 --nproc-per-node=$NUM_GPUS main.py
python main.py \

over

Environment

- OS:
- Python:3.10.9
- Transformers:
- PyTorch:11.7
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :

Anything else?

No response

cyxdsp avatar Jul 05 '23 03:07 cyxdsp

同环境,同配置,同问题。如上操作后,出现新问题。

│ C:\ProgramData\anaconda3\envs\glm\lib\site-packages\torch\distributed\distributed_c10d.py:707 in _get_default_group
│ 704 │ Getting the default process group created by init_process_group
│ 705 │ """
│ 706 │ if not is_initialized():
│ ❱ 707 │ │ raise RuntimeError(
│ 708 │ │ │ "Default process group has not been initialized, "
│ 709 │ │ │ "please make sure to call init_process_group."
│ 710 │ │ )

RuntimeError: Default process group has not been initialized, please make sure to call init_process_group.

hlwgy avatar Jul 05 '23 06:07 hlwgy

报错截全一点,我的可以微调,结果也可以运行。

cyxdsp avatar Jul 05 '23 06:07 cyxdsp

image

isacck avatar Jul 05 '23 07:07 isacck

image

isacck avatar Jul 05 '23 07:07 isacck

image

我改了之后也卡到这一步了

DecemberBi avatar Jul 05 '23 07:07 DecemberBi

我也有这个问题,求解

zoey-zy998 avatar Jul 05 '23 07:07 zoey-zy998

image

看来这个问题挺普遍的,我把我的代码发上来吧,也许是什么设置不一样。

cyxdsp avatar Jul 05 '23 09:07 cyxdsp

我也有这个问题,求解

看来这个问题挺普遍的,我把我的代码发上来吧,也许是什么设置不一样。

cyxdsp avatar Jul 05 '23 09:07 cyxdsp

image

我改了之后也卡到这一步了

看来这个问题挺普遍的,我把我的代码发上来吧,也许是什么设置不一样。

cyxdsp avatar Jul 05 '23 09:07 cyxdsp

https://github.com/cyxdsp/chatglm2----win--:我修改的代码在这里,你们自己看吧

cyxdsp avatar Jul 05 '23 09:07 cyxdsp

https://github.com/cyxdsp/chatglm2----win--:我修改的代码在这里,你们自己看吧 还是出现同样的问题

zoey-zy998 avatar Jul 05 '23 10:07 zoey-zy998

问题+1,请问楼主什么GPU

ALixuhui avatar Jul 05 '23 10:07 ALixuhui

楼主好像没有用GPU跑

zoey-zy998 avatar Jul 05 '23 10:07 zoey-zy998

楼主好像没有用GPU跑

PRE_SEQ_LEN=128 LR=1e-3 NUM_GPUS=0#我用了GUP啊,编号0

cyxdsp avatar Jul 05 '23 10:07 cyxdsp

RuntimeError: Default process group has not been initialized, please make sure to call init_process_group. 真的跪了

zoey-zy998 avatar Jul 05 '23 10:07 zoey-zy998

RuntimeError: Default process group has not been initialized, please make sure to call init_process_group. 真的跪了

你把你的mian.py和train.sh上传给我看俺,这个问题我遇到过,还是分布式的问题

cyxdsp avatar Jul 05 '23 10:07 cyxdsp

楼主,我的main.py没有做变动,下面是train_chat.sh: PRE_SEQ_LEN=128 LR=1e-2 NUM_GPUS=6 CHAT_TRAIN_DATA=/data/lxh/workspace/nlp/ft-dataset/lxh_v3/sft_v3_lxh_shuffle.json CHAT_VAL_DATA=/data/lxh/workspace/nlp/ft-dataset/lxh_v3/sft_v3_lxh_shuffle.json CHECKPOINT_NAME=output/chatglm-6b2-pt-lxh-v3-$PRE_SEQ_LEN-$LR

#torchrun --standalone --nnodes=1 --nproc-per-node=$NUM_GPUS main.py \

CUDA_VISIBLE_DEVICES=1,2,3,4,5,6 python3 main.py
--do_train
--train_file $CHAT_TRAIN_DATA
--validation_file $CHAT_VAL_DATA
--preprocessing_num_workers 10
--prompt_column instruction
--response_column output
--history_column history
--overwrite_cache
--model_name_or_path /data/lxh/workspace/nlp/pre_models/chatglm2-6b
--output_dir $CHECKPOINT_NAME
--overwrite_output_dir
--max_source_length 256
--max_target_length 256
--per_device_train_batch_size 1
--per_device_eval_batch_size 1
--gradient_accumulation_steps 16
--predict_with_generate
--max_steps 200000
--logging_steps 10
--save_steps 500
--learning_rate $LR
--pre_seq_len $PRE_SEQ_LEN
--quantization_bit 4

我目前:torch版本=2.0.0+cu117、transformers=4.30.2、python=3.8.16

ALixuhui avatar Jul 05 '23 11:07 ALixuhui

楼主,我的main.py没有做变动,下面是train_chat.sh: PRE_SEQ_LEN=128 LR=1e-2 NUM_GPUS=6 CHAT_TRAIN_DATA=/data/lxh/workspace/nlp/ft-dataset/lxh_v3/sft_v3_lxh_shuffle.json CHAT_VAL_DATA=/data/lxh/workspace/nlp/ft-dataset/lxh_v3/sft_v3_lxh_shuffle.json CHECKPOINT_NAME=output/chatglm-6b2-pt-lxh-v3-$PRE_SEQ_LEN-$LR

#torchrun --standalone --nnodes=1 --nproc-per-node=$NUM_GPUS main.py \

CUDA_VISIBLE_DEVICES=1,2,3,4,5,6 python3 main.py --do_train --train_file $CHAT_TRAIN_DATA --validation_file $CHAT_VAL_DATA --preprocessing_num_workers 10 --prompt_column instruction --response_column output --history_column history --overwrite_cache --model_name_or_path /data/lxh/workspace/nlp/pre_models/chatglm2-6b --output_dir $CHECKPOINT_NAME --overwrite_output_dir --max_source_length 256 --max_target_length 256 --per_device_train_batch_size 1 --per_device_eval_batch_size 1 --gradient_accumulation_steps 16 --predict_with_generate --max_steps 200000 --logging_steps 10 --save_steps 500 --learning_rate $LR --pre_seq_len $PRE_SEQ_LEN --quantization_bit 4

我目前:torch版本=2.0.0+cu117、transformers=4.30.2、python=3.8.16

六张卡啊,没试过,都六张卡了为什么还要加最后一句呢? 4bit量化还会更慢。另外,仔细看了下,你这和官方的脚本差别好大,而且我提供的修改mian.py的方法你没参考, 我很难办啊

cyxdsp avatar Jul 05 '23 11:07 cyxdsp

同环境,同配置,同问题。如上操作后,出现新问题。

│ C:\ProgramData\anaconda3\envs\glm\lib\site-packages\torch\distributed\distributed_c10d.py:707 in _get_default_group │ 704 │ Getting the default process group created by init_process_group │ 705 │ """ │ 706 │ if not is_initialized(): │ ❱ 707 │ │ raise RuntimeError( │ 708 │ │ │ "Default process group has not been initialized, " │ 709 │ │ │ "please make sure to call init_process_group." │ 710 │ │ )

RuntimeError: Default process group has not been initialized, please make sure to call init_process_group.

有这个问题的可以把 transformers 降级到 4.27.1

duzx16 avatar Jul 05 '23 13:07 duzx16

同环境,同配置,同问题。如上操作后,出现新问题。 │ C:\ProgramData\anaconda3\envs\glm\lib\site-packages\torch\distributed\distributed_c10d.py:707 in _get_default_group │ 704 │ Getting the default process group created by init_process_group │ 705 │ """ │ 706 │ if not is_initialized(): │ ❱ 707 │ │ raise RuntimeError( │ 708 │ │ │ "Default process group has not been initialized, " │ 709 │ │ │ "please make sure to call init_process_group." │ 710 │ │ ) RuntimeError: Default process group has not been initialized, please make sure to call init_process_group.

有这个问题的可以把 transformers 降级到 4.27.1

降级后出现:train_chat.sh: line 33: 25625 Segmentation fault image

ALixuhui avatar Jul 06 '23 02:07 ALixuhui

请问大佬们在启动训练的时候,提示这个报错应该怎么解决? image

MuCune avatar Jul 06 '23 14:07 MuCune

同环境,同配置,同问题。如上操作后,出现新问题。 │ C:\ProgramData\anaconda3\envs\glm\lib\site-packages\torch\distributed\distributed_c10d.py:707 in _get_default_group │ 704 │ Getting the default process group created by init_process_group │ 705 │ """ │ 706 │ if not is_initialized(): │ ❱ 707 │ │ raise RuntimeError( │ 708 │ │ │ "Default process group has not been initialized, " │ 709 │ │ │ "please make sure to call init_process_group." │ 710 │ │ ) RuntimeError: Default process group has not been initialized, please make sure to call init_process_group.

有这个问题的可以把 transformers 降级到 4.27.1

用这个办法解决了

kufei88 avatar Jul 07 '23 09:07 kufei88

同环境,同配置,同问题。如上操作后,出现新问题。 │ C:\ProgramData\anaconda3\envs\glm\lib\site-packages\torch\distributed\distributed_c10d.py:707 in _get_default_group │ 704 │ Getting the default process group created by init_process_group │ 705 │ """ │ 706 │ if not is_initialized(): │ ❱ 707 │ │ raise RuntimeError( │ 708 │ │ │ "Default process group has not been initialized, " │ 709 │ │ │ "please make sure to call init_process_group." │ 710 │ │ ) RuntimeError: Default process group has not been initialized, please make sure to call init_process_group.

有这个问题的可以把 transformers 降级到 4.27.1

用这个办法解决了

对的,我之前换了一些库,一时想不出来,解决了就好

cyxdsp avatar Jul 07 '23 09:07 cyxdsp