unslothai / unsloth

Finetune Llama 3.2, Mistral, Phi, Qwen 2.5 & Gemma LLMs 2-5x faster with 80% less memory
https://unsloth.ai
Apache License 2.0
18.5k stars 1.3k forks source link

Running into this issue randomly: `ImportError: Unsloth: Cannot import unsloth_compiled_cache/Conv3d.py` #1328

Open saum7800 opened 1 day ago

saum7800 commented 1 day ago

Randomly running into this error on an A100 SXM4 80GB, wonder if you have faced it and whether I am doing something wrong.

Screenshot 2024-11-22 at 12 41 58 PM

Above is my GPU setup

File "/root/src/battle_ax/models/multimodal_model/train_model.py", line 115, in train_model_task_impl
    model, tokenizer = FastVisionModel.from_pretrained(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/unsloth/models/loader.py", line 364, in from_pretrained
    model_types = unsloth_compile_transformers(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/unsloth/models/_utils.py", line 1140, in unsloth_compile_transformers
    _unsloth_compile_transformers(
  File "/usr/local/lib/python3.11/site-packages/unsloth_zoo/compiler.py", line 1117, in unsloth_compile_transformers
    forward = create_new_function(
              ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/unsloth_zoo/compiler.py", line 246, in create_new_function
    raise ImportError(f"Unsloth: Cannot import {location}")
ImportError: Unsloth: Cannot import unsloth_compiled_cache/Conv3d.py

sometimes the same error is for rms_norm, sometimes for conv2d, and sometimes it just works. any idea if I might have done something wrong?

bird010 commented 1 day ago

Similar issue happens while calling

model, tokenizer = FastVisionModel.from_pretrained(
    "unsloth/Llama-3.2-11B-Vision-Instruct",
    load_in_4bit = True, # Use 4bit to reduce memory use. False for 16bit LoRA.
    use_gradient_checkpointing = "unsloth", # True or "unsloth" for long context
)

Error msg: Unsloth: Cannot import unsloth_compiled_cache/Conv1d.py

Already upgraded unsloth

unsloth 2024.11.9 pypi_0 pypi unsloth-zoo 2024.11.7 pypi_0 pypi torch 2.5.1+cu121 pypi_0 pypi torchvision 0.20.1+cu121 pypi_0 pypi

bird010 commented 1 day ago

Similar issue happens while calling

model, tokenizer = FastVisionModel.from_pretrained(
    "unsloth/Llama-3.2-11B-Vision-Instruct",
    load_in_4bit = True, # Use 4bit to reduce memory use. False for 16bit LoRA.
    use_gradient_checkpointing = "unsloth", # True or "unsloth" for long context
)

Error msg: Unsloth: Cannot import unsloth_compiled_cache/Conv1d.py

Already upgraded unsloth

unsloth 2024.11.9 pypi_0 pypi unsloth-zoo 2024.11.7 pypi_0 pypi torch 2.5.1+cu121 pypi_0 pypi torchvision 0.20.1+cu121 pypi_0 pypi

I guess I fixed it temporarily. I'm debugging the python file using Cursor / VS, and the python file is not under the root directory of the working space. unsloth_compiled_cache folder is created automatically under the root directory of working space while calling FastVisionModel.from_pretrained( ). Create a soft link in the same directory of the python file, pointing to unsloth_compiled_cache folder fixed this issue.