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

Problem of the _calculate_2nd_gradient #22

Closed
alibaba-yiwuyao opened this issue Mar 3, 2021 · 2 comments
Closed

Problem of the _calculate_2nd_gradient #22

alibaba-yiwuyao opened this issue Mar 3, 2021 · 2 comments

Comments

@alibaba-yiwuyao
Copy link

When I run the cream nas with pytorch==1.7.1, problem appears:

File "/app/nni_lib/trainer.py", line 294, in _calculate_2nd_gradient
grad_outputs=grad_student_val,
File "/opt/conda/lib/python3.7/site-packages/torch/autograd/init.py", line 192, in grad
inputs, allow_unused)
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3136, 1]], which is output 0 of TBackward, is at version 5; expected version 4 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

The second grad calculation may have some problem?

grad_teacher = torch.autograd.grad(
students_weight[0],
self.model.rand_parameters(teacher_cand, self.pick_method=='meta'),
grad_outputs=grad_student_val,
)

@Z7zuqer
Copy link
Collaborator

Z7zuqer commented Mar 4, 2021

Hi,

This error is the result of using different pytorch version. If you install pytorch=1.2 and apex, the code could run without error.

Best,
Hao.

@alibaba-yiwuyao
Copy link
Author

Pytorch 1.2 is OK for this issue, thanks:)

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