showlab / Tune-A-Video

[ICCV 2023] Tune-A-Video: One-Shot Tuning of Image Diffusion Models for Text-to-Video Generation
https://tuneavideo.github.io
Apache License 2.0
4.15k stars 377 forks source link

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 #78

Closed cuiliyuan121 closed 1 year ago

cuiliyuan121 commented 1 year ago

when run the argument:'accelerate launch train_tuneavideo.py --config="configs/man-skiing.yaml', it has error like: Steps: 0%| | 0/500 [00:00<?, ?it/s]/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/utils/checkpoint.py:31: 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") /root/anaconda3/envs/video/lib/python3.9/site-packages/torch/utils/checkpoint.py:31: 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") /root/anaconda3/envs/video/lib/python3.9/site-packages/torch/utils/checkpoint.py:31: 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") /root/anaconda3/envs/video/lib/python3.9/site-packages/torch/utils/checkpoint.py:31: 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:03<26:30, 3.19s/it, lr=3e-5, step_loss=0.00912]Traceback (most recent call last): File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 367, in <module> main(**OmegaConf.load(args.config)) File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 289, in main model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 553, in forward return model_forward(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 541, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast return func(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1026, 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 argumentfind_unused_parameters=Truetotorch.nn.parallel.DistributedDataParallel, and by making sure allforwardfunction 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'sforwardfunction. Please include the loss function and the structure of the return value offorwardof your module when reporting this issue (e.g. list, dict, iterable). Parameter indices which did not receive grad for rank 1: 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 Traceback (most recent call last): File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 367, in <module> main(**OmegaConf.load(args.config)) File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 289, in main model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 553, in forward return model_forward(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 541, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast return func(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1026, 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 argumentfind_unused_parameters=Truetotorch.nn.parallel.DistributedDataParallel, and by making sure allforwardfunction 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'sforwardfunction. Please include the loss function and the structure of the return value offorwardof 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 Traceback (most recent call last): File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 367, in <module> main(**OmegaConf.load(args.config)) File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 289, in main model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 553, in forward return model_forward(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 541, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast return func(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1026, 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 argumentfind_unused_parameters=Truetotorch.nn.parallel.DistributedDataParallel, and by making sure allforwardfunction 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'sforwardfunction. Please include the loss function and the structure of the return value offorwardof your module when reporting this issue (e.g. list, dict, iterable). Parameter indices which did not receive grad for rank 2: 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:03<33:03, 3.98s/it, lr=3e-5, step_loss=0.00912] Traceback (most recent call last): File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 367, in <module> main(**OmegaConf.load(args.config)) File "/HOME/cuily/Tune-A-Video-main/train_tuneavideo.py", line 289, in main model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 553, in forward return model_forward(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/utils/operations.py", line 541, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast return func(*args, **kwargs) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1026, 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 argumentfind_unused_parameters=Truetotorch.nn.parallel.DistributedDataParallel, and by making sure allforwardfunction 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'sforwardfunction. Please include the loss function and the structure of the return value offorward` of your module when reporting this issue (e.g. list, dict, iterable). Parameter indices which did not receive grad for rank 3: 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 ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 61745) of binary: /root/anaconda3/envs/video/bin/python Traceback (most recent call last): File "/root/anaconda3/envs/video/bin/accelerate", line 8, in sys.exit(main()) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/commands/accelerate_cli.py", line 45, in main args.func(args) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/commands/launch.py", line 932, in launch_command multi_gpu_launcher(args) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/accelerate/commands/launch.py", line 627, in multi_gpu_launcher distrib_run.run(args) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/distributed/run.py", line 753, in run elastic_launch( File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 132, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/root/anaconda3/envs/video/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 246, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

train_tuneavideo.py FAILED`

is there any value or loss function not be contributed to the forward function? how to check it?

cuiliyuan121 commented 1 year ago

just use one A1000 resolve this problem