跳至主要内容
筛选器及更多
模型: Qwen3-Coder-30B-A3B
推荐系统内存: 32 GB
30 分钟
初级
codingvscodeqwenllm
LM Studio 最新版本
Visual Studio Code 1.130.0
LM Studio 最新版本
Visual Studio Code 1.130.0
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
LM Studio 最新版本
Visual Studio Code 最新版本
上次验证时间: 2026年10月
设备系列
处理器
OS

使用 VS Code 和 Qwen3-Coder 进行本地 LLM 编码

在本地运行 Qwen3-Coder,配合 VS Code 使用,实现私密代码辅助。

使用 VS Code 和 Qwen3-Coder 进行本地 LLM 编码

概述

编程智能体是强大的工具,让开发者能够与由大语言模型(LLM)驱动的 AI 智能体协作,从而赋能开发者。它们可以嵌入到开发环境中,例如终端或 VS Code,从而无缝集成到开发者的工作流程中。

本教程演示了如何使用 Cline、VS Code 和 LM Studio,完全在本机运行编程智能体。

你将学到什么

  • 如何运行带有 Cline 编程智能体的 VS Code,以辅助软件工程任务。
  • 如何配置 Cline,使其与 LM Studio 通信,以本地推理编程智能体。
  • 如何使用本地编程智能体解决实际的软件工程任务。

设置内存配置

对于 Ryzen AI Halo,专用 GPU 内存默认为 64GB,这对大多数工作负载来说已经足够。对于更大的模型或更长的上下文,将其增加到 96GB 可能会有所帮助。要进行调整,请打开 AMD Software: Adrenalin Edition™,并导航到 Performance → Tuning → AMD Variable Graphics Memory。重启后更改才会生效。

AMD Software Adrenalin Edition — AMD Variable Graphics Memory panel

要更改专用 GPU 内存值,请打开 AMD Software: Adrenalin Edition™,并导航到 Performance → Tuning → AMD Variable Graphics Memory。重启后更改才会生效。

AMD Software Adrenalin Edition — AMD Variable Graphics Memory panel

在 Linux 上,要运行更大的模型,请增加 GPU 可用的共享内存池。这可能需要将 BIOS 中的专用 GPU 内存设置为最小值,以便最大化共享内存池。

对于 AMD Ryzen™ AI Halo,默认为 96GB 共享内存。要修改此设置,请打开 AMD Ryzen™ AI Developer Center,然后转到设置(Settings)选项卡。在图形性能设置(Graphics Performance Settings)下,增加共享视频内存(Shared Video Memory)滑块,然后单击应用更改(Apply Changes),并重启以使更改生效。

AMD Ryzen AI Developer Center — Graphics Performance Settings with Shared Video Memory slider

通过更改内核的转换表管理器(Translation Table Manager,TTM)页面设置来增加共享内存池。AMD 建议在 BIOS 中将最小专用 VRAM 设置为(0.5 GB),以便最大数量可用作共享内存。

  1. 安装 pipx 工具,并将 pipx 安装的 wheel 的路径添加到系统搜索路径中:

    Terminal window
    sudo apt install pipx
    pipx ensurepath
  2. 从 PyPI 安装 amd-debug-tools wheel:

    Terminal window
    pipx install amd-debug-tools
  3. 查询当前的共享内存设置:

    Terminal window
    amd-ttm
  4. 增加共享内存分配(单位为 GB):

    Terminal window
    amd-ttm --set <NUM>
  5. 重启后更改才会生效。

检查软件更新

注意:如果尚未安装 VS Code,你可以通过 Ryzen AI Developer Center 进行安装。

在开始之前,请确保你的 Ryzen AI Halo 已安装最新软件。打开 AMD Ryzen™ AI Developer Center,检查应用本身以及其他软件是否有可用更新。

进入 Updates 选项卡。如果有可用更新,请安装并重启后再继续。

AMD Ryzen AI Developer Center — Updates tab on Windows

进入 Manage 选项卡。如果有可用更新,请安装并重启后再继续。

AMD Ryzen AI Developer Center — Manage tab on Linux

安装软件先决条件

LM Studio

LM Studio 可以从 AMD Ryzen™ AI Developer Center 安装。进入 Updates 标签页,如果尚未安装 LM Studio,请安装它。

为了让 LM Studio 看到预安装模型,请进入 Settings > General > Models Directory。然后将路径改为 C:\Users\Public\models

Adding pre-installed models to LM Studio

  1. 从这里下载安装程序:https://lm-studio.ai/download
  2. 安装。

提示:安装后,启动一次 LM Studio 来初始化 CLI(lms)。

注意:你可以选择安装 .deb 或 AppImage。

  1. 从这里下载 AppImage:https://lm-studio.ai/download?os=linux
  2. 运行 sudo apt install libfuse2
  3. 运行 cd ~/Downloads
  4. 运行 chmod +x LM-Studio-*.AppImage
  5. 运行 ./LM-Studio-*.AppImage

提示:安装后,启动一次 LM Studio 来初始化 CLI(lms)。

为了让 LM Studio 看到预安装模型,请进入 Settings > General > Models Directory。然后将路径改为 /var/cache/models。

Adding pre-installed models to LM Studio


Visual Studio Code

VS Code 可以从 AMD Ryzen™ AI Developer Center 安装。进入 Updates 选项卡,如果尚未安装 VS Code,请进行安装。

VS Code 可以从 AMD Ryzen™ AI Developer Center 安装。进入 Manage 选项卡,如果尚未安装 VS Code,请进行安装。

  1. 从以下地址下载 Windows 安装可执行文件:https://update.code.visualstudio.com/latest/win32-x64-user/stable。
  2. 运行下载的 VSCodeUserSetup-x64-<version>.exe 以安装 VS Code。
  1. 从以下地址下载 Debian 安装包:https://update.code.visualstudio.com/latest/linux-deb-x64/stable。
  2. 安装下载的 code_<version>_amd64.deb 软件包。

启动并配置 LM Studio

我们将使用 LM Studio 来提供支撑编程智能体的 LLM。

  • 在搜索栏中搜索 LM Studio 并启动该应用程序。你将看到如下页面。

LM Studio 初始屏幕

接下来,我们需要在系统中加载 LLM。我们将使用 Qwen3-Coder-30B-A3B 模型,并设置较大的上下文长度。如果尚未安装该模型,请先通过 Model 标签页(搜索图标)下载;如果系统已预装该模型,则可以直接加载。

  • 点击 LM Studio 窗口顶部的搜索栏,或按 CTRL+L。点击“手动选择模型加载参数”(Manually choose model load parameters)开关,然后点击 Qwen3-Coder-30B-A3B 模型。
  • 将上下文长度从 4096 更改为 32768,并确保 GPU Offload 设置为最大值。然后,点击 Load Model

选择模型

我们使用较大的上下文长度,以便智能体能够处理大型代码库并记住已进行的更改。

配置模型

接下来,我们需要启用 LM Studio 服务器。

  • 点击 LM Studio 左侧的 Developer 标签页,或按 CTRL+2。
  • 检查状态开关,确保服务器处于 Running 状态。

服务器状态

启动并配置 VS Code

我们将在 VS Code 中安装 Cline 扩展,并将其连接到我们刚刚创建的 LM Studio 服务器。

  • 在搜索栏中搜索 VS Code 并启动该应用程序。
  • 点击 VS Code 左侧栏中的 Extensions 图标,并搜索 Cline。然后,点击 Install 按钮。

安装 Cline 扩展

  • 左侧应该会出现一个 Cline 图标。点击该图标以打开 Cline。将会出现一个窗口,询问 How will you use Cline?(你将如何使用 Cline?)。由于我们将使用通过 LM Studio 运行的本地 LLM,请选择 Bring my own API Key(使用我自己的 API 密钥)并点击 Continue。

创建账户

接下来,我们需要配置 Cline,使其与我们设置的 LM Studio 服务器通信。

  • 将 API Provider 设置为 LM Studio,模型设置为 Qwen3-Coder-30B-A3B-GGUF。

提示:可能会有更新的模型可用。如果需要,可以考虑下载并切换到 Qwen3.6 模型。

模型配置

创建你的第一个项目

让我们使用本地智能体来创建一个网站!打开 VS Code,选择一个你希望 Cline 创建文件的目录。

  • 为此,请点击 VS Code 左上角的 File -> Open Folder,然后选择一个文件夹,例如 Documents。

VS Code 空文件夹

现在我们已准备好向本地编程智能体输入提示词。

  • 点击左侧栏中的 Cline 扩展,输入提示词以启动智能体。例如,我们可以使用以下提示词:
Create a website showcasing the ability to run local large-language models on an AMD device.

随后,智能体将开始根据提示词创建文件。作为用户,你可以在 VS Code 中观看代码生成的过程,如下所示。每次 Cline 想要创建文件时,你可能需要点击 Save。

Cline 代码生成

生成软件后,智能体任务完成,你可以运行该应用程序。在此示例中,智能体编写了三个文件:index.html、script.js 和 styles.css。只需双击该 HTML 文件,即可加载并与生成的网站进行交互。

后续步骤

生成网站后,你可以继续与 Cline 合作以改进该网站。以下是两个可能的改进方向:

  • 文档:只需向智能体提示 Add a README,智能体即可生成一份 README.md 文件,用于记录该网站的相关文档。
  • 动画:向模型提示 Add an animation that visually represents a large language model running on a laptop.(添加一个动画,直观展示大语言模型在笔记本电脑上运行的过程),即可为网站生成一个动画。

我们鼓励读者尝试使用此设置生成其他应用程序。以下是我们尝试过的一些有趣示例:

  • 复古街机游戏:尝试一些其他提示词。使用以下提示词,还可以让智能体利用 PyGame 包,用 Python 创建复古风格的游戏,这也会很有趣:
Create a simple pong game using the PyGame python package.
  • 数据分析:编程智能体特别有用的一个领域是脚本编写和数据分析。以下提示词可展示本地模型生成用于股票价格可视化的数据分析软件的能力:
Write a Python script that fetches daily price data for AMD (ticker: AMD) from an online API (use the yfinance library so no API key is needed). Loads the last 365 calendar days of data into a Pandas DataFrame. Computes 20-day and 50-day simple moving averages of the closing price. Store the data in a sqlite database and when the script is first run check to see if the sqlite database contains the requested data, if not, fetch it from the API. Plots a single matplotlib line chart with: Close, SMA-20, and SMA-50. Include a title, axis labels, and a legend. Saves the figure to amd_price_sma.png in the current directory and prints the path when done. Allow the user to pass in command line arguments for the total time period of data, the time period for the simple moving average to calculate, as well as to provide different tickers.

资源

以下是一些了解编程智能体、Cline 以及在 上运行工作负载的更多资源:

需要有关此操作手册的帮助?

遇到问题或有疑问?请创建 GitHub issue,我们的团队会跟进处理。