robustbench icon indicating copy to clipboard operation
robustbench copied to clipboard

Quick Tour Error

Open asim29 opened this issue 3 months ago • 2 comments

I tried running the quick tour to test the library, and it doesn't seem to work.

Steps to replicate

Installation

Environment setup:

conda create -n robustbench
conda install python 

This installs Python 3.13.7.

RobustBench setup:

<base_dir>/.conda/envs/robustbench/bin/pip install git+https://github.com/RobustBench/robustbench.git

Running the tour

I then used the following code:

from robustbench.data import load_cifar10
from robustbench.utils import load_model
from autoattack import AutoAttack

x_test, y_test = load_cifar10(n_examples=50)

model = load_model(model_name='Carmon2019Unlabeled', dataset='cifar10', threat_model='Linf')

adversary = AutoAttack(model, norm='Linf', eps=8/255, version='custom', attacks_to_run=['apgd-ce', 'apgd-dlr'])
adversary.apgd.n_restarts = 1

x_adv = adversary.run_standard_evaluation(x_test, y_test)

print(x_adv)

I got the following error:

using custom version including apgd-ce, apgd-dlr.
Traceback (most recent call last):
  File "/home/a7waheed/robustbench/testing.py", line 12, in <module>
    x_adv = adversary.run_standard_evaluation(x_test, y_test)
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/autoattack/autoattack.py", line 112, in run_standard_evaluation
    checks.check_randomized(self.get_logits, x_orig[:bs].to(self.device),
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        y_orig[:bs].to(self.device), bs=bs, logger=self.logger)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/autoattack/checks.py", line 24, in check_randomized
    output = model(x)
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/autoattack/autoattack.py", line 74, in get_logits
    return self.model(x)
           ~~~~~~~~~~^^^
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/robustbench/model_zoo/architectures/wide_resnet.py", line 87, in forward
    out = self.conv1(x)
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/conv.py", line 548, in forward
    return self._conv_forward(input, self.weight, self.bias)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a7waheed/.conda/envs/robustbench/lib/python3.13/site-packages/torch/nn/modules/conv.py", line 543, in _conv_forward
    return F.conv2d(
           ~~~~~~~~^
        input, weight, bias, self.stride, self.padding, self.dilation, self.groups
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

asim29 avatar Oct 04 '25 17:10 asim29