# NVIDIA DGX StationでUnslothを使ってLLMをファインチューニング

これでNVIDIA DGX Station上でUnslothを使ってローカルにLLMをトレーニングできるようになります [Unsloth](https://github.com/unslothai/unsloth)。DGX Stationは次の以上の容量を備えています **約200GBのVRAM** と **700GBを超える統合GPU/CPUメモリ** を備え、大規模AIワークロード向けに設計された緊密に接続されたシステムでGrace CPUとBlackwell GPUを組み合わせています。NVLink-C2Cで接続されることで、CPUとGPUは別個のままですが、従来のCPU-GPU構成よりもはるかに効率的に連携します。

このガイドでは、Unslothノートブックを使用してトレーニングします [Qwen3.5](#qwen3.5-35b-a3b-fine-tuning) と [gpt-oss-120b](#gpt-oss-120b-fine-tuning) をDGX Stationで実行します。Unslothのテスト用に早期アクセスのDGX Stationハードウェアを提供してくれたNVIDIAに感謝します！

### クイックスタート

必要なもの `python3` がインストールされている必要があり、特に開発用ヘッダが必要です。私たちのシステムでは `python 3.12` を使用しているため、3.12の開発用ヘッダをインストールします。

```bash
sudo apt update
sudo apt install python3.12-dev
```

次に、Unslothをインストールするために新しい仮想環境を作成します。 [Unsloth](https://github.com/unslothai/unsloth)。この方法で依存関係の競合を最小限に抑え、現在の作業環境の状態を保持します。&#x20;

{% code overflow="wrap" %}

```bash
python3 -m venv .unsloth
source .unsloth/bin/activate
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
```

{% endcode %}

{% hint style="warning" %}
まずは `torch` をインストールします `cuda 13` インデックスからでないと、CPU版やアーキテクチャや機能が一致しないものが入る可能性があります！
{% endhint %}

<div><figure><img src="/files/bbcafb90a29523c96f9b9845dc336a6b57d62c5a" alt=""><figcaption></figcaption></figure> <figure><img src="/files/d6e0acf7aaf1b1efe12cbdb754a02a8548a4a899" alt=""><figcaption></figcaption></figure></div>

ではUnslothをインストールできます：

```bash
pip install unsloth
```

<div><figure><img src="/files/f83e0cf598279848f74ab2a61a77baf9a31f85b3" alt=""><figcaption></figcaption></figure> <figure><img src="/files/1b30f24ede94b3061c15a40e315eb7ea0d158c40" alt=""><figcaption></figcaption></figure></div>

次にインストールしましょう `xformers` と、必要に応じてソースからビルドする `flash-attention` の両方を。どちらのパッケージも構築に時間がかかるので、ビルド中はしばらくお待ちください。

{% code overflow="wrap" expandable="true" %}

```bash
pip install --no-deps --no-build-isolation xformers==0.0.33.post1
# オプション：flash-attn
# クローンしてビルド（B300向けにsm_100をターゲット） 
git clone https://github.com/Dao-AILab/flash-attention
cd flash-attention 
# B300 = sm_100、アーキテクチャを明示的に設定 
TORCH_CUDA_ARCH_LIST="10.0" MAX_JOBS=8 pip install . --no-build-isolation
cd ..
```

{% endcode %}

<div><figure><img src="/files/1c2abd31b440834514fe05f8e1f0342fac248bed" alt=""><figcaption></figcaption></figure> <figure><img src="/files/41d8fbcbf1c756950e94720cb7185eb18fbe8fae" alt=""><figcaption></figcaption></figure></div>

{% columns %}
{% column %}
Qwen 3.5 MoEでは、高速化のために2つのカーネルパッケージをダウンロードする必要があります `flash-linear-attention` と `causal-conv1d` 。

{% code overflow="wrap" expandable="true" %}

```bash
pip install --no-build-isolation flash-linear-attention causal_conv1d==1.6.0
```

{% endcode %}
{% endcolumn %}

{% column %}

<figure><img src="/files/11d5ec72b68d1e13fe2b53112e6811be1b514f93" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

まだノートブッククライアントをお持ちでない場合は、インストールしてください。このガイドではJupyter Notebookを使用します：

{% code overflow="wrap" expandable="true" %}

```bash
cd ..
pip install notebook
pip install ipywidgets
```

{% endcode %}

最後に、実際に実行するUnslothノートブックをダウンロードします。LLMトレーニング用のノートブックとPythonスクリプトが250以上あります。

{% code overflow="wrap" expandable="true" %}

```bash
git clone https://github.com/unslothai/notebooks.git
cd notebooks
```

{% endcode %}

### トレーニングチュートリアル

{% columns %}
{% column %}
これでJupyter Notebookを起動して、ブラウザでUIにアクセスできます。

{% code overflow="wrap" expandable="true" %}

```bash
jupyter notebook
```

{% endcode %}
{% endcolumn %}

{% column %}

<figure><img src="/files/8122a11624b754a07f989649a5898bf243fe8550" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
次に、コピーして貼り付ける `localhost` のサイト（トークン付き）をブラウザに貼り付けてください。次のような画面が表示されるはずです：

その `nb` フォルダに実行するノートブックがすべて入っています。
{% endcolumn %}

{% column %}

<figure><img src="/files/e70cf5596ea6710a211f80484a8aedec7f3fe7c2" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

#### Qwen3.5-35B-A3B トレーニング

{% columns %}
{% column %}
ファイルを開いてください `nb/Qwen3_5_MoE.ipynb`。インストールセクションは既に必要なものを事前にインストールしているのでスキップしてください。Unslothセクションに移動してそこからセルを実行し始めます。

{% endcolumn %}

{% column %}

<figure><img src="/files/366580c9a96db1e5e91c71a0bef774f714c00f7a" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
ノートブックはモデルのセットアップ、データセット準備、トレーナーの構成を扱います。非常に大きなモデルをダウンロードし、数十億の重みを初期化し、さらに高速化のための最適化を行うため、各ステップには時間がかかることがあります。&#x20;
{% endcolumn %}

{% column %}

<figure><img src="/files/0993e8193a6b3b00646fdb477dec5b92ec290b24" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

デフォルト設定ではトレーニングは非常に高速です。DGX Stationはメモリが十分にあるため、デフォルトのトレーニングハイパーパラメータを変更してメモリと計算を本格的に試すことができます。トレーニングが終わったら、モデルを保存して後で使用したり、他の人と共有するためにHugging Face Hubへアップロードしたり、量子化フォーマットにエクスポートしたりできます。

#### gpt-oss-120b トレーニング

{% columns %}
{% column %}
ファイルを開いてください `nb/gpt-oss-(120B)_A100-Fine-tuning.ipynb`。インストールセクションは既に前提条件をインストールしているのでスキップし、Unslothセクションに移動してください。そこからノートブックの実行を開始できます。ノートブックは約72GBのGPUメモリを使用し、実行に約10分かかります。
{% endcolumn %}

{% column %}

<figure><img src="/files/d00d32996f8c0098f1b873089f62bbdd55423481" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
モデルのダウンロード、重みの初期化、および高速化のための最適化が必要なため、各セルの実行には時間がかかる場合があります。ノートブックはデータセットの前処理とトレーナーの設定を順に説明します。次に `trainer.train()` セルに到達して実行するとトレーニングが開始されます。
{% endcolumn %}

{% column %}

<figure><img src="/files/e98eb59d3cb53c04e564f145e0f709099b2c49b4" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

完了したら、後で使用するためにモデルを保存したり、Hugging Face Hubに公開して世界と共有したり、GGUF形式にエクスポートしたりできます。

<figure><img src="/files/424952ee346f293fb8e68c7ff339ea2ca159cc04" alt=""><figcaption></figcaption></figure>

NVIDIAのDGX Stationについて詳しくは次をご覧ください <https://www.nvidia.com/en-us/products/workstations/dgx-station/>


---

# 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/burogu/dgx-station.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.
