# 在 MacOS 上安装 Unsloth

要在本地 Apple MacOS 设备上本地安装 Unsloth，请按照以下步骤操作：

### 安装 Unsloth

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

使用相同的命令进行更新或使用 `unsloth studio update`.

### 启动

每次你想再次启动 Unsloth 时：

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

有关详细的 Unsloth Studio 安装说明和要求， [请查看我们的指南](https://unsloth.ai/docs/zh/xin-zeng/studio/install).

### 卸载

要在 macOs 上卸载 Unsloth Studio，请按照以下 4 个步骤操作：

#### **1. 移除应用程序**

* MacOS、Linux： `rm -rf ~/.unsloth/studio/unsloth ~/.unsloth/studio/studio`

这会移除应用程序，但会保留你的模型检查点、导出、历史记录、缓存和聊天内容。

#### **2. 移除快捷方式和符号链接**

**macOS：**

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

#### **3. 移除 CLI 命令**

**macOS、Linux：**

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

#### **4. 移除所有内容（可选）**

如需同时删除历史记录、缓存、聊天内容、模型检查点和模型导出，请删除整个 Unsloth 文件夹：

* MacOS、Linux： `rm -rf ~/.unsloth`

请注意，下载的 HF 模型文件是单独存储在 Hugging Face 缓存中的——以上步骤都不会将其删除。请参见 **删除模型文件** 如下，如果你想释放那部分磁盘空间。

{% hint style="warning" %}
注意：使用 `rm -rf` 命令将会 **删除所有内容**，包括你的历史记录、缓存、聊天内容等。
{% endhint %}

如果你仍然遇到与 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 %}

### **删除模型文件**

你可以从模型搜索中的垃圾桶图标删除旧模型文件，或者从 Hugging Face 缓存目录中移除相关的缓存模型文件夹。

默认缓存位置是：

{% code expandable="true" %}

```bash
~/.cache/huggingface/hub/
```

{% endcode %}

如果 `HF_HUB_CACHE` 或 `HF_HOME` 已设置，请改用该位置。在 Linux 和 WSL 上， `XDG_CACHE_HOME` 也可以更改默认缓存根目录。你可以通过以下方式检查：

{% code expandable="true" %}

```bash
echo ${HF_HUB_CACHE:-${HF_HOME:-${XDG_CACHE_HOME:-$HOME/.cache}/huggingface}/hub}
```

{% endcode %}

要删除特定模型，请移除其文件夹（例如 `models--unsloth--Llama-3.1-8B-bnb-4bit`）从缓存目录中移除。要清除所有已缓存的模型：

{% code expandable="true" %}

```bash
rm -rf ~/.cache/huggingface/hub/
```

{% 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/zh/kai-shi-shi-yong/install/mac.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.
