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.4k stars 1.29k forks source link

import unsloth causes error: pip install unsloth-zoo #1252

Open DaddyCodesAlot opened 2 weeks ago

DaddyCodesAlot commented 2 weeks ago

Hi, running this code:

from unsloth import FastLanguageModel

I get this error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File /usr/local/lib/python3.10/dist-packages/unsloth/__init__.py:32
     31 try:
---> 32     import unsloth_zoo
     33 except:

File /usr/local/lib/python3.10/dist-packages/unsloth_zoo/__init__.py:27
     26 if not ("UNSLOTH_IS_PRESENT" in os.environ):
---> 27     raise ImportError("Please install Unsloth via `pip install unsloth`!")
     28 pass

ImportError: Please install Unsloth via `pip install unsloth`!

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Cell In[15], line 1
----> 1 from unsloth import FastLanguageModel
      2 import torch
      3 import gc

File /usr/local/lib/python3.10/dist-packages/unsloth/__init__.py:34
     32     import unsloth_zoo
     33 except:
---> 34     raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth-zoo`")
     35 pass
     37 # Unsloth currently does not work on multi GPU setups - sadly we are a 2 brother team so
     38 # enabling it will require much more work, so we have to prioritize. Please understand!
     39 # We do have a beta version, which you can contact us about!
     40 # Thank you for your understanding and we appreciate it immensely!

ImportError: Unsloth: Please install unsloth_zoo via `pip install unsloth-zoo`

Here's how I installed unsloth:

!pip install "unsloth[cu121] @ git+https://github.com/unslothai/unsloth.git@a2f8db3e7341f983af5814a2c56f54fa29ee548d"

DaddyCodesAlot commented 2 weeks ago

Interesting, importing unsloth-zoo causes this issue::

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[5], line 1
----> 1 import unsloth_zoo

File /usr/local/lib/python3.10/dist-packages/unsloth_zoo/__init__.py:27
     25 import os
     26 if not ("UNSLOTH_IS_PRESENT" in os.environ):
---> 27     raise ImportError("Please install Unsloth via `pip install unsloth`!")
     28 pass
     30 try:

ImportError: Please install Unsloth via `pip install unsloth`!

Despite both packages being installed.

MrAnayDongre commented 2 weeks ago

I can confirm that I have successfully recreated the bug. The issue persists even when both 'unsloth' and 'unsloth-zoo' are installed.

Try manually setting if that helps:

os.environ["UNSLOTH_IS_PRESENT"] = "1"

arianyambao commented 2 weeks ago

I can confirm that I have successfully recreated the bug. The issue persists even when both 'unsloth' and 'unsloth-zoo' are installed.

Try manually setting if that helps:

os.environ["UNSLOTH_IS_PRESENT"] = "1"

Thank you.

danielhanchen commented 1 week ago

I'll add a fix - apologies on the issue!

DaddyCodesAlot commented 1 week ago

I can confirm that I have successfully recreated the bug. The issue persists even when both 'unsloth' and 'unsloth-zoo' are installed.

Try manually setting if that helps:

os.environ["UNSLOTH_IS_PRESENT"] = "1"

Thank you, this fixed it!