Skip to content

[FIXED] Kaggle notebook: No module named 'unsloth' #566

Closed

Description

@avcode-exe

image
I got the error in kaggle notebook, here is how I install unsloth:
image

Activity

  1. Tharun-swi commented on May 31, 2024

    @Tharun-swi

    More information about this ERROR:

    Collecting shtab>=1.5.6 (from tyro->unsloth@ git+https://github.com/unslothai/unsloth.git->unsloth[kaggle-new]@ git+https://github.com/unslothai/unsloth.git)
    Downloading shtab-1.7.1-py3-none-any.whl.metadata (7.3 kB)
    ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/opt/conda/lib/python3.10/site-packages/aiohttp-3.9.1.dist-info/METADATA'

  2. atishay2411 commented on May 31, 2024

    @atishay2411

    I encountered the same error. It was functioning correctly until last week, but when I attempted install it on the kaggle notebook today, the error occured.

    Screenshot 2024-05-31 at 3 41 09 PM
  3. danielhanchen commented on May 31, 2024

    @danielhanchen
    Member

    Oh yep sorry everyone!!! Working on a fix! Sorry again!

  4. MRQJsfhf commented on Jun 1, 2024

    @MRQJsfhf

    I also encountered the following:---------------------------------------------------------------------------
    ModuleNotFoundError 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!

    ModuleNotFoundError: No module named 'unsloth'

  5. MRQJsfhf commented on Jun 1, 2024

    @MRQJsfhf

    And there are also cases where there is no "xformers" module.

  6. danielhanchen commented on Jun 1, 2024

    @danielhanchen
    Member

    @atishay2411 @avcode-exe @Tharun-swi @MRQJsfhf Just fixed it!
    Please use the latest Kaggle notebooks:

    Mistral 7b: https://www.kaggle.com/code/danielhanchen/kaggle-mistral-7b-unsloth-notebook
    Llama-3 8b: https://www.kaggle.com/code/danielhanchen/kaggle-llama-3-8b-unsloth-notebook

    The Gemma and a nw Phi-3 Medium are still running:
    Gemma 7b: https://www.kaggle.com/code/danielhanchen/kaggle-gemma-7b-unsloth-notebook/

    To edit notebooks manually, please edit the install cell from

    %%capture
    !pip install -U "xformers<0.0.26" --index-url https://download.pytorch.org/whl/cu121
    !pip install "unsloth[kaggle-new] @ git+https://github.com/unslothai/unsloth.git"
    
    # Temporary fix for https://github.com/huggingface/datasets/issues/6753
    !pip install datasets==2.16.0 fsspec==2023.10.0 gcsfs==2023.10.0
    
    import os
    os.environ["WANDB_DISABLED"] = "true"

    to

    %%capture
    !mamba install --force-reinstall aiohttp -y
    !pip install -U "xformers<0.0.26" --index-url https://download.pytorch.org/whl/cu121
    !pip install "unsloth[kaggle-new] @ git+https://github.com/unslothai/unsloth.git"
    
    # Temporary fix for https://github.com/huggingface/datasets/issues/6753
    !pip install datasets==2.16.0 fsspec==2023.10.0 gcsfs==2023.10.0
    
    import os
    os.environ["WANDB_DISABLED"] = "true"

    ie put !mamba install --force-reinstall aiohttp -y at the top of the install cell.

  7. added
    fixed - pending confirmation
    and removed
    currently fixing
    on Jun 1, 2024
  8. jamessucla commented on Jun 1, 2024

    @jamessucla

    Works for me now. Thanks for the quick fix!

  9. atishay2411 commented on Jun 1, 2024

    @atishay2411

    The version 4 works perfectly fine for me as well, thanks for the quick turnaround @danielhanchen !!

  10. changed the title [-]Kaggle notebook: No module named 'unsloth'[/-] [+][FIXED] Kaggle notebook: No module named 'unsloth'[/+] on Jun 1, 2024
  11. avcode-exe commented on Jun 1, 2024

    @avcode-exe
    Author

    Works for me too! Thx!

  12. a442509097 commented on Jun 2, 2024

    @a442509097
    Unsloth: Will use up to 20.49 out of 31.36 RAM for saving.
      0%|          | 0/32 [00:00<?, ?it/s]
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:629, in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization, _disable_byteorder_record)
        628 with _open_zipfile_writer(f) as opened_zipfile:
    --> 629     _save(obj, opened_zipfile, pickle_module, pickle_protocol, _disable_byteorder_record)
        630     return
    
    File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:863, in _save(obj, zip_file, pickle_module, pickle_protocol, _disable_byteorder_record)
        862 num_bytes = storage.nbytes()
    --> 863 zip_file.write_record(name, storage.data_ptr(), num_bytes)
    
    RuntimeError: [enforce fail at inline_container.cc:764] . PytorchStreamWriter failed writing file data/51: file write failed
    
    During handling of the above exception, another exception occurred:
    
    RuntimeError                              Traceback (most recent call last)
    File /opt/conda/lib/python3.10/site-packages/unsloth/save.py:1367, in unsloth_save_pretrained_gguf(self, save_directory, tokenizer, quantization_method, first_conversion, push_to_hub, token, private, is_main_process, state_dict, save_function, max_shard_size, safe_serialization, variant, save_peft_format, tags, temporary_location, maximum_memory_usage)
       1366 try:
    -> 1367     new_save_directory, old_username = unsloth_save_model(**arguments)
       1368     makefile = None
    
    

    Capture

    In GGUF / llama.cpp

  13. danielhanchen commented on Jun 2, 2024

    @danielhanchen
    Member

    Hmm I think Kaggle is notorious for breaking llama.cpp saves because Kaggle only has 20GB of disk space. My suggestion is to save the LoRA adapters, then use Colab which has like 80GB Disk space to convert to GGUF

  14. avcode-exe commented on Jun 2, 2024

    @avcode-exe
    Author
    Unsloth: Will use up to 20.49 out of 31.36 RAM for saving.
      0%|          | 0/32 [00:00<?, ?it/s]
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:629, in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization, _disable_byteorder_record)
        628 with _open_zipfile_writer(f) as opened_zipfile:
    --> 629     _save(obj, opened_zipfile, pickle_module, pickle_protocol, _disable_byteorder_record)
        630     return
    
    File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:863, in _save(obj, zip_file, pickle_module, pickle_protocol, _disable_byteorder_record)
        862 num_bytes = storage.nbytes()
    --> 863 zip_file.write_record(name, storage.data_ptr(), num_bytes)
    
    RuntimeError: [enforce fail at inline_container.cc:764] . PytorchStreamWriter failed writing file data/51: file write failed
    
    During handling of the above exception, another exception occurred:
    
    RuntimeError                              Traceback (most recent call last)
    File /opt/conda/lib/python3.10/site-packages/unsloth/save.py:1367, in unsloth_save_pretrained_gguf(self, save_directory, tokenizer, quantization_method, first_conversion, push_to_hub, token, private, is_main_process, state_dict, save_function, max_shard_size, safe_serialization, variant, save_peft_format, tags, temporary_location, maximum_memory_usage)
       1366 try:
    -> 1367     new_save_directory, old_username = unsloth_save_model(**arguments)
       1368     makefile = None
    
    

    Capture

    In GGUF / llama.cpp

    You can try to push the full model to HF by saving it under a different directory other then /kaggle/output, then use "gguf_converter" space on HF by GGML to convert to gguf.

  15. unpinned this issue on Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    URGENT BUGfixed - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions