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

SYS.DISTRIBUTED #9

Open
marson666 opened this issue Mar 23, 2022 · 7 comments
Open

SYS.DISTRIBUTED #9

marson666 opened this issue Mar 23, 2022 · 7 comments

Comments

@marson666
Copy link

I'm trying to train xing processed_data from scratch using DDP,
SYS.DISTRIBUTED True
SYS.WORLD_SIZE 4 (4 GPUS)

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 (1) passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel; (2) making sure all forward function outputs participate in calculating loss. If you already have done the above two steps, 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).

@marson666 marson666 changed the title SYS. SYS.DISTRIBUTED Mar 23, 2022
@ShenhanQian
Copy link
Owner

Thanks for reporting this problem. We have tested and fixed it by the latest commit. Please pull and check if the problem is gone on your side.

@marson666
Copy link
Author

maybe here should also add @torch.no_grad()

@ShenhanQian
Copy link
Owner

ShenhanQian commented Apr 1, 2022

Why?

@marson666
Copy link
Author

I use your latest repo to run the code and encounter the wrong error below, so i add @torch.no_grad() to reduce_tensor_dict and it run successfully.
python=3.8.12 torch=1.10.0+cu113

`Traceback (most recent call last):
File "main.py", line 73, in
main()
File "main.py", line 64, in main
mp.spawn(run_distributed,
File "/data/home/sen.ma/miniconda3/envs/py38/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 230, in spawn
return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
File "/data/home/sen.ma/miniconda3/envs/py38/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 188, in start_processes
while not context.join():
File "/data/home/sen.ma/miniconda3/envs/py38/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 150, in join
raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException:

-- Process 0 terminated with the following error:
Traceback (most recent call last):
File "/data/home/sen.ma/miniconda3/envs/py38/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 59, in _wrap
fn(i, *args)
File "/data/home/sen.ma/projects/SpeechDrivesTemplates/main.py", line 58, in run_distributed
run(args, cfg)
File "/data/home/sen.ma/projects/SpeechDrivesTemplates/main.py", line 51, in run
pipeline.train(cfg, exp_tag, args.resume_from)
File "/data/home/sen.ma/projects/SpeechDrivesTemplates/core/pipelines/trainer.py", line 389, in train
self.train_step(batch, t_step+1, global_step, epoch)
File "/data/home/sen.ma/projects/SpeechDrivesTemplates/core/pipelines/voice2pose.py", line 312, in train_step
self.reduce_tensor_dict(losses_dict)
File "/data/home/sen.ma/projects/SpeechDrivesTemplates/core/pipelines/trainer.py", line 329, in reduce_tensor_dict
v /= self.get_world_size()
RuntimeError: Output 0 of _DDPSinkBackward is a view and is being modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.
`

@ShenhanQian
Copy link
Owner

I don't encounter the same problem on my machine. Maybe it's caused by PyTorch version difference (I'm using PyTorch1.7.0).

Since reduce_tensor_dict is only used for logging rather than training, using @torch.no_grad() is ok.

As another solution (which avoids in-place operation), I suggest substituting v /= self.get_world_size() with tensor_dict[k] = v / self.get_world_size().

@ShenhanQian
Copy link
Owner

I have tested with the latest PyTorch distribution (1.11.0) and have not encountered the above problem. Did you modify the code and use reduce_tensor_dict before the backprop?

@marson666
Copy link
Author

I just change 2D landmarks to 3D, and comment the lip_sync_error

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

2 participants