unslothai / unsloth

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

Error when execute from unsloth import FastLanguageModel #536

Closed EnchantedAI closed 5 months ago

EnchantedAI commented 5 months ago

when execute “from unsloth import FastLanguageModel” Runtime error:Failed to import transformers.integrations.peft because of the following error (look up to see its traceback): module 'torch._functorch.eager_transforms' has no attribute 'grad_and_value' All error description:

AttributeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name) 1535 return importlib.import_module("." + module_name, self.name) 1536 except Exception as e: -> 1537 raise RuntimeError( 1538 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its" 1539 f" traceback):\n{e}"

RuntimeError: Failed to import transformers.integrations.peft because of the following error (look up to see its traceback): module 'torch._functorch.eager_transforms' has no attribute 'grad_and_value'

EnchantedAI commented 5 months ago

version is not compatible

danielhanchen commented 5 months ago

So resolved?

OsenLiu commented 5 months ago

I resolve it by uninstalling torch and installing torce 2.2.1 in colab. !pip3 uninstall --yes torch torchaudio torchvision torchtext torchdata !pip install torch==2.2.1 torchaudio torchvision torchtext torchdata

EnchantedAI commented 5 months ago

So resolved?

Yes,colab seems to have a wrong pytorch version, I resolved it by reinstalling torch 2.2.1

danielhanchen commented 5 months ago

Wait for torch 2.3, use the new method:

%%capture
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --no-deps xformers trl peft accelerate bitsandbytes