Skip to content

[Bug] Can't use GPU: Unsloth installs PyTorch+CUDA 12.4 despite conda environment with CUDA 11.8 #2499

Closed

Description

@ctongh

Description
Hi there! 👋 I'm running into a bit of a headache with Unsloth and CUDA compatibility. Despite following the official installation instructions for CUDA 11.8, my system keeps telling me the NVIDIA driver is too old and CUDA is unavailable. I'd really appreciate some help figuring this out!

Environment

  • OS: Linux (Ubuntu)
  • Python version: 3.11.11
  • NVIDIA driver version: 520.56.06
  • CUDA version on system: 11.8
  • GPU model: NVIDIA GeForce RTX 3090 (24GB VRAM)
  • Unsloth version: 2025.4.7
  • PyTorch version: 2.6.0+cu124 (installed by Unsloth)

Expected behavior
Unsloth should use the available GPU with CUDA 11.8 support as specified in the installation command.

Actual behavior
PyTorch reports that the NVIDIA driver is too old and CUDA is unavailable:

UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 11080). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx

When running the training script, Unsloth exits with:

NotImplementedError: Unsloth: No NVIDIA GPU found? Unsloth currently only supports GPUs!

Steps to reproduce

  1. Created a new conda environment with the official command:
conda create --name unsloth_env \
    python=3.11 \
    pytorch-cuda=11.8 \
    pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformers \
    -y
conda activate unsloth_env
pip install unsloth
  1. Installed required dependencies
  2. When running training script, received the CUDA error

What I've tried so far

  • Verified that NVIDIA driver (520.56.06) supports CUDA 11.8
  • Confirmed GPU is detected by nvidia-smi
  • Checked that conda installation included the correct CUDA packages
  • Ran diagnostics to verify the issue is due to PyTorch's CUDA version mismatch

Additional information
The issue appears to be that Unsloth's pip installation overrides the conda-installed PyTorch (with CUDA 11.8) with a newer PyTorch version that requires CUDA 12.4. Despite specifying pytorch-cuda=11.8 in the conda environment, running pip install unsloth installs torch-2.6.0+cu124 which is incompatible with the system driver.

I think this might be a dependency management quirk where Unsloth really wants specific versions of PyTorch that need newer CUDA versions than what I have available. Any suggestions on how to make Unsloth work with my current setup would be super helpful! Thanks in advance! 🙏

Activity

  1. rolandtannous commented on May 9, 2025

    @rolandtannous
    Contributor

    @ctongh

    Some of the core packages required by unsloth, require a newer version of torch like 2.6.0 or newer.
    You can't really work around this without break the package.
    One example is xformers. Latest xformers version 0.0.30 requires torch==2.7.0

    In your case:

    • RTX 3090 supports newer driver and cuda 12.4, check screenshots below

    Image

    Image

    -update your driver versions and install system wide cuda-toolkit from here: https://developer.nvidia.com/cuda-12-4-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network
    Make sure to pick the correct ubuntu version you have 20.04 vs 22.04

    • Inside your conda working environments , do as follows:
    1. Install cuda-toolkit (You need cuda toolkit inside your conda environments even if you've installed it system wide) in the following manner:
      conda install -c "nvidia/label/cuda-12.4.131" cuda-toolkit
    2. Install unsloth-zoo and unsloth from the latest main repos:
      pip install git+https://github.com/unslothai/unsloth-zoo.git
      pip install git+https://github.com/unslothai/unsloth.git
    3. Install some other required dependencies:
      pip install bitsandbytes datasets huggingface_hub hf_transfer
    4. Optionally compile flash attention from source:
      Follow install from source section using setup.py install as explained here https://github.com/Dao-AILab/flash-attention?tab=readme-ov-file#installation-and-features

    You should be good to go.
    If you have some other package that requires cuda-11.8, what you can do is create a separate conda environment for it and install cuda toolkit 11.8 inside that specific environment .

    Hope this helps.

  2. Oleg777778 commented on May 9, 2025

    @Oleg777778

    It feels like Unsloth is impossible to install properly. I've been struggling with this for over a month now. First, I tried all three installation methods on Windows, and now I’m trying on Linux—but nothing works, despite putting in a ridiculous amount of time and effort. Below are the results of my Linux attempts. I’ve tried everything at this point. What am I doing wrong?

    Hardware Configuration:

    • OS: Manjaro Linux (Arch-based) 6.12.21-4-MANJARO
    • GPU: NVIDIA RTX 4060 Ti (16GB VRAM)
    • Driver: 520.56.06
    • CPU: AMD Ryzen 5 1600X (6 cores)
    • RAM: 64GB

    Software Environment:

    • Miniconda3 with Python 3.11.11
    • CUDA 12.1 via conda (nvidia/label/cuda-12.1.1)
    • PyTorch 2.3.0+cu121
    • Unsloth 2025.4.8 (git)
    • Transformers 4.51.3

    Full Error Reproduction:

    1. Clean environment setup:
    conda create -n unsloth_env python=3.11 pytorch-cuda=12.1 pytorch cudatoolkit -c pytorch -c nvidia -y
    conda activate unsloth_env
    pip install git+https://github.com/unslothai/unsloth-zoo.git
    pip install git+https://github.com/unslothai/unsloth.git
    pip install bitsandbytes datasets huggingface_hub hf_transfer
    
    1. First attempt (fails with xformers error):
      python -c "from unsloth import FastLanguageModel; model, tokenizer = FastLanguageModel.from_pretrained('unsloth/mistral-7b-bnb-4bit', load_in_4bit=True)"

    Error:

    AttributeError: 'NoneType' object has no attribute 'attn_bias'
    [Full traceback shows failure in unsloth/models/mistral.py line 197]
    
    1. Attempted solutions (all failed):

    a) Disabling xformers:
    XFORMERS_DISABLED=1 python -c "..."
    [Same error]

    b) Manual xformers install:
    pip install xformers==0.0.25
    [Creates version conflicts]

    c) Barebones test:
    python -c "from unsloth import FastLanguageModel; print('Import works')"
    [Success, but generation fails]

    Key Error Logs:

    Main generation failure:
    Traceback (most recent call last):

      File "<string>", line 9, in <module>
      File "/.../unsloth/models/llama.py", line 1581, in unsloth_fast_generate
        output = self._old_generate(*args, **kwargs)
      [...]
      File "/.../unsloth/models/mistral.py", line 197:
        causal_mask = xformers.attn_bias.LowerTriangularMask()
    AttributeError: 'NoneType' object has no attribute 'attn_bias'
    

    Current Status:

    • Model loads successfully (verified via simple import)
    • All generation attempts fail with xformers dependency error
    • Tried all suggested solutions from this issue
    • System meets all requirements (VRAM, CUDA, etc.)

    Request:
    Need either:

    1. Working xformers-free configuration, or
    2. Clear documentation of required xformers version, or
    3. Patch to make xformers optional
  3. rolandtannous commented on May 9, 2025

    @rolandtannous
    Contributor

    @Oleg777778
    Sorry to hear about your frustration . I can see why it's potentially not working.
    Please update your GPU driver to at least cu550.
    Then follow exactly the steps I provided above to install unsloth in an environment. Your current approach is the cause of several issues. Make sure to install cuda toolkit > 12.4 following the steps i provided. Don't pre-install torch,let unsloth-zoo install it. Don't force an xformers version.

    Also that attn_bias error you are getting is because you potentially need to install flash attention. Follow step4.

  4. notlu commented on May 10, 2025

    @notlu

    I met with the same issue.

  5. rolandtannous commented on May 10, 2025

    @rolandtannous
    Contributor

    @notlu follow the 4 steps in a new environment as detailed at the bottom of this reply:
    #2499 (comment)

    your cuda driver has to be up to date. the cuda toolkit version should be >=12.4

  6. ctongh commented on May 12, 2025

    @ctongh
    Author

    Hi @rolandtannous @Oleg777778 ,Thank you all for your quick responses! These solutions will be incredibly helpful for others who encounter similar issues and find this thread.

    In my specific situation, we have multiple servers in our lab, and some of them are running older CUDA versions (like 11.8). Since I'm not the server administrator, I don't have permission to update the GPU drivers or CUDA versions on these machines.

    I'm wondering if there's a way to use an earlier version of unsloth that would be compatible with older GPU drivers and CUDA versions. Currently, when trying to install a specific version through pip, I can only go back as far as version 2024.8 (but I likely need an even earlier version like 2023.8 to work with my setup).

    If it could make earlier versions available, that would be extremely convenient. Of course, I understand that with models constantly evolving, it makes sense that unsloth only provides relatively recent versions.

    Thanks again for your help!

  7. rolandtannous commented on May 12, 2025

    @rolandtannous
    Contributor

    @ctongh unfortunately, I don't think that's currently possible. I am also afraid you'll lose a lot of functionality that has been added in the latest versions of unsloth and all its dependencies.
    The best way forward is explain to your IT admin the situation , and request they update the CUDA version at least on the workstation you're using, or just on all servers. They shouldn't mind.

  8. Oleg777778 commented on May 12, 2025

    @Oleg777778

    @rolandtannous, I want to sincerely thank you for your guidance! Your advice on driver updates and CUDA 12.4 installation was instrumental in finally getting Unsloth to work locally after a month of dependency struggles. The model now runs flawlessly for inference — truly a breakthrough!

    Remaining Hurdle: Flash Attention Compilation Hang
    Despite Unsloth’s functionality, installing flash-attn freezes during compilation. Here’s the detailed breakdown:

    System Configuration:
    OS: Fresh Ubuntu 24.04 install
    GPU: RTX 4060 Ti 16GB (Driver 550.54.15)
    CUDA: 12.4 (via conda install -c "nvidia/label/cuda-12.4.131" cuda-toolkit)
    Hardware: Ryzen 5 1600X, 64GB RAM

    Reproduction Steps:

    pip uninstall flash-attn -y
    pip install flash-attn --no-build-isolation --verbose
    

    Observed Behavior:

    1. Compilation hangs indefinitely (tested for 2+ hours) with:
      Building wheel for flash-attn (setup.py) ... /

    2. "top" shows sustained 100% CPU usage on 2 cores by gcc/nvcc without progress.

    3. Forced termination (Ctrl+C) reveals:
      cicc: error while loading shared libraries: libtinfo.so.6: cannot open shared object file

    Attempted Solutions:
    ✔ Installed libtinfo6 and libncurses5 (no effect)
    ✔ Limited threads: MAX_JOBS=2 pip install flash-attn
    ✔ Pre-built packages: pip install flash-attn --no-build-isolation --no-deps
    ✔ Manual compilation from FlashAttention repo

    Key Questions:

    1. Is there a known workaround for the libtinfo.so.6 dependency on Ubuntu 24.04?
    2. Are there pre-compiled binaries for CUDA 12.4 to avoid compilation?
    3. Would downgrading to CUDA 12.1 (with compatible driver) be advisable?

    Current Workaround:
    Using "FastLanguageModel.disable_xFormers = True", but hoping to unlock full performance with Flash Attention.

    Your expertise would be invaluable—this is the last major blocker! Many thanks in advance for any insights.

  9. rolandtannous commented on May 12, 2025

    @rolandtannous
    Contributor

    @Oleg777778

    steps

    1. uninstall pip flash-attn
    pip uninstall flash-attn -y
    
    1. clone flash attention repo
    git clone https://github.com/Dao-AILab/flash-attention
    
    1. cd into flash-attention directory
    cd flash-attention
    
    1. compile from source using:
    MAX_JOBS=4 python setup.py install
    
  10. Oleg777778 commented on May 14, 2025

    @Oleg777778

    @rolandtannous,
    thank you very much for your help. It works properly at last!
    FA [Xformers = None. FA2 = True]

  11. rolandtannous commented on May 14, 2025

    @rolandtannous
    Contributor

    Great to know. I'll close this for now.
    Please feel free to re-open it if you feel you have to.

  12. arnabwithab commented on Jun 18, 2025

    @arnabwithab

    @rolandtannous
    im getting the same error, however I've completed all the steps as you had previously mentioned

    Image

    Image

    Image

    Image

    I even downgraded to a cuda 12.4 to no avail

  13. rolandtannous commented on Jun 18, 2025

    @rolandtannous
    Contributor

    @Eros483 that was mostly applicable to linux system.

    For windows support:

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

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions