patrickjohncyh / fashion-clip

FashionCLIP is a CLIP-like model fine-tuned for the fashion domain.
MIT License
336 stars 37 forks source link

UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown #40

Open mehtaabGill opened 2 weeks ago

mehtaabGill commented 2 weeks ago

Recently ran into an issue while using fashion-clip on a non-cuda device (Apple M1 Mac).

Error:

/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/resource_tracker.py:254:
UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown

Steps to recreate:

run this script on a device without cuda available

from fashion_clip.fashion_clip import FashionCLIP

model = FashionCLIP("fashion-clip")

def embed_text(description):
    text_embedding = model.encode_text([description], 1).flatten().tolist()
    return text_embedding

embed_text("Black Dress")

Expected result:

Successful embedding

Current result:

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
  warnings.warn(
Map: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 142.35 examples/s]
  0%|                                                                                                                                              | 0/1 [00:00<?, ?it/s]Bus error: 10
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

Additonal context:

This issue is relatively new (within the last 6-7 days). I have had this script working for several weeks but when I went to run it a few days ago, I noticed it took extra long to start (perhaps downloading new resources), and I haven't been able to get it to work since then. Additionally, the script works flawlessly on my Windows PC with cuda available.

mehtaabGill commented 1 week ago

Update:

Downgrading to torch==1.11.0 and numpy<2 resolves this issue.