> 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/zh/bo-ke/dgx-station.md).

# 在 NVIDIA DGX Station 上使用 Unsloth 对 LLM 进行微调

关于如何使用 Unsloth 的 notebooks 在 NVIDIA DGX Station 上进行微调的教程。

现在你可以在本地使用你的 NVIDIA DGX Station 训练 LLM，借助 [Unsloth](https://github.com/unslothai/unsloth)。DGX Station 拥有超过 **约 200GB 显存** 以及超过 **700GB 的统一 GPU/CPU 内存** 并将 Grace CPU 和 Blackwell GPU 组合在一个紧密连接的系统中，专为大规模 AI 工作负载而设计。CPU 和 GPU 通过 NVLink-C2C 连接，彼此保持独立，但协同工作时的效率远高于传统的 CPU-GPU 架构。

在本指南中，我们将使用 Unsloth notebooks 进行训练 [Qwen3.5](#qwen3.5-35b-a3b-fine-tuning) 和 [gpt-oss-120b](#gpt-oss-120b-fine-tuning) 在 DGX Station 上进行测试。感谢 NVIDIA 提供部分早期访问的 DGX Station 硬件，让我们可以在其上测试 Unsloth！

### 快速入门

你将需要 `python3` 已安装，尤其需要 dev 头文件。在我们的系统上，我们有 `python 3.12` 因此我们将安装 3.12 的开发头文件。

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

然后创建一个新的虚拟环境来安装 [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="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fw04Su0JZriUaQxD31wf0%2Funknown.png?alt=media&amp;token=83e61cdb-74c3-42c4-a1ff-18cec3752c9e" alt=""><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F9bs6h6YxI2hqnqOz1bU0%2Funknown.png?alt=media&amp;token=e3e261b5-be18-4d49-9f38-526012add332" alt=""><figcaption></figcaption></figure></div>

现在我们可以安装 Unsloth：

```bash
pip install unsloth
```

<div><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FhQZznPQ8O9Wh3At6FclO%2Funknown.png?alt=media&amp;token=34c8de6e-bef8-414c-8e1b-2913589c4b10" alt=""><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FdLZCFmln5LaUWtO6eC4A%2Funknown.png?alt=media&amp;token=ce04e025-32c7-4847-ac35-bee1baf6259f" 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="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FnyczIn3YvXAPx5oIfZQQ%2Funknown.png?alt=media&amp;token=1a2c5f7b-13c5-4f5e-b4c4-61df8d5fc653" alt=""><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FoupUFzx2pOG6l5B91Pw4%2Funknown.png?alt=media&amp;token=009d2c73-5992-4593-8fd0-e7d813eda3ff" alt=""><figcaption></figcaption></figure></div>

{% columns %}
{% column %}
对于 Qwen 3.5 MoE，我们需要下载两个内核包 `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="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F4xEY8k3jzxfOgMWAgJD7%2Funknown.png?alt=media&amp;token=2b8bd62e-23cd-4bcf-a0af-6d161d1ec1a1" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

如果你还没有 notebook 客户端，请安装一个。本指南中我们将使用 Jupyter Notebook：

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

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

{% endcode %}

最后我们下载要运行的实际 Unsloth notebooks。这里有 250 多个用于 LLM 训练的 notebooks，以及 Python 脚本。

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

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

{% endcode %}

### 训练教程

{% columns %}
{% column %}
现在我们可以启动 Jupyter Notebook，并在浏览器中打开其界面。

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

```bash
jupyter notebook
```

{% endcode %}
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FP2seywdWvLHHQkdP8DGy%2Funknown.png?alt=media&amp;token=ca1b5390-5eb8-416b-a3e9-d9df9b27fb0b" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
复制并粘贴 `localhost` 带有 token 参数的网站地址，并将其粘贴到浏览器中。你应该会看到类似这样的内容：

“ `nb` 文件夹中包含所有可运行的 notebooks。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FSxN976oDM4WaG5EtpSc9%2Funknown.png?alt=media&amp;token=7113ba12-5bcc-4bc6-9777-b9d4c440d0bf" 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="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fif8mAvc1au9Hl83IZzNm%2FDGX%20Station.png?alt=media&amp;token=1011c8a9-c6ba-48df-a726-d3bc3bc8e947" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
该 notebook 涵盖模型设置、数据集准备和训练器配置。每一步都可能需要一些时间，因为我们要下载一个非常大的模型、初始化数十亿个权重，并进一步优化以使其运行更快。&#x20;
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F4v0NmHdhiYCHFll8U8OD%2Funknown.png?alt=media&amp;token=69e3d279-4d59-4439-802f-11bd02fe39d3" 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 部分。我们可以从那里开始运行该 notebook。该 notebook 将使用大约 72 GB 的 GPU 内存，并花费约 10 分钟。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F8jYYievlemxDJBatevNV%2FDGX%20Station%202.png?alt=media&amp;token=efef1a26-a170-4690-972f-1a7cde67e9ea" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
每个单元格的运行都可能需要一些时间，因为我们需要下载模型、初始化权重，并进一步优化以获得更快的体验。该 notebook 会介绍数据集预处理和训练器设置。等我们到达 `trainer.train()` 单元格并执行后，训练就开始了。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FOxuma3ZZeEbxZrAWIgnq%2FDGX%20Station%203.png?alt=media&amp;token=17beb84e-eb56-4357-aee2-078c4db3eb84" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

现在训练已经完成，我们可以将模型保存以供后续使用，推送到 Hugging Face Hub 与全世界分享，或者导出为 GGUF 格式。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fy1UxtQ01avFK5BIkofwt%2Fimage.png?alt=media&amp;token=8d137818-a3a6-4d00-a9fd-1e41ed0483a5" alt=""><figcaption></figcaption></figure>

在以下位置了解更多关于 NVIDIA DGX Station 的信息： <https://www.nvidia.com/en-us/products/workstations/dgx-station/>


---

# 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/zh/bo-ke/dgx-station.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.
