dydjw9 / MetaAttack_ICLR2020

45 stars 6 forks source link

Any suggestion for high resolution dataset experiments? #11

Open machanic opened 4 years ago

machanic commented 4 years ago

I recently experiment the code on the ImageNet dataset (224x224 resolution) in a Nvidia 1080Ti(11Gb) GPU. But it fails because the code of output = F.softmax(model(img_var), dim = 1) will consume too much GPU memory which is larger than 11Gb. https://github.com/dydjw9/MetaAttack_ICLR2020/blob/master/meta_attack/meta_attack_cifar/attacks/generate_gradient.py#L85

Because args.update_pixels = 128, which means a batch of 128 * 2 + 1= 257 224x224 images will be sent to victim model.

How to solve this issue and any suggestion about experimenting on large resolution data like ImageNet?

dydjw9 commented 4 years ago

Hi, could you try to feed the imgaes to models in small batches? And as I explained in the previous issue, you only need to query f(x+h) 128 and f(x) 1 = 129 times. That will reduce half of the batch size.

machanic commented 4 years ago

@dydjw9 Although I have modified the code to only feed batch_size images, 224x224 images will still consume the memory out of GPU limitation. I also tried split batch size of images into evenly partitioned small groups and sent to GPU, but still out of memory error. Why AFTER feed-forward that I have already got the output logits, the GPU memory still occupy some memory and does not release, I have already used torch.no_grad() but it does not work.

machanic commented 4 years ago

I have tried , I failed tested on ImageNet 224x224 images.