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

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. #79

Open
chenglinh opened this issue Jul 17, 2023 · 2 comments

Comments

@chenglinh
Copy link

Hi, I am facing the error message described below while training on my RTX 4090 GPU. I've adjusted the frame number to avoid exceeding the memory limitation, and left the remaining code unchanged. However, the training process could not function properly. Besides, I've seen someone posted similar issue previously, though I did not understand how did he solve his problem. Thus, I'm posting this issue again to ask for help. Thanks!


The following values were not passed to accelerate launch and had defaults used instead:
More than one GPU was found, enabling multi-GPU training.
If this was unintended please pass in --num_processes=1.
--num_machines was set to a value of 1
--mixed_precision was set to a value of 'no'
--dynamo_backend was set to a value of 'no'
To avoid this warning pass in values for each of the problematic parameters or run accelerate config.
07/17/2023 05:25:57 - INFO - main - Distributed environment: MULTI_GPU Backend: nccl
Num processes: 1
Process index: 0
Local process index: 0
Device: cuda:0

Mixed precision type: fp16

{'variance_type', 'prediction_type'} was not found in config. Values will be initialized to default values.
The config attributes {'scaling_factor': 0.18215} were passed to AutoencoderKL, but are not expected and will be ignored. Please verify your config.json configuration file.
{'norm_num_groups'} was not found in config. Values will be initialized to default values.
{'only_cross_attention', 'class_embed_type', 'upcast_attention', 'resnet_time_scale_shift', 'dual_cross_attention', 'mid_block_type', 'num_class_embeds', 'use_linear_projection'} was not found in config. Values will be initialized to default values.
{'prediction_type'} was not found in config. Values will be initialized to default values.
{'prediction_type'} was not found in config. Values will be initialized to default values.
07/17/2023 05:26:02 - INFO - main - ***** Running training *****
07/17/2023 05:26:02 - INFO - main - Num examples = 1
07/17/2023 05:26:02 - INFO - main - Num Epochs = 500
07/17/2023 05:26:02 - INFO - main - Instantaneous batch size per device = 1
07/17/2023 05:26:02 - INFO - main - Total train batch size (w. parallel, distributed & accumulation) = 1
07/17/2023 05:26:02 - INFO - main - Gradient Accumulation steps = 1
07/17/2023 05:26:02 - INFO - main - Total optimization steps = 500
Steps: 0%| | 0/500 [00:00<?, ?it/s]
/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/utils/checkpoint.py:25: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
warnings.warn("None of the inputs have requires_grad=True. Gradients will be None")
Steps: 0%|▍ | 1/500 [00:01<10:49, 1.30s/it, lr=3e-5, step_loss=0.00935]
Traceback (most recent call last):
File "/home/clhsieh/video_editing/Tune-A-Video/train_tuneavideo.py", line 374, in
main(**OmegaConf.load(args.config))
File "/home/clhsieh/video_editing/Tune-A-Video/train_tuneavideo.py", line 296, in main
model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 994, in forward
if torch.is_grad_enabled() and self.reducer._rebuild_buckets():
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel, and by
making sure all forward function outputs participate in calculating loss.
If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).
Parameter indices which did not receive grad for rank 0: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error
Steps: 0%|▍ | 1/500 [00:01<12:45, 1.53s/it, lr=3e-5, step_loss=0.00935]
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 44880) of binary: /home/clhsieh/miniconda3/envs/tune_a_video/bin/python
Traceback (most recent call last):
File "/home/clhsieh/miniconda3/envs/tune_a_video/bin/accelerate", line 8, in
sys.exit(main())
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 45, in main
args.func(args)
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/accelerate/commands/launch.py", line 970, in launch_command
multi_gpu_launcher(args)
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/accelerate/commands/launch.py", line 646, in multi_gpu_launcher
distrib_run.run(args)
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/distributed/run.py", line 752, in run
elastic_launch(
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 131, in call
return launch_agent(self._config, self._entrypoint, list(args))
File "/home/clhsieh/miniconda3/envs/tune_a_video/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 245, in launch_agent
raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

@RoyZhao926
Copy link

I have the same question

@NguyenTriTrinh
Copy link

Specifying one GPU like "export CUDA_VISIBLE_DEVICES=0" works for me

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