dvlab-research / MGM

Official repo for "Mini-Gemini: Mining the Potential of Multi-modality Vision Language Models"
Apache License 2.0
3.22k stars 280 forks source link

为啥我6张4090 24G,微调Mini-Gemini-8x7B会显存不够QAQ #75

Closed HongLouyemeng closed 7 months ago

HongLouyemeng commented 7 months ago

是zero2的原因吗

yanwei-li commented 7 months ago

Hi, please try zero3 if do not have enough GPU. But 8x7B model needs to load all the MoE weights before training, I guess 6x4090 is not enough for fine-tuning the 8x7B model.

HongLouyemeng commented 7 months ago

Hi, please try zero3 if do not have enough GPU. But 8x7B model needs to load all the MoE weights before training, I guess 6x4090 is not enough for fine-tuning the 8x7B model.

但是2B的模型在4个4090 24G上也不够 image

HongLouyemeng commented 7 months ago

使用问题解决

teamwong111 commented 6 months ago

使用问题解决

Hi, I use 10x3090 to finetune Gemma 2B and occur CUDA out of memory, and the comment can not solve my issue. my script is as follows. Could you help me?

#!/bin/bash
PRETRAIN_NAME=MGM-2B-Pretrain
FINETUNE_NAME=MGM-2B-HD
AUX_SIZE=1536
IMAGE_GRID=2
IMAGE_GLOBAL=True

deepspeed \
    mgm/train/train_mem.py \
    --deepspeed ./scripts/zero2_offload.json \
    --model_name_or_path model_zoo/LLM/gemma/gemma-2b-it \
    --version gemma \
    --data_path ./data/MGM-Finetune/ai2d.json \
    --image_folder ./data/MGM-Finetune \
    --vision_tower model_zoo/OpenAI/clip-vit-large-patch14-336 \
    --vision_tower_aux model_zoo/OpenAI/openclip-convnext-large-d-320-laion2B-s29B-b131K-ft-soup \
    --image_grid $IMAGE_GRID \
    --image_global $IMAGE_GLOBAL \
    --pretrain_mm_mlp_adapter ./work_dirs/$PRETRAIN_NAME/mm_projector.bin \
    --mm_projector_type mlp2x_gelu \
    --mm_vision_select_layer -2 \
    --mm_use_im_start_end False \
    --mm_use_im_patch_token False \
    --image_aspect_ratio pad \
    --group_by_modality_length True \
    --image_size_aux $AUX_SIZE \
    --bf16 True \
    --output_dir ./work_dirs/$FINETUNE_NAME \
    --num_train_epochs 1 \
    --per_device_train_batch_size 4 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 1 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 20000 \
    --save_total_limit 1 \
    --learning_rate 2e-5 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --tf32 True \
    --model_max_length 2048 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True \
    --report_to wandb