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.56k stars 1.3k forks source link

GETTING ERROR WHILE RUNNING A KAGGLE NOTEBOOK #1335

Open MuhammadBilal848 opened 20 hours ago

MuhammadBilal848 commented 20 hours ago

I am trying to run a mistral 22B model on kaggle but getting this error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[7], line 1
----> 1 from unsloth import FastLanguageModel
      2 import torch
      3 max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!

File /opt/conda/lib/python3.10/site-packages/unsloth/__init__.py:76
     71     raise ImportError(
     72         "Unsloth: Pytorch is not installed. Go to [https://pytorch.org/.\n](https://pytorch.org/n)"\
     73         "We have some installation instructions on our Github page."
     74     )
     75 except Exception as exception:
---> 76     raise exception
     77 pass
     79 # We support Pytorch 2
     80 # Fixes https://github.com/unslothai/unsloth/issues/38

File /opt/conda/lib/python3.10/site-packages/unsloth/__init__.py:69
     66 os.environ["UNSLOTH_IS_PRESENT"] = "1"
     68 try:
---> 69     import torch
     70 except ModuleNotFoundError:
     71     raise ImportError(
     72         "Unsloth: Pytorch is not installed. Go to [https://pytorch.org/.\n](https://pytorch.org/n)"\
     73         "We have some installation instructions on our Github page."
     74     )

File /opt/conda/lib/python3.10/site-packages/torch/__init__.py:367
    365     if USE_GLOBAL_DEPS:
    366         _load_global_deps()
--> 367     from torch._C import *  # noqa: F403
    370 class SymInt:
    371     """
    372     Like an int (including magic methods), but redirects all operations on the
    373     wrapped node. This is used in particular to symbolically record operations
    374     in the symbolic shape workflow.
    375     """

ImportError: /opt/conda/lib/python3.10/site-packages/torch/lib/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkComplete_12_4, version libnvJitLink.so.12
Cirr0e commented 19 hours ago

Hi there! I understand you're running into an import error with unsloth while trying to run a Mistral 22B model on Kaggle. I can help you resolve this.

The error you're encountering is actually a known issue that has been fixed in the latest version of unsloth. From looking at similar reported issues, this is related to library import order and version compatibility.

Here's how to fix it:

  1. First, uninstall the current version of unsloth:

    pip uninstall unsloth -y
  2. Then install the latest version with this command:

    pip install --upgrade --force-reinstall --no-cache-dir git+https://github.com/unslothai/unsloth.git

This solution comes from one of the unsloth maintainers who confirmed this fixes the symbol loading issue you're experiencing.

The root cause was related to how bitsandbytes was being imported, and this has been addressed in the latest version of the library. The update removes the problematic import check that was causing the conflict.

If you're still experiencing issues after this update, please let me know and I can help troubleshoot further.

References:

Let me know if you need any clarification or run into any other issues!

danielhanchen commented 15 hours ago

@MuhammadBilal848 Did you try using this specific installation cell:

%%capture
!pip install pip3-autoremove
!pip-autoremove torch torchvision torchaudio -y
!pip install torch torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu121
!pip install unsloth