vscodeHow to Fine-tune LLMs in VS Code with Unsloth

Guide to fine-tuning models directly in Visual Studio Code via Unsloth and Google Colab.

You can now fine-tune LLMs directly from Visual Studio Code (VSCode), locally or by using Google Colab's extension. In this guide, you’ll learn how to connect any Unsloth fine-tuning notebook in VS Code to a Colab runtime, so you can train on your local or free Colab GPU.

1

Prerequisites

To begin we will need to have:

  • Installed VS Codearrow-up-right. Git (for cloning the notebook repo) should be installed by default.

  • A Google account (to authenticate with Colab)

  • Recommended: the Jupyter extension in VS Code (most setups already have it)

2

Install the Colab extension in VS Code

  1. Open Extensions in VS Code (Ctrl+Shift+X / Cmd+Shift+X)

  2. Search for “Colab” and install the Google Colab extension

3

Open an Unsloth notebook

  1. Clone the notebooks repository:

    git clone https://github.com/unslothai/notebooks
    cd notebooks
  2. Open your desired notebook. Unsloth supports most models including embedding, TTS. For example, we'll use Qwen3-4B RL: nb/Qwen3_(4B)-GRPO.ipynb

4

Select a kernel and choose Colab

In the notebook toolbar, click Select Kernel, then choose Colab

5

Add a new Colab server

After choosing Colab, you’ll see a dropdown with server options.

  1. Click + Add New Colab Server

  2. The first time, a browser window may open for Google authentication

    • Log in, grant access, then return to VS Code

6

Select GPU and name the server

  1. Set Hardware accelerator to GPU

  2. Choose a GPU type (for example T4, if available)

  3. Give the server a name (anything you like)

circle-info

Note: GPU availability depends on your Colab plan and current capacity. If you don’t see GPU options, see troubleshooting below.

7

Pick the Python kernel

Once connected to the Colab server, select the Python kernel that appears for that runtime (usually a Python 3 kernel).

8

Run the notebook

  • Click Run All in the notebook toolbar (or run cells top-to-bottom)

  • Watch the setup cells install dependencies and then start the Unsloth workflow

Troubleshooting

After Colab server disconnects, the notebook won’t run on a new server

What’s happening: If the notebook stays open while the Colab server disconnects, VS Code can get stuck in a bad kernel/runtime state after reconnecting. Related GitHub issuearrow-up-right.

Fix: Close the notebook tab completely and open the notebook again.

You can’t select a GPU (only CPU shows up)

Possible causes and fixes:

  • Colab free tier capacity: GPUs may be temporarily unavailable → try again later.

  • Not actually connected to a Colab runtime: re-check Select Kernel → Colab and ensure a Colab server is active.

  • Account/region restrictions or limits reached: you may need to wait or use a different Google account / plan.

Everything worked, but packages are “gone” after reconnecting

Colab runtimes are ephemeral. When a server restarts, you usually need to re-run the setup/install cells (often the first few cells in the notebook).

Last updated

Was this helpful?