Git Product home page Git Product logo

Comments (9)

JiayuZou2020 avatar JiayuZou2020 commented on June 8, 2024 4

If you want to use 6 GPUs for pretraining or fine-tuning, you can run the following code.
python -m torch.distributed.launch --nproc_per_node=6 --master_port=12320 run_mae_pretraining.py --data_path ${DATA_PATH} --mask_type tube --mask_ratio 0.9 --model pretrain_videomae_base_patch16_224 --decoder_depth 4 --batch_size 32 --num_frames 16 --sampling_rate 4 --opt adamw --opt_betas 0.9 0.95 --warmup_epochs 40 --save_ckpt_freq 20 --epochs 801 --log_dir ${OUTPUT_DIR} --output_dir ${OUTPUT_DIR}

from videomae.

jianyulei1 avatar jianyulei1 commented on June 8, 2024

Hi, if I want to set batch size to 8, does LR need to be changed?

from videomae.

mjlbach avatar mjlbach commented on June 8, 2024

I've had issues training with less GPUs (6 v100s), training on SSV2 we get about 40% higher loss than with the pretrained model (from the log files) at 800 epochs. The LR is scaled by num_training_steps per epoch which depends on the number of tasks.

Does anyone have any suggestions?

from videomae.

Zi-hao-Wei avatar Zi-hao-Wei commented on June 8, 2024

In my case, I added an accumlate iter arguments during training, which can scale up the effective batch size. The accum_iter's implementation can be found in the repo of MAE.

from videomae.

mjlbach avatar mjlbach commented on June 8, 2024

@Zi-hao-Wei Would you mind sharing your modifications/code?

from videomae.

Zi-hao-Wei avatar Zi-hao-Wei commented on June 8, 2024

You can find it here https://github.com/Zi-hao-Wei/VideoMAE_acc_iter; Maybe I can add a pull/request to the original repo?

from videomae.

mjlbach avatar mjlbach commented on June 8, 2024

@Zi-hao-Wei When I tried setting accum_iter to 8 on 8 A40s the loss seemed to not improve (green: accum_iter = 8, vs. grey: accum_iter=1)

image

What's a bit weird, is it works "ok" with accum_iter set to 6 (on 8x gpus), the model is able to learn but the resulting loss is worse than training on a single gpu.

image

Were you able to get good results with this? Wondering if the learning rates are equivalent as compared to the original implementation on more GPUs, that's the only thing I can think of.

My learning rate appears to start at 0:

{"train_lr": 0.0, "train_min_lr": 0.0, "train_loss": 1.4127931836105527, "train_loss_scale": 65536.0, "train_weight_decay": 0.05, "train_grad_norm": 0.8564211130142212, "epoch": 0, "n_parameters": 94210944}
{"train_lr": 2.958407871198569e-05, "train_min_lr": 2.958407871198569e-05, "train_loss": 1.4128651916980743, "train_loss_scale": 65536.0, "train_weight_decay": 0.05, "train_grad_norm": 0.8564602732658386, "epoch": 1, "n_parameters": 94210944}
{"train_lr": 5.916815742397138e-05, "train_min_lr": 5.916815742397138e-05, "train_loss": 1.3674379118851252, "train_loss_scale": 65536.0, "train_weight_decay": 0.05, "train_grad_norm": 0.761830747127533, "epoch": 2, "n_parameters": 94210944}
{"train_lr": 8.875223613595705e-05, "train_min_lr": 8.875223613595705e-05, "train_loss": 1.3142942587534587, "train_loss_scale": 65536.0, "train_weight_decay": 0.05, "train_grad_norm": 0.6155216693878174, "epoch": 3, "n_parameters": 94210944}

And not match what is in the log in MODEL_ZOO.md:

https://drive.google.com/file/d/1kP3_-465jCL7PRNFq1JcAghPo2BONRWY/view

Here's the difference:

800 epoch pretrained checkpoint from MODEL_ZOO.md:
rec_img10

Reproduced using the available training script, on 8 x a40s with accum_iter = 6 (8 does not train)
rec_img10

Also, I think you are clearing the gradients too early in your implementation. My modifications are in this branch: https://github.com/mjlbach/VideoMAE/tree/dataset_location, however, your implementation matches the original placement in this codebase (confused why it was moved from MAE in the first place)

from videomae.

Zi-hao-Wei avatar Zi-hao-Wei commented on June 8, 2024

Thank you for sharing. I will try to follow your implementation.

from videomae.

congee524 avatar congee524 commented on June 8, 2024

too small batch size may degrade the model performance, maybe you can use checkpoint.checkpoint to save memory.

from videomae.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.