LukasStruppek / Plug-and-Play-Attacks

[ICML 2022 / ICLR 2024] Source code for our papers "Plug & Play Attacks: Towards Robust and Flexible Model Inversion Attacks" and "Be Careful What You Smooth For".
https://proceedings.mlr.press/v162/struppek22a.html
MIT License
37 stars 9 forks source link

ValueError: Could not find run <Run model_inversion_targets_facescrub/XXXXXXXXX/XXXXXXXXX (not found)> #4

Closed Mark-Dou closed 1 year ago

Mark-Dou commented 1 year ago

Thanks for your excellent work. When I execute

python attack.py -c configs/attacking/CelebA_FFHQ.yaml

`Traceback (most recent call last): File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/normalize.py", line 25, in wrapper return func(*args, **kwargs) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 880, in run self._runs[path] = Run(self.client, entity, project, run_id) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 1720, in init self.load(force=not _attrs) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 1824, in load raise ValueError("Could not find run %s" % self) ValueError: Could not find run <Run model_inversion_targets_facescrub/XXXXXXXXX/XXXXXXXXX (not found)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "attack.py", line 455, in main() File "attack.py", line 67, in main target_model = config.create_target_model() File "/data/users/zihanliu/hanyiwang/paper_code/MIAs/Plug-and-Play-Attacks/utils/attack_config_parser.py", line 26, in create_target_model model = load_model(self._config['wandb_target_run']) File "/data/users/zihanliu/hanyiwang/paper_code/MIAs/Plug-and-Play-Attacks/utils/wandb.py", line 21, in load_model run = api.run(run_path) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/normalize.py", line 65, in wrapper raise CommError(message, err).with_traceback(sys.exc_info()[2]) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/normalize.py", line 25, in wrapper return func(*args, **kwargs) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 880, in run self._runs[path] = Run(self.client, entity, project, run_id) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 1720, in init self.load(force=not _attrs) File "/data/users/zihanliu/lib/anaconda3/envs/torch/lib/python3.8/site-packages/wandb/apis/public.py", line 1824, in load raise ValueError("Could not find run %s" % self) wandb.errors.CommError: Could not find run <Run model_inversion_targets_facescrub/XXXXXXXXX/XXXXXXXXX (not found)>

` such errors raised. How can I solve this problem? Thank you~

LukasStruppek commented 1 year ago

Hi Mark-Dou,

the reason is that the config is missing a run path to a trained model on Weights & Biases. You first need to train your target (and an evaluation model) on your dataset. Simply follow the instructions at https://github.com/LukasStruppek/Plug-and-Play-Attacks#train-target-models. If you use WandB for logging, you can simply copy and paste the run paths of your trained models, replace the "XXXXXXXXX" in the configuration file and then you can run the attack. Alternatively, you can also provide a local path to your model weights, see the default_attacking_local.yaml file.

Best, Lukas

LukasStruppek commented 1 year ago

If you want to use the models from our paper, you can download them directly from GitHub under the ICML release. Then simply adjust the attack config for the local files.

Mark-Dou commented 1 year ago

Thanks a lot, Lukas! I have solved this problem according to your suggestions.

I followed all the instructions in README.md. When i run python attack.py -c configs/attacking/CelebA_FFHQ.yaml in the docker container,

Find initial style vector w: 0%| | 0/5000 [00:00<?, ?it/s] Traceback (most recent call last): File "attack.py", line 465, in main() File "attack.py", line 95, in main w, w_init, x, V = create_initial_vectors( File "attack.py", line 446, in create_initial_vectors w = config.create_candidates(G, target_model, targets).cpu() File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/utils/attack_config_parser.py", line 108, in create_candidates w = find_initial_w(generator=generator, File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/attacks/initial_selection.py", line 63, in find_initial_w imgs = generator.synthesis(w[0], File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1056, in _call_impl return forward_call(*input, kwargs) File "", line 463, in forward File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1056, in _call_impl return forward_call(*input, *kwargs) File "", line 390, in forward File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1056, in _call_impl return forward_call(input, kwargs) File "", line 291, in forward File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/stylegan2-ada-pytorch/torch_utils/misc.py", line 101, in decorator return fn(*args, *kwargs) File "", line 72, in modulated_conv2d File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/stylegan2-ada-pytorch/torch_utils/misc.py", line 101, in decorator return fn(args, **kwargs) File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/stylegan2-ada-pytorch/torch_utils/ops/conv2d_resample.py", line 147, in conv2d_resample return _conv2d_wrapper(x=x, w=w, padding=[py0,px0], groups=groups, flip_weight=flip_weight) File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/stylegan2-ada-pytorch/torch_utils/ops/conv2d_resample.py", line 54, in _conv2d_wrapper return op(x, w, stride=stride, padding=padding, groups=groups) File "/workspace/paper_code/MIA/Plug-and-Play-Attacks/stylegan2-ada-pytorch/torch_utils/ops/conv2d_gradfix.py", line 38, in conv2d return torch.nn.functional.conv2d(input=input, weight=weight, bias=bias, stride=stride, padding=padding, dilation=dilation, groups=groups) RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR

such errors appeared, I have no idea on the reason. Could you give me some suggestions? Thank you very much~

LukasStruppek commented 1 year ago

Hmm, that seems to be a problem with the CUDA version and StyleGAN2. I know that other people had also some problems with training a StyleGAN2 and the PyTorch version. You could try to downgrade PyTorch to 1.8.1. However, I just tested it with the provided Docker file and it worked without any problems. My PyTorch version is 1.10.0a0+3fd9dcf.

Maybe also have a look at the official StyleGAN2-Ada Repo and the issues there.