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

Pytorch moved zero_gradients out of gradcheck (apparently?) #34

Closed
bwbellmath opened this issue Jul 2, 2021 · 1 comment
Closed

Pytorch moved zero_gradients out of gradcheck (apparently?) #34

bwbellmath opened this issue Jul 2, 2021 · 1 comment

Comments

@bwbellmath
Copy link

installing torchattacks from scratch on a fresh HPC environment, I hit the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../.conda/envs/stabn/lib/python3.8/site-packages/torchattacks/__init__.py", line 17, in <module>
    from .attacks.fab import FAB
  File ".../.conda/envs/stabn/lib/python3.8/site-packages/torchattacks/attacks/fab.py", line 12, in <module>
    from torch.autograd.gradcheck import zero_gradients
ImportError: cannot import name 'zero_gradients' from 'torch.autograd.gradcheck' (.../.conda/envs/stabn/lib/python3.8/site-packages/torch/autograd/gradcheck.py)

Notably, when investigating the gradcheck.py file, zero_gradients is no longer defined within and a significant refactor was mentioned in the relasenotes for pytorch version 1.9 17 days ago

I think I can just use the LTS release which seems not to have this change, but I think it's notable enough to raise as an issue.

@Harry24k
Copy link
Owner

Harry24k commented Jul 8, 2021

Thank you. Solved by implementing zero_gradients from the old version of PyTorch. Please refer to v3.0.0.

@Harry24k Harry24k closed this as completed Jul 8, 2021
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