- Open
exp_config_template.pyand replace allTODO: placeholderswith the appropriate file paths for your local environment. - Edit
search/search_space.pyand set theCACHE_DIRvariable to the directory where you want to store the OpenCLIP model weights. - Modify
generate_exp_configs.pyto toggle between evaluation and attacker configurations by commenting or uncommenting lines marked with#. - Run
generate_exp_configs.pyto generate the final configuration files.
- An example configuration is available in l_inf_pgd_12.
Our default implementation uses PyTorch Distributed Data Parallel (DDP) in a SLURM environment. The hyperparameter k—which determines the number of surrogate models selected per iteration—is controlled via the WORLD_SIZE environment variable. By default, the implementation loads exactly one model per GPU (i.e., per rank).
export MASTER_PORT={Port}
export "WORLD_SIZE="$SLURM_NTASKS
echo "WORLD_SIZE="$WORLD_SIZE
master_addr=$(scontrol show hostnames "$SLURM_JOB_NODELIST" | head -n 1)
export MASTER_ADDR=$master_addr
export LOCAL_RANK=$SLURM_LOCALID
echo "MASTER_ADDR="$MASTER_ADDR
export OMP_NUM_THREADS=$SLURM_CPUS_ON_NODE
srun python3 generate_universal_perturbation.py --ddp --dist_eval \
--exp_name Which Attacker to use e.g. l_inf_pgd_12 \
--exp_path PATH/TO/EXP_FILE_FOLDER \
--exp_config PATH/TO/CONFIG/FOLDER