Windows Installation
See how to install Unsloth on Windows with or without WSL.
Last updated
Was this helpful?
See how to install Unsloth on Windows with or without WSL.
Last updated
Was this helpful?
Install NVIDIA Video Driver
You should install the latest version of your GPUs driver. Download drivers here:
Install Visual Studio C++
You will need Visual Studio, with C++ installed. By default, C++ is not installed with Visual Studio, so make sure you select all of the C++ options. Also select options for Windows 10/11 SDK.
Launch the Installer here:
In the installer, navigate to individual components and select all the options listed here:
.NET Framework 4.8 SDK
.NET Framework 4.7.2 targeting pack
C# and Visual Basic Roslyn compilers
MSBuild
MSVC v143 - VS 2022 C++ x64/x86 build tools
C++ 2022 Redistributable Update
C++ CMake tools for Windows
C++/CLI support for v143 build tools (Latest)
MSBuild support for LLVM (clang-cl) toolset
C++ Clang Compiler for Windows (19.1.1)
Windows 11 SDK (10.0.22621.0)
Windows Universal CRT SDK
C++ 2022 Redistributable MSMs
Easier method: Or you can open an elevated Command Prompt or PowerShell:
Search for "cmd" or "PowerShell", right-click it, and choose "Run as administrator."
Paste and run this command (update the Visual Studio path if necessary):
Install Python and CUDA Toolkit
Follow the instructions to install .
Then install Miniconda (which has Python) here:
Install PyTorch
You will need the correct version of PyTorch that is compatible with your CUDA drivers, so make sure to select them carefully.
Install Unsloth
Open Conda command prompt or your terminal with Python and run the command:
If you're using GRPO or plan to use vLLM, currently vLLM does not support Windows directly but only via WSL or Linux.
To run Unsloth directly on Windows:
Install Triton from this Windows fork and follow the instructions (be aware that the Windows fork requires PyTorch >= 2.4 and CUDA 12)
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
and triton
. Go to https://pytorch.org to install it. For example pip install torch torchvision torchaudio triton
Confirm if CUDA is installated correctly. Try nvcc
. If that fails, you need to install cudatoolkit
or CUDA drivers.
Install xformers
manually. You can try installing vllm
and seeing if vllm
succeeds. Check if xformers
succeeded with python -m xformers.info
Go to https://github.com/facebookresearch/xformers. Another option is to install flash-attn
for Ampere GPUs.
Double check that your versions of Python, CUDA, CUDNN, torch
, triton
, and xformers
are compatible with one another. The may be useful.
Finally, install bitsandbytes
and check it with python -m bitsandbytes
Install NVIDIA CUDA Toolkit:
Reboot your system after installation if prompted.
Note: No additional setup is required after installation for Unsloth.
Install Microsoft C++ Build Tools:
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.
Install Conda
Follow installation instruction from the website
To check whether conda
is already installed, you can test it with conda
in your PowerShell
Open PowerShell as Administrator:
Right-click Start and select "Windows PowerShell (Admin)".
Navigate to the script’s location using cd
:
Run the script:
Activate the environment after the installation completes:
Unsloth and its dependencies are now ready!
WSL is Window's subsystem for Linux.
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:
Download any Colab notebook from Unsloth, import it into your Jupyter Notebook, adjust the parameters as needed, and execute the script.
Download and install the appropriate version of the NVIDIA CUDA Toolkit from .
Download and install Microsoft Build Tools for Visual Studio from the .
Download and install Miniconda from the
Download the PowerShell script by going through this link.
Install python though .