[Bug] Installation on Windows with Conda fails due to aggressive PyTorch version replacement
#3,308 opened on Sep 11, 2025
Description
-
Did you update? Yes, I am installing from the latest main branch on GitHub (commit f06200db...).
-
Colab or Kaggle or local / cloud Local machine.
-
Number GPUs used 1x NVIDIA GPU (CUDA 12.1 compatible).
-
Which notebook? N/A, this issue occurs when running a basic local Python script.
-
Which Unsloth version, TRL version, transformers version, PyTorch version? This bug is an installation issue where versions are being incorrectly replaced. Here are the key versions involved in the final failed attempt:
Environment: Conda with Python 3.10
PyTorch (Installed by Conda): 2.5.1+cu121
PyTorch (Incorrectly installed by pip): 2.8.0 (CPU-only version)
Unsloth: 2025.9.4 (from git)
Transformers: 4.38.2
TRL: 0.7.11
PEFT: 0.9.0
Accelerate: 0.28.0
Bitsandbytes: 0.43.0
- Which trainer? The error occurs during the initial import (from unsloth import FastLanguageModel) before any Trainer is initialized.
Summary of Bug On a fresh Conda environment on Windows with the correct GPU-enabled PyTorch installed, any pip install command for a package that lists torch as a dependency (like bitsandbytes or transformers) aggressively uninstalls the Conda torch+cu121 package and replaces it with a newer, CPU-only torch version from PyPI. This breaks the installation and leads to a NotImplementedError because the GPU can no longer be detected.
Minimal Code to Reproduce Error The error is reproducible with the installation steps themselves.
- Set up the correct Conda environment:
Bash
Create a clean Conda environment with a supported Python version
conda create -n unsloth_test python=3.10 conda activate unsloth_test
Install the correct, GPU-enabled PyTorch via Conda
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
At this point, python -c "import torch; print(torch.cuda.is_available())" correctly returns True.
- Trigger the bug by installing dependencies with pip:
Bash
This command uninstalls the GPU PyTorch and installs a CPU version
pip install bitsandbytes==0.43.0
Now, python -c "import torch; print(torch.cuda.is_available())" incorrectly returns False.
- The Python script then fails:
Python
import torch from unsloth import FastLanguageModel
This script now fails with NotImplementedError because the underlying
PyTorch can no longer see the GPU.
model, tokenizer = FastLanguageModel.from_pretrained( model_name = "unsloth/mistral-7b-v0.3-bnb-4bit", )