hcguoO0 / FIA

code for "Feature Importance-aware Transferable Adversarial Attacks"
77 stars 15 forks source link

Hi, it seems that attack.py cannot use GPU, could you please check related codes? #3

Closed ddghjikle closed 3 years ago

hcguoO0 commented 3 years ago

Can you show the error message?

ddghjikle commented 3 years ago

According to my experimental results, there are no error message. It seems that all codes are successfully run on CPU rather than the 0 GPU, which is set as the default device.

hcguoO0 commented 3 years ago

how long do you run attack.py for all 1000 images?

ddghjikle commented 3 years ago

Before these codes generating images, the latest log is generated in 2021-08-18 09:31:27. Therefore, it seems that about 10 hours are taken to generate adversarial images of FIAPIDIM.

ddghjikle commented 3 years ago

To be more clear, during running these codes, i often see my platform information by using nvidia-smi and top -u. I am sure that attack.py did not use GPU devices,

hcguoO0 commented 3 years ago

Can you show some log messages?

ddghjikle commented 3 years ago

Below are some messages during generating images of FIAPIDIM.

WARNING:tensorflow:From attack.py:267: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

W0818 09:31:27.775135 139927571894464 deprecation_wrapper.py:119] From attack.py:267: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

WARNING:tensorflow:From attack.py:268: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0818 09:31:27.818869 139927571894464 deprecation_wrapper.py:119] From attack.py:268: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2021-08-18 09:31:27.819423: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2021-08-18 09:31:27.860271: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2199885000 Hz 2021-08-18 09:31:27.865803: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55a10eda83c0 executing computations on platform Host. Devices: 2021-08-18 09:31:27.865847: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): , WARNING:tensorflow:From /home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/training/saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. W0818 09:31:27.871428 139927571894464 deprecation.py:323] From /home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/training/saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. INFO:tensorflow:Restoring parameters from ./models_tf/vgg_16.ckpt I0818 09:31:27.874672 139927571894464 saver.py:1280] Restoring parameters from ./models_tf/vgg_16.ckpt 2021-08-18 09:31:27.953310: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile. Generating: 100 Generating: 200 Generating: 300 Generating: 400 Generating: 500 Generating: 600 Generating: 700 Generating: 800 Generating: 900 Generating: 1000

ddghjikle commented 3 years ago

During running the verify.py, here presents an error: Traceback (most recent call last): File "verify.py", line 101, in main(args.ori_path,args.adv_path,args.output_file) File "verify.py", line 80, in main ori_pre,adv_pre,ground_truth=verify(model_name,ori_path,adv_path) File "verify.py", line 42, in verify saver.restore(sess,checkpoint_path) File "/home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1276, in restore if not checkpoint_management.checkpoint_exists(compat.as_text(save_path)): File "/home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func return func(*args, **kwargs) File "/home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_management.py", line 372, in checkpoint_exists if file_io.get_matching_files(pathname): File "/home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 363, in get_matching_files return get_matching_files_v2(filename) File "/home/jrh/yes/envs/py36-torch19/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 384, in get_matching_files_v2 compat.as_bytes(pattern)) tensorflow.python.framework.errors_impl.NotFoundError: ./models_tf/resnet_v2_50; No such file or directory

For addressing this error, i downloaded pre-trained resnet_v2_50_2017_04_14.tar from the shared url and placed them in the models_tf folder. However, the above error still remains.

hcguoO0 commented 3 years ago

I am sure the code can use GPU, at least in my platform. Can you check again your GPU whether is available and there is no other python procedure running on this GPU?

hcguoO0 commented 3 years ago

As for the verify.py, the right file path should be: ./models_tf/resnet_v2_50/(eval.graph、resnet_v2_50.ckpt、train.graph)

ddghjikle commented 3 years ago

OK, thanks very much. Is that mean each pre-trained model should be placed in separate folders? I directly uncompressed all files in the models_tf folder.

hcguoO0 commented 3 years ago

If there are more checkpoint files for one model, you should place them in separate folders, and if there is only one checkpoint file for one model, just place it in ./models_tf/.

ddghjikle commented 3 years ago

Thanks very much for your help. Best regards.

发自我的iPhone

------------------ Original ------------------ From: Hengchang Guo @.> Date: Thu,Aug 19,2021 9:48 AM To: hcguoO0/FIA @.> Cc: ddghjikle @.>, Author @.> Subject: Re: [hcguoO0/FIA] Hi, it seems that attack.py cannot use GPU, could you please check related codes? (#3)

Fengww2014 commented 3 years ago

Hi, I also found that it seems that attack.py cannot use GPU, could you please check related codes?