Windows Installation
See how to install Unsloth on Windows with or without WSL.
Method #1 - Windows directly:
To run Unsloth directly on Windows (without WSL):
Install Triton from this Windows fork and follow the instructions here.
In the SFTTrainer, set
dataset_num_proc=1
to avoid a crashing issue:
For advanced installation instructions or if you see weird errors during installations:
Install
torch
andtriton
. Go to Pytorch to install it. For examplepip install torch torchvision torchaudio triton
Confirm if CUDA is installated correctly. Try
nvcc
. If that fails, you need to installcudatoolkit
or CUDA drivers.Install
xformers
manually. You can try installingvllm
and seeing ifvllm
succeeds. Check ifxformers
succeeded withpython -m xformers.info
Go to https://github.com/facebookresearch/xformers. Another option is to installflash-attn
for Ampere GPUs.Install
bitsandbytes
and check it withpython -m bitsandbytes.
Afterwards, follow our standard pip install procedure: For stable releases, use
pip install unsloth
. We recommendpip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
for most installations though.
Method #2 - Windows using PowerShell:
Step 1: Install Prerequisites
Install NVIDIA CUDA Toolkit:
Download and install the appropriate version of the NVIDIA CUDA Toolkit from CUDA Downloads.
Reboot your system after installation if prompted.
Note: No additional setup is required after installation for Unsloth.
Install Microsoft C++ Build Tools:
Download and install Microsoft Build Tools for Visual Studio from the official website.
During installation, select the C++ build tools workload. Ensure the MSVC compiler toolset is included.
Set Environment Variables for the C++ Compiler:
Open the System Properties window (search for "Environment Variables" in the Start menu).
Click "Environment Variables…".
Add or update the following under System variables:
CC: Path to the
cl.exe
C++ compiler. Example (adjust if your version differs):CXX: Same path as
CC
.
Click OK to save changes.
Verify: Open a new terminal and type
cl
. It should show version info.
Step 2: Run the Unsloth Installation Script
Download the
unsloth_windows.ps1
PowerShell script.Open PowerShell as Administrator:
Right-click Start and select "Windows PowerShell (Admin)".
Navigate to the script’s location using
cd
:Run the script:
Step 3: Using Unsloth
Activate the environment after the installation completes:
Unsloth and its dependencies are now ready!
Method #3 - Windows via WSL:
WSL is Window's subsystem for Linux.
Install python though Python's official site.
Start WSL (Should already be preinstalled). Open command prompt as admin then run:
Optional: If WSL is not preinstalled, go to the Microsoft store and search "Ubuntu" and the app that says Ubuntu will be WSL. Install it and run it and continue from there.
Update WSL:
Install pip:
Install unsloth:
Optional: Install Jupyter Notebook to run in a Colab like environment:
Launch Jupyter Notebook:
Last updated