在4-3090对ChatGLM-6B-PT微调, 由于gpu:0, gpu:2, gpu:3都被占用, 导致微调显存不足
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 96.00 MiB (GPU 0; 23.70 GiB total capacity; 8.87 GiB already allocated; 79.81 MiB free; 8.88 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
只能选择在gpu:1上微调模型, 问题是deepspeed脚本ds_train_finetune.sh默认是全卡跑的, 可以看到运行时提示
[INFO] [launch.py:249:main] Setting CUDA_VISIBLE_DEVICES=0, 1, 2, 3
这是由于ds_train_finetune.sh中, 默认num_gpus=4所有卡全开
LR=1e-4
MASTER_PORT=$(shuf -n 1 -i 10000-65535)
deepspeed --num_gpus=4 --master_port $MASTER_PORT main.py \

在4-3090上使用ChatGLM-6B-PT模型进行微调时遇到GPU显存不足的问题,由于其他GPU已被占用。通过修改ds_train_finetune.sh脚本,设置CUDA_VISIBLE_DEVICES=1和--num_gpus=1来指定GPU:1进行训练,但初始尝试未成功。查阅Deepspeed文档后,尝试使用hostfile和--include参数,但因SSH连接问题失败。最终通过删除hostfile和仅使用--include=localhost:1解决了单GPU训练的问题,成功在GPU:1上进行微调。
最低0.47元/天 解锁文章
5万+





