> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/jp/burogu/fine-tuning-llms-with-blackwell-rtx-50-series-and-unsloth.md).

# Blackwell、RTX 50 シリーズ、Unsloth で LLM をファインチューニングする

NVIDIA の Blackwell RTX 50 シリーズと B200 GPU で LLM をファインチューニングする方法を、ステップごとのガイドで学びます。

Unsloth は NVIDIA の Blackwell アーキテクチャ GPU をサポートするようになりました。RTX 50シリーズ GPU（5060〜5090）、RTX PRO 6000、そして B200、B40、GB100、GB102 などが含まれます！ 公式の [NVIDIA のブログ記事はこちら](https://developer.nvidia.com/blog/train-an-llm-on-an-nvidia-blackwell-desktop-with-unsloth-and-scale-it/).

Unsloth は、2018年以降の NVIDIA GPU すべてに対応しました。以下を含みます [DGX Spark](/docs/jp/burogu/fine-tuning-llms-with-nvidia-dgx-spark-and-unsloth.md).

> **新しい** [**Docker イメージ**](#docker) **は Blackwell をサポートしています。Docker イメージを実行して、学習を始めましょう！** [**ガイド**](/docs/jp/burogu/fine-tuning-llms-with-blackwell-rtx-50-series-and-unsloth.md)

### pip でインストール

Unsloth をインストールするだけです:

```bash
pip install unsloth
```

問題が見られる場合は、別の方法として、分離された環境を作成できます:

```bash
python -m venv unsloth
source unsloth/bin/activate
pip install unsloth
```

なお、以下になる場合があります `pip3` または `pip3.13` および `python3` または `python3.13`

Xformers でいくつか問題が発生する場合があり、その場合はソースからビルドしてください:

{% code overflow="wrap" %}

```bash
# まず、以前のライブラリによってインストールされた xformers をアンインストールします
pip uninstall xformers -y

# クローンしてビルド
pip install ninja
export TORCH_CUDA_ARCH_LIST="12.0"
git clone --depth=1 https://github.com/facebookresearch/xformers --recursive
cd xformers && python setup.py install && cd ..
```

{% endcode %}

### Docker

[**`unsloth/unsloth`**](https://hub.docker.com/r/unsloth/unsloth) は Unsloth の唯一の Docker イメージです。Blackwell および 50シリーズ GPU では、この同じイメージを使用してください。別のイメージは不要です。

インストール手順については、こちらの [Unsloth Docker ガイド](/docs/jp/burogu/how-to-fine-tune-llms-with-unsloth-and-docker.md).

### uv

```bash
uv pip install unsloth
```

#### uv（上級）

インストール順序は重要です。なぜなら、バンドルされた依存関係を特定のバージョンで上書きしたいからです（具体的には `xformers` そして `triton`).

1. 私は `uv` より `pip` を使うのが好みです。依存関係の解決が速く、より優れているためです。特に `torch` に依存するライブラリであっても、今回のケースでは特定の `CUDA` バージョンが必要だからです。

   インストール `uv`

   ```bash
   curl -LsSf https://astral.sh/uv/install.sh | sh && source $HOME/.local/bin/env
   ```

   プロジェクト用ディレクトリと venv を作成します:

   ```bash
   mkdir 'unsloth-blackwell' && cd 'unsloth-blackwell'
   uv venv .venv --python=3.12 --seed
   source .venv/bin/activate
   ```
2. インストール `vllm`

   ```bash
   uv pip install -U vllm --torch-backend=cu128
   ```

   指定する必要があることに注意してください `cu128`、そうしないと `vllm` がインストールされます `torch==2.7.0` ですが、 `cu126`.
3. インストール `unsloth` 依存関係付きです

   ```bash
   uv pip install unsloth unsloth_zoo bitsandbytes
   ```

   Xformers による奇妙な解決問題が見られる場合は、Xformers なしでソースから Unsloth をインストールすることもできます:

   ```bash
   uv pip install -qqq \\
   "unsloth_zoo[base] @ git+https://github.com/unslothai/unsloth-zoo" \
   "unsloth[base] @ git+https://github.com/unslothai/unsloth"
   ```
4. ダウンロードしてビルド `xformers` （任意）

   Xformers は任意ですが、確実に高速で、メモリ消費も少なくなります。Xformers を使わない場合は、PyTorch のネイティブ SDPA を使用します。Xformers をソースからビルドするのは時間がかかることがあるので注意してください！

   ```bash
   # まず、以前のライブラリによってインストールされた xformers をアンインストールします
   pip uninstall xformers -y

   # クローンしてビルド
   pip install ninja
   export TORCH_CUDA_ARCH_LIST="12.0"
   git clone --depth=1 https://github.com/facebookresearch/xformers --recursive
   cd xformers && python setup.py install && cd ..
   ```

   なお、次を明示的に設定する必要があります `TORCH_CUDA_ARCH_LIST=12.0`.
5. `transformers` 任意の transformers バージョンをインストールできますが、最新を入れるのが最善です。

   ```bash
   uv pip install -U transformers
   ```

### Conda または mamba（上級）

1. インストール `conda/mamba`

   ```bash
   curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
   ```

   インストールスクリプトを実行します

   ```bash
   bash Miniforge3-$(uname)-$(uname -m).sh
   ```

   conda または mamba の環境を作成します

   ```bash
   conda create --name unsloth-blackwell python==3.12 -y
   ```

   新しく作成した環境を有効化

   ```bash
   conda activate unsloth-blackwell
   ```
2. インストール `vllm`

   有効化した conda/mamba 環境の中にいることを確認してください。ターミナルのシェルの先頭に、次のように環境名が表示されるはずです。your `(unsloth-blackwell)user@machine:`

   ```bash
   pip install -U vllm --extra-index-url https://download.pytorch.org/whl/cu128
   ```

   指定する必要があることに注意してください `cu128`、そうしないと `vllm` がインストールされます `torch==2.7.0` ですが、 `cu126`.
3. インストール `unsloth` 依存関係付きです

   有効化した conda/mamba 環境の中にいることを確認してください。ターミナルのシェルの先頭に、次のように環境名が表示されるはずです。your `(unsloth-blackwell)user@machine:`

   ```bash
   pip install unsloth unsloth_zoo bitsandbytes
   ```
4. ダウンロードしてビルド `xformers` （任意）

   Xformers は任意ですが、確実に高速で、メモリ消費も少なくなります。Xformers を使わない場合は、PyTorch のネイティブ SDPA を使用します。Xformers をソースからビルドするのは時間がかかることがあるので注意してください！

   ターミナルのシェルの先頭に、次のように環境名が表示されるはずです。your `(unsloth-blackwell)user@machine:`

   ```bash
   # まず、以前のライブラリによってインストールされた xformers をアンインストールします
   pip uninstall xformers -y

   # クローンしてビルド
   pip install ninja
   export TORCH_CUDA_ARCH_LIST="12.0"
   git clone --depth=1 https://github.com/facebookresearch/xformers --recursive
   cd xformers && python setup.py install && cd ..
   ```

   なお、次を明示的に設定する必要があります `TORCH_CUDA_ARCH_LIST=12.0`.
5. `Transformers` 任意の transformers バージョンをインストールできますが、最新を入れるのが最善です。

   ```bash
   uv pip install -U transformers
   ```

mamba をパッケージとして使っている場合は、上記のすべてのコマンドで conda を mamba に置き換えるだけです。

アップグレードしないでください `triton` 単独で。各 `torch` リリースは、正確な `triton` そのリリースがビルドされたときの正確なバージョンを固定しており（これはすでに Blackwell をサポートしています）、そのため `pip install -U triton` は次のようなエラーを引き起こします `torch ... requires triton==X, but you have triton Y which is incompatible`。すでに実行してしまった場合は、エラーに記載されたバージョンをインストールしてください。たとえば `pip install "triton==3.7.1"`.

### WSL 固有の注意事項

WSL（Windows Subsystem for Linux）を使用していて、xformers のコンパイル中に問題が発生した場合（念のため、Xformers は任意ですが、学習はより高速です）、次の追加手順に従ってください:

1. **WSL のメモリ上限を増やす** WSL の設定ファイルを作成または編集します:

   ```bash
   # Windows ユーザー ディレクトリに .wslconfig を作成または編集します
   # （通常は C:\Users\YourUsername\.wslconfig）

   # 次の行をファイルに追加します
   [wsl2]
   memory=16GB  # xformers のコンパイルには最低でも 16GB を推奨
   processors=4  # CPU コア数に応じて調整してください
   swap=2GB
   localhostForwarding=true
   ```

   これらの変更を行ったら、WSL を再起動します:

   ```powershell
   wsl --shutdown
   ```
2. **xformers をインストール** WSL 用に最適化されたコンパイルで xformers をインストールするには、次のコマンドを使用します:

   ```bash
   # Blackwell GPU 用に CUDA アーキテクチャを設定
   export TORCH_CUDA_ARCH_LIST="12.0"

   # 最適化されたビルドフラグでソースから xformers をインストール
   pip install -v --no-build-isolation -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers
   ```

   その `--no-build-isolation` フラグは、WSL 環境で起こり得るビルドの問題を回避するのに役立ちます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/jp/burogu/fine-tuning-llms-with-blackwell-rtx-50-series-and-unsloth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
