Internal assert failed from pytorch, bug report

When I run my code, this message is displayed: How can I fix it? I’m writing a neural network with pytorch-lightning and dgl with multiple optimizers, and I’m training with ddp on 1 gpu.

Traceback (most recent call last):
  File "", line 50, in <module>, train_loader, val_loader)
  File "/afs/", line 439, in fit
    results = self.accelerator_backend.train()
  File "/afs/", line 146, in train
    results = self.ddp_train(process_idx=self.task_idx, model=model)
  File "/afs/", line 279, in ddp_train
    results = self.train_or_test()
  File "/afs/", line 66, in train_or_test
    results = self.trainer.train()
  File "/afs/", line 482, in train
  File "/afs/", line 541, in run_training_epoch
    batch_output = self.run_training_batch(batch, batch_idx, dataloader_idx)
  File "/afs/", line 678, in run_training_batch
  File "/afs/", line 760, in training_step_and_backward
    result = self.training_step(split_batch, batch_idx, opt_idx, hiddens)
  File "/afs/", line 304, in training_step
    training_step_output = self.trainer.accelerator_backend.training_step(args)
  File "/afs/", line 156, in training_step
    output = self.trainer.model(*args)
  File "/afs/", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/afs/", line 176, in forward
    output = self.module.training_step(*inputs[0], **kwargs[0])
  File "/afs/", line 195, in training_step
    self.manual_backward(L_est, opts[1], retain_graph=True)
  File "/afs/", line 1081, in manual_backward
    self.trainer.train_loop.backward(loss, optimizer, -1, *args, **kwargs)
  File "/afs/", line 781, in backward
    self.trainer.accelerator_backend.backward(result, optimizer, opt_idx, *args, **kwargs)
  File "/afs/", line 98, in backward
    closure_loss.backward(*args, **kwargs)
  File "/afs/", line 198, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/afs/", line 100, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: has_marked_unused_parameters_ INTERNAL ASSERT FAILED at /opt/conda/conda-bld/pytorch_1591914880026/work/torch/csrc/distributed/c10d/reducer.cpp:327, please report a bug to PyTorch.  (mark_variable_ready at /opt/conda/conda-bld/pytorch_1591914880026/work/torch/csrc/distributed/c10d/reducer.cpp:327)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x4e (0x7f27ea039b5e in /afs/
frame #1: c10d::Reducer::mark_variable_ready(c10d::Reducer::VariableIndex) + 0x9ba (0x7f2817a1b3aa in /afs/
frame #2: c10d::Reducer::autograd_hook(c10d::Reducer::VariableIndex) + 0x2d0 (0x7f2817a1b910 in /afs/
frame #3: <unknown function> + 0x8a395c (0x7f2817a1095c in /afs/
frame #4: torch::autograd::Engine::evaluate_function(std::shared_ptr<torch::autograd::GraphTask>&, torch::autograd::Node*, torch::autograd::InputBuffer&) + 0x60d (0x7f281412d00d in /afs/
frame #5: torch::autograd::Engine::thread_main(std::shared_ptr<torch::autograd::GraphTask> const&, bool) + 0x3d2 (0x7f281412eed2 in /afs/
frame #6: torch::autograd::Engine::thread_init(int) + 0x39 (0x7f2814127549 in /afs/
frame #7: torch::autograd::python::PythonEngine::thread_init(int) + 0x38 (0x7f2817677638 in /afs/
frame #8: <unknown function> + 0xc819d (0x7f2819ed219d in /afs/
frame #9: <unknown function> + 0x7ea5 (0x7f2838eebea5 in /lib64/
frame #10: clone + 0x6d (0x7f2838c148cd in /lib64/

Exception ignored in: <function tqdm.__del__ at 0x7f27dcf30b90>
Traceback (most recent call last):
  File "/afs/", line 1122, in __del__
  File "/afs/", line 1335, in close
  File "/afs/", line 1514, in display
  File "/afs/", line 1125, in __repr__
  File "/afs/", line 1475, in format_dict
TypeError: cannot unpack non-iterable NoneType object

Are you seeing the same issue without using Lightning?
Also, could you post an executable code snippet so that we could reproduce this issue?

I’ve confirmed it’s an error on pytorch-lightning side. Thank you for the suggestion!