fra31 / auto-attack

Code relative to "Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks"
https://arxiv.org/abs/2003.01690
MIT License
639 stars 111 forks source link

ImportError: cannot import name 'zero_gradients' from 'torch.autograd.gradcheck' #59

Closed Topology1225 closed 3 years ago

Topology1225 commented 3 years ago

I updated my pytorch to 1.9.0 via

pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

After that, I got the next error message.

File "/home/satoharu/AdEx/SDPML/src/attacker/Attacker.py", line 65, in attack
    adv_example = self._attack(log=log, *args, **kwargs)
  File "/home/satoharu/AdEx/SDPML/src/attacker/AUTOPGD.py", line 96, in _attack
    adversary = AutoAttack(
  File "/home/satoharu/.pyenv/versions/3.9.4_sdp/lib/python3.9/site-packages/autoattack/autoattack.py", line 31, in __init__
    from .fab_pt import FABAttack
  File "/home/satoharu/.pyenv/versions/3.9.4_sdp/lib/python3.9/site-packages/autoattack/fab_pt.py", line 16, in <module>
    from torch.autograd.gradcheck import zero_gradients
ImportError: cannot import name 'zero_gradients' from 'torch.autograd.gradcheck' (/home/satoharu/.pyenv/versions/3.9.4_sdp/lib/python3.9/site-packages/torch/autograd/gradcheck.py)

I think the zero_gradients method was removed.

Reference

https://pytorch.org/get-started/locally/