Pip Install, uv, venv

To install Unsloth locally via Pip, follow the steps below:

Install with pip (recommended) for the latest pip release:

pip install unsloth

To use uv:

pip install --upgrade pip && pip install uv
uv pip install unsloth

To install vLLM and Unsloth together, do:

uv pip install unsloth vllm

To install the latest main branch of Unsloth, do:

pip install unsloth
pip uninstall unsloth unsloth_zoo -y && pip install --no-deps git+https://github.com/unslothai/unsloth_zoo.git && pip install --no-deps git+https://github.com/unslothai/unsloth.git

For venv and virtual environments installs to isolate your installation to not break system packages, and to reduce irreparable damage to your system, use venv:

apt install python3.10-venv python3.11-venv python3.12-venv python3.13-venv -y
python -m venv unsloth_env
source unsloth_env/bin/activate
pip install --upgrade pip && pip install uv
uv pip install unsloth

If you're installing Unsloth in Jupyter, Colab, or other notebooks, be sure to prefix the command with !. This isn't necessary when using a terminal

Python 3.13 is now supported!

Uninstall or Reinstall

If you're still encountering dependency issues with Unsloth, many users have resolved them by forcing uninstalling and reinstalling Unsloth:


Advanced Pip Installation

Pip is a bit more complex since there are dependency issues. The pip command is different for torch 2.2,2.3,2.4,2.5 and CUDA versions.

For other torch versions, we support torch211, torch212, torch220, torch230, torch240 and for CUDA versions, we support cu118 and cu121 and cu124. For Ampere devices (A100, H100, RTX3090) and above, use cu118-ampere or cu121-ampere or cu124-ampere.

For example, if you have torch 2.4 and CUDA 12.1, use:

Another example, if you have torch 2.5 and CUDA 12.4, use:

And other examples:

Or, run the below in a terminal to get the optimal pip installation command:

Or, run the below manually in a Python REPL:

Last updated

Was this helpful?