# pip と uv で Unsloth をインストールする

Unslothは2つの方法で使えます： [Unsloth Studio](#unsloth-studio)、Web UI、または [Unsloth Core](#unsloth-core)、コードベース版です。&#x20;

## **Unsloth Studio**

### **MacOS、Linux、WSL：**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

更新するには同じコマンドを使うか、 `unsloth studio update`.

### **Windows PowerShell：**

```bash
irm https://unsloth.ai/install.ps1 | iex
```

更新するには同じコマンドを使うか、 `unsloth studio update`.

### 起動：

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

Unsloth Studio の詳細なインストール手順と要件については、 [ガイドをご覧ください](https://unsloth.ai/docs/jp/xin-zhe/studio/install).

### アンインストール

Unsloth Studio をアンインストールするには、次の4つの手順に従ってください：

#### **1. アプリケーションを削除する**

* MacOS、WSL、Linux： `rm -rf ~/.unsloth/studio/unsloth ~/.unsloth/studio/studio`
* Windows（PowerShell）： `Remove-Item -Recurse -Force "$HOME\.unsloth\studio\unsloth", "$HOME\.unsloth\studio\studio"`&#x20;

これによりアプリケーションは削除されますが、モデルのチェックポイント、エクスポート、履歴、キャッシュ、チャットはそのまま残ります。

#### **2. ショートカットとシンボリックリンクを削除する**

**macOS：**

```bash
rm -rf ~/Applications/Unsloth\ Studio.app ~/Desktop/Unsloth\ Studio
```

**Linux：**

```bash
rm -f ~/.local/share/applications/unsloth-studio.desktop ~/Desktop/unsloth-studio.desktop
```

**WSL / Windows（PowerShell）：**

```bash
Remove-Item -Force "$HOME\Desktop\Unsloth Studio.lnk"
Remove-Item -Force "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Unsloth Studio.lnk"
```

#### **3. CLIコマンドを削除する**

**macOS、Linux、WSL：**

```bash
rm -f ~/.local/bin/unsloth
```

**Windows（PowerShell）：** インストーラーは venv の `Scripts` ディレクトリをユーザーの PATH に追加しました。削除するには、設定 → システム → 情報 → 詳細システム設定 → 環境変数 を開き、 `Path` をユーザー変数の下で見つけて、 `.unsloth\studio\...\Scripts`.

#### **4. すべて削除する（任意）**

履歴、キャッシュ、チャット、モデルのチェックポイント、モデルのエクスポートも削除するには、Unsloth フォルダ全体を削除してください：

* MacOS、WSL、Linux： `rm -rf ~/.unsloth`
* Windows（PowerShell）： `Remove-Item -Recurse -Force "$HOME\.unsloth"`&#x20;

ダウンロードした HF モデルファイルは Hugging Face のキャッシュに別途保存されることに注意してください。上記のどの手順でもそれらは削除されません。空き容量を確保したい場合は、以下の **モデルファイルの削除** を参照してください。

{% hint style="warning" %}
注意： `rm -rf` コマンドを使うと **すべて削除されます**。履歴、キャッシュ、チャットなども含まれます。
{% endhint %}

### **キャッシュされた HF モデルファイルの削除**

古いモデルファイルは、モデル検索のゴミ箱アイコンから削除するか、デフォルトの Hugging Face キャッシュディレクトリから該当するキャッシュ済みモデルフォルダを削除することで消せます。デフォルトでは、Hugging Face は `~/.cache/huggingface/hub/` を macOS/Linux/WSL で使用し、 `C:\Users\<username>\.cache\huggingface\hub\` を Windows で使用します。

* **MacOS、Linux、WSL：** `~/.cache/huggingface/hub/`
* **Windows：** `%USERPROFILE%\.cache\huggingface\hub\`

もし `HF_HUB_CACHE` または `HF_HOME` が設定されている場合は、その場所を代わりに使用してください。Linux と WSL では、 `XDG_CACHE_HOME` もデフォルトのキャッシュルートを変更できます。

## **Unsloth Core**

**最新の pip リリースを使うには、uv pip でインストールしてください（推奨）：**

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv unsloth_env --python 3.13
source unsloth_env/bin/activate
uv pip install unsloth --torch-backend=auto
```

または通常の pip で：

```bash
pip install unsloth
```

インストールするには **vLLM と Unsloth** を一緒に、次のようにします：

```bash
uv pip install unsloth vllm --torch-backend=auto
```

Unsloth の **最新の main ブランチ** をインストールするには、次のようにします：

{% code overflow="wrap" %}

```bash
uv pip install unsloth --torch-backend=auto
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
```

{% endcode %}

以下の用途では **venv と仮想環境でのインストール** を使って、インストールを分離しシステムパッケージを壊さず、システムへの修復不能な損害を減らしてください：

{% code overflow="wrap" %}

```bash
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 --torch-backend=auto
```

{% endcode %}

Jupyter、Colab、その他のノートブックで Unsloth をインストールする場合は、コマンドの前に `!`を付けてください。ターミナルを使う場合は必要ありません

{% hint style="info" %}
Python 3.13 がサポートされました！
{% endhint %}

### Unsloth Core をアンインストール

それでも Unsloth で依存関係の問題が起きる場合、多くのユーザーは Unsloth を強制アンインストールして再インストールすることで解決しています：

{% code overflow="wrap" %}

```bash
pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth
pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth_zoo
```

{% endcode %}

### 高度な Pip インストール

{% hint style="warning" %}
次の場合は **使用しないでください** ： [Conda](https://unsloth.ai/docs/jp/meru/install/conda-install).
{% endhint %}

Pip は依存関係の問題があるため少し複雑です。pip コマンドは `torch 2.2,2.3,2.4,2.5` と CUDA のバージョンで異なります。

その他の torch バージョンについては、 `torch211`, `torch212`, `torch220`, `torch230`, `torch240` をサポートしており、CUDA バージョンについては、 `cu118` と `cu121` と `cu124`をサポートしています。Ampere デバイス（A100、H100、RTX3090）以上では、 `cu118-ampere` または `cu121-ampere` または `cu124-ampere`.

を使用してください。たとえば、 `torch 2.4` と `CUDA 12.1`を使っている場合は、次のようにします：

```bash
pip install --upgrade pip
pip install "unsloth[cu121-torch240] @ git+https://github.com/unslothai/unsloth.git"
```

別の例として、 `torch 2.5` と `CUDA 12.4`を使っている場合は、次のようにします：

```bash
pip install --upgrade pip
を使っている場合は、次のようにします：
```

他の例：

```bash
pip install "unsloth[cu121-ampere-torch240] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu118-ampere-torch240] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu121-torch240] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu118-torch240] @ git+https://github.com/unslothai/unsloth.git"

pip install "unsloth[cu121-torch230] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu121-ampere-torch230] @ git+https://github.com/unslothai/unsloth.git"

pip install "unsloth[cu121-torch250] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu124-ampere-torch250] @ git+https://github.com/unslothai/unsloth.git"
```

または、以下をターミナルで実行して、 **最適な** pip インストールコマンドを取得してください：

```bash
wget -qO- https://raw.githubusercontent.com/unslothai/unsloth/main/unsloth/_auto_install.py | python -
```

または、以下を Python REPL で手動実行してください：

{% code overflow="wrap" %}

```python
# Apache License, Version 2.0（"License"）の下でライセンスされています
try: import torch
except: raise ImportError('Install torch via `pip install torch`')
from packaging.version import Version as V
import re
v = V(re.match(r"[0-9\.]{3,}", torch.__version__).group(0))
cuda = str(torch.version.cuda)
is_ampere = torch.cuda.get_device_capability()[0] >= 8
USE_ABI = torch._C._GLIBCXX_USE_CXX11_ABI
if cuda not in ("11.8", "12.1", "12.4", "12.6", "12.8", "13.0"): raise RuntimeError(f"CUDA = {cuda} not supported!")
if   v <= V('2.1.0'): raise RuntimeError(f"Torch = {v} too old!")
elif v <= V('2.1.1'): x = 'cu{}{}-torch211'
elif v <= V('2.1.2'): x = 'cu{}{}-torch212'
elif v  < V('2.3.0'): x = 'cu{}{}-torch220'
elif v  < V('2.4.0'): x = 'cu{}{}-torch230'
elif v  < V('2.5.0'): x = 'cu{}{}-torch240'
elif v  < V('2.5.1'): x = 'cu{}{}-torch250'
elif v <= V('2.5.1'): x = 'cu{}{}-torch251'
elif v  < V('2.7.0'): x = 'cu{}{}-torch260'
elif v  < V('2.7.9'): x = 'cu{}{}-torch270'
elif v  < V('2.8.0'): x = 'cu{}{}-torch271'
elif v  < V('2.8.9'): x = 'cu{}{}-torch280'
elif v  < V('2.9.1'): x = 'cu{}{}-torch290'
elif v  < V('2.9.2'): x = 'cu{}{}-torch291'
else: raise RuntimeError(f"Torch = {v} too new!")
if v > V('2.6.9') and cuda not in ("11.8", "12.6", "12.8", "13.0"): raise RuntimeError(f"CUDA = {cuda} not supported!")
x = x.format(cuda.replace(".", ""), "-ampere" if False else "") # is_ampere is broken due to flash-attn
print(f'pip install --upgrade pip && pip install --no-deps git+https://github.com/unslothai/unsloth-zoo.git && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git" --no-build-isolation')
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://unsloth.ai/docs/jp/meru/install/pip-install.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
