Skip to content

ImportError: Unsloth: CUDA is not linked properly. #221

Closed

Description

@athoag-sony

I followed the conda installation instructions in the README:

conda create --name unsloth_env python=3.10
conda activate unsloth_env

conda install pytorch cudatoolkit torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

conda install xformers -c xformers

pip install bitsandbytes

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

There were no issues during the install. However, when I try to import from unsloth, I get an error.

from unsloth import FastLanguageModel

Results in an error:

/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/bitsandbytes/cextension.py:34: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable.
  warn("The installed version of bitsandbytes was compiled without GPU support. "
/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cadam32bit_grad_fp32
/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/unsloth/__init__.py:71: UserWarning: Unsloth: Running `ldconfig /usr/lib64-nvidia` to link CUDA.
  warnings.warn(
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
Traceback (most recent call last):
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/unsloth/__init__.py", line 68, in <module>
    cdequantize_blockwise_fp32 = bnb.functional.lib.cdequantize_blockwise_fp32
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cdequantize_blockwise_fp32

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/unsloth/__init__.py", line 99, in <module>
    cdequantize_blockwise_fp32 = bnb.functional.lib.cdequantize_blockwise_fp32
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cdequantize_blockwise_fp32

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/miniconda/envs/unsloth_env/lib/python3.10/site-packages/unsloth/__init__.py", line 102, in <module>
    raise ImportError("Unsloth: CUDA is not linked properly.\n"\
ImportError: Unsloth: CUDA is not linked properly.
We tried running `ldconfig /usr/lib64-nvidia` ourselves, but it didn't work.
You need to run in your terminal `sudo ldconfig /usr/lib64-nvidia` yourself, then import Unsloth.
Also try `sudo ldconfig /usr/local/cuda-xx.x` - find the latest cuda version.

I looked for both /usr/lib64-nvidia and files matching /usr/local/cuda-* but found none.

I have the NVIDIA driver installed fine for cuda=12.2. Here is the output of my nvidia-smi command:

Tue Mar  5 01:23:41 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.161.07             Driver Version: 535.161.07   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  Tesla T4                       Off | 00000000:00:1B.0 Off |                    0 |
| N/A   27C    P0              24W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   1  Tesla T4                       Off | 00000000:00:1C.0 Off |                    0 |
| N/A   27C    P0              25W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   2  Tesla T4                       Off | 00000000:00:1D.0 Off |                    0 |
| N/A   27C    P0              24W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   3  Tesla T4                       Off | 00000000:00:1E.0 Off |                    0 |
| N/A   28C    P0              25W /  70W |      2MiB / 15360MiB |      6%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

I'm running Ubuntu 22.04.3 on an AWS EC2 g4dn.12xlarge which has T4 GPUs.

Activity

  1. danielhanchen commented on Mar 5, 2024

    @danielhanchen
    Member

    Sorry on the issue :(

    There is another way to install it if this works (Also first check if mamba works in the terminal, since it makes installing faster by reducing solving time :))

    conda create --name unsloth_env python=3.10
    conda activate unsloth_env
    
    conda install pytorch cudatoolkit torchvision torchaudio pytorch-cuda=12.1 bitsandbytes -c pytorch -c nvidia -c conda-forge
    
    conda install xformers -c xformers
    
    pip install "unsloth[conda] @ git+https://github.com/unslothai/unsloth.git"
    

    If that doesn't work, also try folding in xformers:

    conda create --name unsloth_env python=3.10
    conda activate unsloth_env
    
    conda install pytorch cudatoolkit torchvision torchaudio xformers pytorch-cuda=12.1 bitsandbytes -c pytorch -c nvidia -c conda-forge -c xformers
    
    pip install "unsloth[conda] @ git+https://github.com/unslothai/unsloth.git"
    
  2. athoag-sony commented on Mar 5, 2024

    @athoag-sony
    Author

    Hi, thanks for the response. The first suggestion did not work. The second did at least change the error:

    >>> from unsloth import FastLanguageModel
    False
    
    ===================================BUG REPORT===================================
    /home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:167: UserWarning: Welcome to bitsandbytes. For bug reports, please run
    
    python -m bitsandbytes
    
    
      warn(msg)
    ================================================================================
    /home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:167: UserWarning: Found duplicate ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] files: {PosixPath('/home/ubuntu/miniconda/envs/unsloth-test/lib/libcudart.so'), PosixPath('/home/ubuntu/miniconda/envs/unsloth-test/lib/libcudart.so.11.0')}.. We select the PyTorch default libcudart.so, which is {torch.version.cuda},but this might missmatch with the CUDA version that is needed for bitsandbytes.To override this behavior set the BNB_CUDA_VERSION=<version string, e.g. 122> environmental variableFor example, if you want to use the CUDA version 122BNB_CUDA_VERSION=122 python ...OR set the environmental variable in your .bashrc: export BNB_CUDA_VERSION=122In the case of a manual override, make sure you set the LD_LIBRARY_PATH, e.g.export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.2
      warn(msg)
    /home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:167: UserWarning: /home/ubuntu/miniconda/envs/unsloth-test did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...
      warn(msg)
    CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths...
    The following directories listed in your path were found to be non-existent: {PosixPath('/usr/local/cuda/lib64')}
    DEBUG: Possible options found for libcudart.so: set()
    CUDA SETUP: PyTorch settings found: CUDA_VERSION=121, Highest Compute Capability: 7.5.
    CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
    CUDA SETUP: Required library version not found: libbitsandbytes_cuda121.so. Maybe you need to compile it from source?
    CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...
    
    ================================================ERROR=====================================
    CUDA SETUP: CUDA detection failed! Possible reasons:
    1. You need to manually override the PyTorch CUDA version. Please see: "https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
    2. CUDA driver not installed
    3. CUDA not installed
    4. You have multiple conflicting CUDA libraries
    5. Required library not pre-compiled for this bitsandbytes release!
    CUDA SETUP: If you compiled from source, try again with `make CUDA_VERSION=DETECTED_CUDA_VERSION` for example, `make CUDA_VERSION=113`.
    CUDA SETUP: The CUDA version for the compile might depend on your conda install. Inspect CUDA version via `conda list | grep cuda`.
    ================================================================================
    
    CUDA SETUP: Problem: The main issue seems to be that the main CUDA runtime library was not detected.
    CUDA SETUP: Solution 1: To solve the issue the libcudart.so location needs to be added to the LD_LIBRARY_PATH variable
    CUDA SETUP: Solution 1a): Find the cuda runtime library via: find / -name libcudart.so 2>/dev/null
    CUDA SETUP: Solution 1b): Once the library is found add it to the LD_LIBRARY_PATH: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:FOUND_PATH_FROM_1a
    CUDA SETUP: Solution 1c): For a permanent solution add the export from 1b into your .bashrc file, located at ~/.bashrc
    CUDA SETUP: Solution 2: If no library was found in step 1a) you need to install CUDA.
    CUDA SETUP: Solution 2a): Download CUDA install script: wget https://raw.githubusercontent.com/TimDettmers/bitsandbytes/main/cuda_install.sh
    CUDA SETUP: Solution 2b): Install desired CUDA version to desired location. The syntax is bash cuda_install.sh CUDA_VERSION PATH_TO_INSTALL_INTO.
    CUDA SETUP: Solution 2b): For example, "bash cuda_install.sh 113 ~/local/" will download CUDA 11.3 and install into the folder ~/local
    CUDA SETUP: Setup Failed!
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/unsloth/__init__.py", line 59, in <module>
        import bitsandbytes as bnb
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/__init__.py", line 6, in <module>
        from . import cuda_setup, utils, research
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/research/__init__.py", line 1, in <module>
        from . import nn
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/research/nn/__init__.py", line 1, in <module>
        from .modules import LinearFP8Mixed, LinearFP8Global
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/research/nn/modules.py", line 8, in <module>
        from bitsandbytes.optim import GlobalOptimManager
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/optim/__init__.py", line 6, in <module>
        from bitsandbytes.cextension import COMPILED_WITH_CUDA
      File "/home/ubuntu/miniconda/envs/unsloth-test/lib/python3.10/site-packages/bitsandbytes/cextension.py", line 20, in <module>
        raise RuntimeError('''
    RuntimeError: 
            CUDA Setup failed despite GPU being available. Please run the following command to get more information:
    
            python -m bitsandbytes
    
            Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
            to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
            and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

    I will look into this a bit more, but if you have seen this before and know what to do please let me know.

    I did notice that if installed xformers after pytorch-cuda, it changed my pytorch version to one that was not cuda-compatible:

    The following packages will be SUPERSEDED by a higher-priority channel:
    
      pytorch            pytorch::pytorch-2.2.1-py3.10_cuda12.~ --> pkgs/main::pytorch-2.2.0-cpu_py310hdc00b08_0
    

    But this seems to be solved by folding in the xformers installation into the conda install command as you suggested.

  3. j-d-salinger commented on Mar 5, 2024

    @j-d-salinger

    I have the same issue... This "folding-in" sort of worked for me... When I try to install it says 'no module name triton found'... If i run pip3 install triton, I get a linking error again

  4. danielhanchen commented on Mar 5, 2024

    @danielhanchen
    Member

    @j-d-salinger For triton - oh my there's no triton during the pytorch install? Maybe add an update flag to Conda.

    @athoag-sony Hmm bitsandbytes issues :( I might have to open a large thread in BnB - installing from source might be the only other option for now - I'll see what I can do

  5. j-d-salinger commented on Mar 5, 2024

    @j-d-salinger

    Thanks!! i was able to get a functional bitsandbytes by building from source. Or at least, i no longer get a warning that it was compiled iwthout GPU support.

    I thought that would solve it, but there is still an ldconfig error...

  6. athoag-sony commented on Mar 5, 2024

    @athoag-sony
    Author

    I was able to get bitsandbytes to import by using python=3.11 instead of python=3.10. However, now when I try to import from unsloth I get:

    >>> from unsloth import FastLanguageModel
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ubuntu/miniconda/envs/unsloth/lib/python3.11/site-packages/unsloth/__init__.py", line 60, in <module>
        import triton
    ModuleNotFoundError: No module named 'triton'

    Here are the steps to reproduce:

    conda create -n unsloth python=3.11 -y
    conda activate unsloth
    conda install pytorch cudatoolkit torchvision torchaudio xformers pytorch-cuda=12.1 bitsandbytes -c pytorch -c nvidia -c conda-forge -c xformers
    pip install "unsloth[conda] @ git+https://github.com/unslothai/unsloth.git"
    

    If I then try to install triton with conda:

    conda install triton -c pytorch -c nvidia -c conda-forge -c xformers
    

    I get a new error when I try to import from unsloth:

    >>> from unsloth import FastLanguageModel
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ubuntu/miniconda/envs/unsloth/lib/python3.11/site-packages/unsloth/__init__.py", line 61, in <module>
        from triton.common.build import libcuda_dirs
    ModuleNotFoundError: No module named 'triton.common'
  7. danielhanchen commented on Mar 6, 2024

    @danielhanchen
    Member

    @j-d-salinger Can you run python -m bitsandbytes and python -m xformers.info in a terminal and paste ur output here

    @athoag-sony Can you import triton manually and check its version by import triton; triton.__version__ It probably means thats an old version. Another approach is to use pip directly: pip install triton

    Again apologies on the install issues - sadly Triton and BnB can be quite annoying to install

  8. avacaondata commented on Mar 12, 2024

    @avacaondata

    I'm having a similar error; tried to use the steps above and install bitsandbytes from source but still:

    False
    /root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/bitsandbytes/cextension.py:31: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable.
      warn("The installed version of bitsandbytes was compiled without GPU support. "
    'NoneType' object has no attribute 'cadam32bit_grad_fp32'
    /root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/__init__.py:71: UserWarning: Unsloth: Running `ldconfig /usr/lib64-nvidia` to link CUDA.
      warnings.warn(
    /sbin/ldconfig.real: Can't link /usr/lib/wsl/lib/libnvoptix_loader.so.1 to libnvoptix.so.1
    /sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
    
    /root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/__init__.py:102: UserWarning: Unsloth: CUDA is not linked properly.
    Try running `python -m bitsandbytes` then `python -m xformers.info`
    We tried running `ldconfig /usr/lib64-nvidia` ourselves, but it didn't work.
    You need to run in your terminal `sudo ldconfig /usr/lib64-nvidia` yourself, then import Unsloth.
    Also try `sudo ldconfig /usr/local/cuda-xx.x` - find the latest cuda version.
    Unsloth will still run for now, but maybe it might crash - let's hope it works!
      warnings.warn(
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/__init__.py", line 112, in <module>
        from .models import *
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/models/__init__.py", line 15, in <module>
        from .loader import FastLanguageModel
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/models/loader.py", line 15, in <module>
        from .llama import FastLlamaModel, logger
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/models/llama.py", line 26, in <module>
        from ..kernels import *
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/kernels/__init__.py", line 15, in <module>
        from .cross_entropy_loss import fast_cross_entropy_loss
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/kernels/cross_entropy_loss.py", line 18, in <module>
        from .utils import calculate_settings, MAX_FUSED_SIZE
      File "/root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/unsloth/kernels/utils.py", line 36, in <module>
        cdequantize_blockwise_fp32      = bnb.functional.lib.cdequantize_blockwise_fp32
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'cdequantize_blockwise_fp32'
    

    @danielhanchen How can I install unsloth properly?

  9. avacaondata commented on Mar 12, 2024

    @avacaondata

    xformers info:

    xFormers 0.0.21
    memory_efficient_attention.cutlassF:               available
    memory_efficient_attention.cutlassB:               available
    memory_efficient_attention.decoderF:               available
    [email protected]:         unavailable
    [email protected]:         unavailable
    memory_efficient_attention.smallkF:                available
    memory_efficient_attention.smallkB:                available
    memory_efficient_attention.tritonflashattF:        unavailable
    memory_efficient_attention.tritonflashattB:        unavailable
    indexing.scaled_index_addF:                        available
    indexing.scaled_index_addB:                        available
    indexing.index_select:                             available
    swiglu.dual_gemm_silu:                             available
    swiglu.gemm_fused_operand_sum:                     available
    swiglu.fused.p.cpp:                                available
    is_triton_available:                               False
    is_functorch_available:                            False
    pytorch.version:                                   2.1.2.post101
    pytorch.cuda:                                      not available
    build.info:                                        available
    build.cuda_version:                                None
    build.python_version:                              3.11.6
    build.torch_version:                               2.1.0.post100
    build.env.TORCH_CUDA_ARCH_LIST:                    None
    build.env.XFORMERS_BUILD_TYPE:                     None
    build.env.XFORMERS_ENABLE_DEBUG_ASSERTIONS:        None
    build.env.NVCC_FLAGS:                              None
    build.env.XFORMERS_PACKAGE_FROM:                   None
    source.privacy:                                    open source
    

    output of bitsandbytes:

    /root/miniconda3/envs/chatnatural/lib/python3.11/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cadam32bit_grad_fp32
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++ BUG REPORT INFORMATION ++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    +++++++++++++++++++ ANACONDA CUDA PATHS ++++++++++++++++++++
    ['/root/miniconda3/envs/chatnatural/lib/libomptarget.rtl.cuda.so', '/root/miniconda3/envs/chatnatural/lib/libcudart.so']
    
    ++++++++++++++++++ /usr/local CUDA PATHS +++++++++++++++++++
    []
    
    +++++++++++++++ WORKING DIRECTORY CUDA PATHS +++++++++++++++
    []
    
    ++++++++++++++++++++++++++ OTHER +++++++++++++++++++++++++++
    COMPILED_WITH_CUDA = False
    COMPUTE_CAPABILITIES_PER_GPU = []
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ DEBUG INFO END ++++++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Checking that the library is importable and CUDA is callable...
    
    WARNING: Please be sure to sanitize sensitive info from any such env vars!
    
    Torch not compiled with CUDA enabled
    
    Above we output some debug information. Please provide this info when creating an issue via https://github.com/TimDettmers/bitsandbytes/issues/new/choose ...
    
  10. danielhanchen commented on Mar 12, 2024

    @danielhanchen
    Member

    @avacaondata Hmm there is another approach which might or might not work:

    pip install -U xformers --index-url https://download.pytorch.org/whl/cu121
    pip install "unsloth[kaggle-new] @ git+https://github.com/unslothai/unsloth.git@nightly"
    

    This is a nightly build so I'm still working on it - it might or might not work.

  11. avacaondata commented on Mar 12, 2024

    @avacaondata

    Ok thanks @danielhanchen that seems to solve the past issue, but now I have another one, I think related to triton:

    Traceback (most recent call last):
      File "/mnt/c/Users/Usuario/Documents/autolms/src/autotransformers/autotrainer.py", line 171, in train_with_fixed_params
        test_results = self.train_one_model_fixed_params(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/mnt/c/Users/Usuario/Documents/autolms/src/autotransformers/autotrainer.py", line 302, in train_one_model_fixed_params
        self.trainer.train()
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/transformers/trainer.py", line 1624, in train
        return inner_training_loop(
               ^^^^^^^^^^^^^^^^^^^^
      File "<string>", line 354, in _fast_inner_training_loop
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/transformers/trainer.py", line 2902, in training_step
        loss = self.compute_loss(model, inputs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/transformers/trainer.py", line 2925, in compute_loss
        outputs = model(**inputs)
                  ^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/accelerate/utils/operations.py", line 817, in forward
        return model_forward(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/accelerate/utils/operations.py", line 805, in __call__
        return convert_to_fp32(self.model_forward(*args, **kwargs))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/amp/autocast_mode.py", line 16, in decorate_autocast
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/models/llama.py", line 807, in PeftModelForCausalLM_fast_forward
        return self.base_model(
               ^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/peft/tuners/tuners_utils.py", line 160, in forward
        return self.model.forward(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/models/llama.py", line 740, in _CausalLM_fast_forward
        outputs = self.model(
                  ^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/models/llama.py", line 612, in LlamaModel_fast_forward
        layer_outputs = torch.utils.checkpoint.checkpoint(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/_compile.py", line 24, in inner
        return torch._dynamo.disable(fn, recursive)(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 489, in _fn
        return fn(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/_dynamo/external_utils.py", line 17, in inner
        return fn(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/utils/checkpoint.py", line 482, in checkpoint
        return CheckpointFunction.apply(function, preserve, *args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/autograd/function.py", line 553, in apply
        return super().apply(*args, **kwargs)  # type: ignore[misc]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/utils/checkpoint.py", line 261, in forward
        outputs = run_function(*args)
                  ^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/models/llama.py", line 608, in custom_forward
        return module(*inputs, past_key_value, output_attentions, padding_mask=padding_mask)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/models/gemma.py", line 109, in GemmaDecoderLayer_fast_forward
        hidden_states = fast_rms_layernorm(self.input_layernorm, hidden_states, gemma = True)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/kernels/rms_layernorm.py", line 190, in fast_rms_layernorm
        out = Fast_RMS_Layernorm.apply(X, W, eps, gemma)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/torch/autograd/function.py", line 553, in apply
        return super().apply(*args, **kwargs)  # type: ignore[misc]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/unsloth/kernels/rms_layernorm.py", line 144, in forward
        fx[(n_rows,)](
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/triton/runtime/jit.py", line 532, in run
        self.cache[device][key] = compile(
                                  ^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/triton/compiler/compiler.py", line 614, in compile
        so_path = make_stub(name, signature, constants, ids, enable_warp_specialization=enable_warp_specialization)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/triton/compiler/make_launcher.py", line 37, in make_stub
        so = _build(name, src_path, tmpdir)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/miniconda3/envs/unsloth/lib/python3.11/site-packages/triton/common/build.py", line 83, in _build
        raise RuntimeError("Failed to find C compiler. Please specify via CC environment variable.")
    RuntimeError: Failed to find C compiler. Please specify via CC environment variable.
    
  12. danielhanchen commented on Mar 12, 2024

    @danielhanchen
    Member

    @avacaondata wait are u on WSL / Linux?

  13. avacaondata commented on Mar 12, 2024

    @avacaondata

    Yes I'm on WSL with Ubuntu 20, is that a problem for unsloth to work? @danielhanchen

  14. matthewdouglas commented on Mar 13, 2024

    @matthewdouglas

    @avacaondata You'll want to sudo apt install build-essential and if you have the same problem, try export CC=/usr/bin/gcc (make sure that's the right path).

    For those issues with BNB, I'd like to know if it is with the 0.43.0 release or a prior one, as the build/distribution pipeline has had some changes for 0.43.0. It should find the libraries that came distributed with PyTorch, but there's some situations where it may not (e.g. other CUDA toolkit versions installed, environment settings like LD_LOAD_LIBRARY, PATH, etc. I'm planning to continue contributing over there to make this more seamless.

  15. avacaondata commented on Mar 13, 2024

    @avacaondata

    @matthewdouglas Thanks you! ❤️ At least the error changed:

    Error out of memory at line 383 in file /src/csrc/pythonInterface.cpp
    

    However that's strange because with normal QLoRA it works, without using the unsloth wrapper. Moreover, I'm checking the GPU memory and at no point it goes above 15GB.

  16. 8 remaining items

  17. danielhanchen commented on Mar 16, 2024

    @danielhanchen
    Member

    @athoag-sony I'll work on something to make it faster, but it's generally checking for all the necessary packages to see if they work :)

  18. danielhanchen commented on Mar 20, 2024

    @danielhanchen
    Member

    @avacaondata I forgot to ask if you had Pytorch 2.2.0 or 2.2.1? If you do, I updated Unsloth to reduce memory VRAM fragmentation which might be the issue of OOMs - although I'm not sure. It can sometimes reduce VRAM usage by 3GB!!

  19. socallme commented on Apr 6, 2024

    @socallme

    Oh wait @athoag-sony @j-d-salinger I think someone else solved it! Turns out Pytorch installs 2.2.1, but Xformers requires 2.2.0.

    Below should work:

    conda create --name unsloth_env python=3.10
    conda activate unsloth_env
    
    conda install pytorch==2.2.0 cudatoolkit torchvision torchaudio pytorch-cuda=<12.1/11.8> -c pytorch -c nvidia
    
    conda install xformers -c xformers
    
    pip install bitsandbytes
    
    pip install "unsloth[conda] @ git+https://github.com/unslothai/unsloth.git"

    I've just tried this but still get the same error. Have tried recreating the conda env with no success.

    ++++++++++++++++++ BUG REPORT INFORMATION ++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    +++++++++++++++++++ ANACONDA CUDA PATHS ++++++++++++++++++++
    ['/home/anon/miniconda3/envs/unsloth_env/lib/libcudart.so']

    ++++++++++++++++++ /usr/local CUDA PATHS +++++++++++++++++++
    []

    +++++++++++++++ WORKING DIRECTORY CUDA PATHS +++++++++++++++
    []

    ++ LD_LIBRARY_PATH /usr/local/cuda-12.4/lib64 CUDA PATHS +++
    ['/usr/local/cuda-12.4/lib64/stubs/libcuda.so']

    ++++++++++++++++++++++++++ OTHER +++++++++++++++++++++++++++
    COMPILED_WITH_CUDA = True
    COMPUTE_CAPABILITIES_PER_GPU = ['8.6']
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ DEBUG INFO END ++++++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Checking that the library is importable and CUDA is callable...

    WARNING: Please be sure to sanitize sensitive info from any such env vars!

    SUCCESS!
    Installation was successful!

    Unable to find python bindings at /usr/local/dcgm/bindings/python3. No data will be captured.
    xFormers 0.0.24+cu118
    memory_efficient_attention.cutlassF: available
    memory_efficient_attention.cutlassB: available
    memory_efficient_attention.decoderF: available
    [email protected]: available
    [email protected]: available
    memory_efficient_attention.smallkF: available
    memory_efficient_attention.smallkB: available
    memory_efficient_attention.tritonflashattF: unavailable
    memory_efficient_attention.tritonflashattB: unavailable
    memory_efficient_attention.triton_splitKF: available
    indexing.scaled_index_addF: available
    indexing.scaled_index_addB: available
    indexing.index_select: available
    sequence_parallel_fused.write_values: unavailable
    sequence_parallel_fused.wait_values: unavailable
    sequence_parallel_fused.cuda_memset_32b_async: unavailable
    sp24.sparse24_sparsify_both_ways: available
    sp24.sparse24_apply: available
    sp24.sparse24_apply_dense_output: available
    sp24._sparse24_gemm: available
    [email protected]: available
    swiglu.dual_gemm_silu: available
    swiglu.gemm_fused_operand_sum: available
    swiglu.fused.p.cpp: available
    is_triton_available: True
    pytorch.version: 2.2.0+cu121
    pytorch.cuda: available
    gpu.compute_capability: 8.6
    gpu.name: NVIDIA GeForce RTX 3090
    dcgm_profiler: unavailable
    build.info: available
    build.cuda_version: 1108
    build.python_version: 3.10.13
    build.torch_version: 2.2.0+cu118
    build.env.TORCH_CUDA_ARCH_LIST: 5.0+PTX 6.0 6.1 7.0 7.5 8.0+PTX 9.0
    build.env.XFORMERS_BUILD_TYPE: Release
    build.env.XFORMERS_ENABLE_DEBUG_ASSERTIONS: None
    build.env.NVCC_FLAGS: None
    build.env.XFORMERS_PACKAGE_FROM: wheel-v0.0.24
    build.nvcc_version: 11.8.89
    source.privacy: open source

    from unsloth import FastLanguageModel
    /home/anon/.local/lib/python3.10/site-packages/unsloth/init.py:72: UserWarning: Unsloth: Running ldconfig /usr/lib64-nvidia to link CUDA.
    warnings.warn(
    /sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
    /home/anon/.local/lib/python3.10/site-packages/unsloth/init.py:103: UserWarning: Unsloth: CUDA is not linked properly.
    Try running python -m bitsandbytes then python -m xformers.info
    We tried running ldconfig /usr/lib64-nvidia ourselves, but it didn't work.
    You need to run in your terminal sudo ldconfig /usr/lib64-nvidia yourself, then import Unsloth.
    Also try sudo ldconfig /usr/local/cuda-xx.x - find the latest cuda version.
    Unsloth will still run for now, but maybe it might crash - let's hope it works!
    warnings.warn(

  20. danielhanchen commented on Apr 6, 2024

    @danielhanchen
    Member

    @socallme We have new install instructions for that!

    # RTX 3090, 4090 Ampere GPUs:
    pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
    pip install --no-deps packaging ninja einops flash-attn xformers trl peft accelerate bitsandbytes
    
    # Pre Ampere RTX 2080, T4, GTX 1080 GPUs:
    pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
    pip install --no-deps xformers trl peft accelerate bitsandbytes
  21. socallme commented on Apr 7, 2024

    @socallme

    @danielhanchen I have tried those instructions with the same result. There are never any errors or warnings when installing either.

    /usr/local/lib/python3.10/dist-packages/unsloth/init.py:72: UserWarning: Unsloth: Running ldconfig /usr/lib64-nvidia to link CUDA.
    warnings.warn(
    /usr/local/lib/python3.10/dist-packages/unsloth/init.py:103: UserWarning: Unsloth: CUDA is not linked properly.

  22. danielhanchen commented on Apr 7, 2024

    @danielhanchen
    Member

    @socallme Are you using conda? Can you try running nvcc in the terminal and nvidia-smi

  23. socallme commented on Apr 9, 2024

    @socallme

    @danielhanchen I am using conda. Are there links I need to manually make?

    I am able to run other tools without issue in conda, eg axolotl, llamacpp
    nvcc and nvidia-smi:

    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2024 NVIDIA Corporation
    Built on Thu_Mar_28_02:18:24_PDT_2024
    Cuda compilation tools, release 12.4, V12.4.131
    Build cuda_12.4.r12.4/compiler.34097967_0

    +-----------------------------------------------------------------------------------------+
    | NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4 |
    |-----------------------------------------+------------------------+----------------------+
    | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
    | | | MIG M. |
    |=========================================+========================+======================|
    | 0 NVIDIA GeForce RTX 3090 Off | 00000000:04:00.0 On | N/A |
    | 70% 75C P2 298W / 300W | 21862MiB / 24576MiB | 97% Default |
    | | | N/A |
    +-----------------------------------------+------------------------+----------------------+

    +-----------------------------------------------------------------------------------------+
    | Processes: |
    | GPU GI CI PID Type Process name GPU Memory |
    | ID ID Usage |
    |=========================================================================================|
    | 0 N/A N/A 788204 C python 21856MiB |
    +-----------------------------------------------------------------------------------------+

  24. tdolega commented on May 14, 2024

    @tdolega

    @socallme did you managed to fix the issue? I have the same problem.

  25. danielhanchen commented on May 17, 2024

    @danielhanchen
    Member

    @tdolega Oh no :( Conda correct? It's actually best to follow Kaggle's install method ie

    !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"
    
  26. mzeidhassan commented on Aug 27, 2024

    @mzeidhassan

    I have been trying for almost 6 hours to install all requirements, but each time I fix something, another breaks. Unsloth installation, especially on Windows, is a nightmare.

  27. danielhanchen commented on Aug 27, 2024

    @danielhanchen
    Member

    @mzeidhassan Oh sorry :( Oh yep Windows is a nightmare - it's Triton that's causing the issue.

    Another issue is to use miniconda and conda and install through Windows (not pip)

  28. shimmyshimmer commented on Jan 19, 2025

    @shimmyshimmer
    Member

    We have docs which might be able to help, if you're still experiencing errors please let us know: https://docs.unsloth.ai/get-started/installing-+-updating

    We're also gonna make Windows downloading much easier hopefully pretty soon!

  29. rolandtannous commented on May 9, 2025

    @rolandtannous
    Contributor

    @athoag-sony

    Hello!
    I would suggest you try the following approach:

    1. Create a new conda environment : conda create --name unsloth_new python==3.11
    2. activate the new environment conda activate unsloth_new
    3. Install cuda-toolkit conda install -c "nvidia/label/cuda-12.6.3” cuda-toolkit
    4. Install unsloth-zoo and unsloth either via
      pip install
      or directly from main repo using
      pip install --force-reinstall git+https://github.com/unslothai/unsloth-zoo.git and
      pip install --force-reinstall git+https://github.com/unslothai/unsloth.git
    5. Install some other required dependencies pip install bitsandbytes datasets huggingface_hub hf_transfer
    6. Install flash attention (optional): https://github.com/Dao-AILab/flash-attention.git . Follow the install from source section

    you should be good to go.
    Please let us know if this works and mark this issue as close or complete once it is resolved. Thank you!

  30. added a commit that references this issue on Mar 12, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions