Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模型训练时GPU占用率长时间保持100% #66

Open
ProgrameThinking opened this issue Jan 18, 2025 · 11 comments
Open

模型训练时GPU占用率长时间保持100% #66

ProgrameThinking opened this issue Jan 18, 2025 · 11 comments

Comments

@ProgrameThinking
Copy link

作者您好,在使用该框架训练的时候出现运行若干个epoch后gpu占用率达到100%,但是训练不再进行下去的情况,也就是卡死,其中epoch数并不固定。设备是两张4090,pytorch版本是2.5.1 cuda版本是12.1

@SunnyHaze
Copy link
Contributor

请具体指明复现时使用的模型名,如果有超参数的shell最好也上传一下方便复现与确认问题。

@ProgrameThinking
Copy link
Author

请具体指明复现时使用的模型名,如果有超参数的shell最好也上传一下方便复现与确认问题。

模型是我自己写的,并不方便上传,但是我可以把训练的shell粘贴过来
训练部分有8000张图片,测试部分有2000张图片。

您可以提供一些有助于定位问题的方法吗?

base_dir="./output_dir"
mkdir -p ${base_dir}

CUDA_VISIBLE_DEVICES=0,1
torchrun
--standalone
--nnodes=1
--nproc_per_node=2
./train.py
--model mynet
--world_size 2
--batch_size 6
--data_path "dataset/train.json"
--epochs 200
--lr 1e-4
--image_size 512
--if_not_amp
--num_workers 0
--find_unused_parameters
--if_resizing
--min_lr 5e-7
--weight_decay 0.05
--edge_mask_width 7
--test_data_path "dataset/val.json"
--test_batch_size 1
--warmup_epochs 2
--output_dir ${base_dir}/
--log_dir ${base_dir}/
--accum_iter 2
--seed 42
--test_period 4
2> ${base_dir}/error.log 1>${base_dir}/logs.log

@Inkyl
Copy link
Contributor

Inkyl commented Jan 18, 2025

目前发现4090机器在运行Trufor和Mesorch模型时,偶尔会出现NCCL通信超时问题,而A40和3090机器几乎未遇到类似情况。针对此问题,我们的临时解决方案是:开始训练模型时,程序稳定运行后,多次使用Ctrl+C终止进程后再稳定训练模型,这一操作可显著降低问题发生的概率。同时定期保存检查点(ckpt)以便快速恢复。

问题的根本原因仍在排查中,初步推测可能与4090的硬件特性以及Trufor和Mesorch模型的某些配置参数有关。我们将继续深入分析以彻底解决。

@SunnyHaze
Copy link
Contributor

这里主要是通过输出额外的CUDA日志说明为:出现NCCL通信超时问题。这个属于比较底层的bug。。。确实有点棘手。

@ProgrameThinking
Copy link
Author

请问您是否注意出现NCCL通信超时这个问题时其他模型的训练loss?在我这里是当输出的预测loss在0.07左右会卡死

@SunnyHaze
Copy link
Contributor

我们这边的经验感觉随机性比较大,和loss关系不大,有的时候严重有的时候不厉害。

一个比较极端的操作是关掉amp半精度,这样可以保证不出问题,但是会使得训练速度变慢,显存变大...

我们暂时理论上认为就是GPU在某些局部,通信速度比运算速度慢,导致卡死。加上4090本身就削减了一部分带宽。是有点棘手,如果可行的话可以考虑换机器or削减模型理论计算所需的带宽。

@ProgrameThinking
Copy link
Author

好吧,感谢您的回复

@SunnyHaze
Copy link
Contributor

这个问题有其他的发现和进展欢迎随时同步,我们也找了很久这个问题怎么解决...

@ProgrameThinking
Copy link
Author

实际上我报告情况的时候已经关闭了半精度...,不过还是感谢您的解答

@SunnyHaze
Copy link
Contributor

这样啊...我们这两天再看看定位下问题吧,这个确实蛮恼火的。

@SunnyHaze
Copy link
Contributor

Anyway也感谢你report这些信息。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants