mlfoundations / open_clip

An open source implementation of CLIP.
Other
9.29k stars 923 forks source link

Issue with --lock-text Parameter in Bash Script #805

Open Lylinnnnn opened 5 months ago

Lylinnnnn commented 5 months ago

Hello,

I am encountering an issue with the --lock-text parameter in my bash script. Below is the script I am using:

export CUDA_VISIBLE_DEVICES=0,1

torchrun --nproc_per_node 2 -m training.main \
    --save-frequency 2 \
    --train-data "medium_train_output_0104.csv" \
    --val-data "medium_test_output_0104.csv" \
    --pretrained "open_clip/open_clip_pytorch_model_b_32.bin" \
    --dataset-type "csv" \
    --batch-size 512 \
    --workers 8 \
    --lr 2e-4 \
    --wd 0.01 \
    --epochs 31 \
    --warmup 500 \
    --model ViT-B-32 \
    --force-image-size 224 \
    --report-to "tensorboard" \
    --log-every-n-steps 500 \
    --lr-scheduler const \
    --lock-text \
    --lock-image \
    --lock-image-unlocked-groups 6 \
    --lock-image-freeze-bn-stats

However, when I run this script, I encounter the following error:

2024-01-26,08:22:52 | INFO | Running in distributed mode with multiple processes. Device: cuda:1.Process (global: 1, local 1), total 2.
2024-01-26,08:22:52 | INFO | Loaded ViT-B-32 model config.
2024-01-26,08:22:52 | INFO | Running in distributed mode with multiple processes. Device: cuda:0.Process (global: 0, local 0), total 2.
2024-01-26,08:22:52 | INFO | Loaded ViT-B-32 model config.
2024-01-26,08:22:53 | INFO | Loading pretrained ViT-B-32 weights (/home/radiance/open_clip/open_clip_pytorch_model_b_32.bin).
2024-01-26,08:22:53 | INFO | Loading pretrained ViT-B-32 weights (/home/radiance/open_clip/open_clip_pytorch_model_b_32.bin).
Traceback (most recent call last):
  File "/home/radiance/.conda/envs/jarvis/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/radiance/.conda/envs/jarvis/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/radiance/open_clip/src/training/main.py", line 542, in <module>
    main(sys.argv[1:])
  File "/home/radiance/open_clip/src/training/main.py", line 297, in main
    model.lock_text_tower(
  File "/home/radiance/.conda/envs/jarvis/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1614, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'CLIP' object has no attribute 'lock_text_tower'

I am not sure why the lock_image parameter is causing this issue. Could you please give me a help?

Lylinnnnn commented 5 months ago

Additionally, the --lock-image parameter is functioning normally.

rwightman commented 5 months ago

The issue is with --lock-text you mean? text locking needs support for the base model, see #523 ... that issue is almost working but think it needs a few changes, nobody has had the time to dig in

Lylinnnnn commented 5 months ago

Sorry for the confusion, I got it wrong earlier. I meant to refer to the issue with lock text. Thank you for your advice.