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

Import error for pytorch version 1.10.0 #78

Closed henrikju closed 2 years ago

henrikju commented 2 years ago

For the latest pytorch 1.10.0, there is an import error when defining an AutoAttack object:

 15 import torch

---> 16 from torch.autograd.gradcheck import zero_gradients 17 18 from autoattack.fab_projections import projection_linf, projection_l2,\

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

It seems this can be easily fixed, by replacing all instances of "zero_gradients(im)" with "im.zero_grad()" in fab_pt.py.

fra31 commented 2 years ago

Hi,

this should have been fixed with https://github.com/fra31/auto-attack/commit/40dddf05b3bb62dd723eed9bd4cab7395b79de31. Are you maybe using an older version?

henrikju commented 2 years ago

Hi,

yes you are right. I was using an older version. The reason was because i was relying on the automated installation of autoattack from robustbench, i think that might still be pointing to an older version of autoattack.

Thanks!

fra31 commented 2 years ago

Right, I'll update that too, thanks!