Harry24k / adversarial-attacks-pytorch

PyTorch implementation of adversarial attacks [torchattacks].
https://adversarial-attacks-pytorch.readthedocs.io/en/latest/index.html
MIT License
1.79k stars 338 forks source link

Device error #49

Closed aminullah6264 closed 2 years ago

aminullah6264 commented 2 years ago

Hi Harry

I just tried with the demo code, however it pop up the following error.

torchattacks/attack.py", line 26, in init self.device = next(model.parameters()).device StopIteration:

aminullah6264 commented 2 years ago

solved by the following change in attack.py file

#     self.device = next(model.parameters()).device
       self.device = 'cuda'
aminullah6264 commented 2 years ago

self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Harry24k commented 2 years ago

This can be work, but I worried about the case you use more than 1 GPUs.