carpedm20 / carpedm20/ENAS-pytorch
RuntimeError: grad can be implicitly created only for scalar outputs
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 486
- PR merge metrics
- No merged PRs in 30d
Description
I encountered this strange error. Here is the output, thank you.
Before, it was showing that the error cannot run on CPU and GPU at the same time, I added . cuda() after loss, it starts showing this error.
Traceback (most recent call last):
File "D:/xiangmu/ENAS-pytorch-master/main.py", line 56, in
main(args)
File "D:/xiangmu/ENAS-pytorch-master/main.py", line 35, in main
trnr.train()
File "D:\xiangmu\ENAS-pytorch-master\trainer.py", line 223, in train
self.train_shared(dag=dag)
File "D:\xiangmu\ENAS-pytorch-master\trainer.py", line 317, in train_shared
loss.backward()
File "C:\Users\sunhaonan\.conda\envs\enas\lib\site-packages\torch\_tensor.py", line 307, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "C:\Users\sunhaonan\.conda\envs\enas\lib\site-packages\torch\autograd\__init__.py", line 150, in backward
grad_tensors_ = _make_grads(tensors, grad_tensors_)
File "C:\Users\sunhaonan\.conda\envs\enas\lib\site-packages\torch\autograd\__init__.py", line 51, in _make_grads
raise RuntimeError("grad can be implicitly created only for scalar outputs")
RuntimeError: grad can be implicitly created only for scalar outputs
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with main.py and trainer.py, following the call from main() through train() to train_shared() at trainer.py line 317, where loss.backward() fails. Reproduce the reported run and inspect the loss value immediately before backward. Done means the training path no longer raises the reported RuntimeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100