For the complete documentation index, see llms.txt. This page is also available as Markdown.

Train model locally on Windows (Advanced)

Connect Google Colab to a local Jupyter runtime and GPU.

Reminder: All code and scripts for this project are executed in the cloud. Open the Google Colab Notebook and select Runtime > Run all to execute the setup.

Train in Google Colab while keeping datasets, models, and outputs on your computer.

This workflow connects Colab to a local Jupyter server on Windows. It also uses a dedicated Python environment.

Install 64-bit Python 3.13 or earlier before starting. Use the same Python installation throughout.

Connect Colab to your computer

1

Install JupyterLab

Install JupyterLab from the Jupyter installation guide.

JupyterLab installation instructions
2

Start a local Jupyter server

Open PowerShell and run:

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 --NotebookApp.allow_credentials=True

Keep this terminal open while using the local runtime.

3

Fix a missing jupyter command

If PowerShell reports that jupyter is not recognized, add Python's Scripts folder to your user Path.

  1. Press Windows, search for Environment Variables, then select Edit the system environment variables.

  2. Select Environment Variables.

  3. Under User variables, select Path → Edit → New.

  4. Add your Python Scripts path. For example:

    C:\Users\<your-username>\AppData\Roaming\Python\Python313\Scripts
  5. Select OK in every dialog.

  6. Close and reopen PowerShell.

Windows Environment Variables dialog
4

Copy the local server URL

When the server starts, PowerShell displays a URL with a token. Copy the complete URL.

Local Jupyter server URL in PowerShell

The address resembles http://localhost:8888/?token=....

Copying the local Jupyter server URL
5

Connect Google Colab

In Colab, select Connect → Connect to local runtime.

Google Colab Connect to local runtime dialog

Paste the local server URL, then select Connect.

Work with local files

Colab now uses your local runtime and storage. Your datasets, models, and training outputs remain on your local drive.

Create an empty project folder before training. This keeps generated files organized.

Colab’s Files pane may not immediately show local file changes. Use the local Jupyter URL to verify files and folders.

Local Jupyter file browser

Open the project folder in Jupyter. It contains your datasets, models, charts, and training outputs.

Project folder in the local Jupyter file browser

Use 64-bit Python 3.12 or earlier. Download it from the Python website.

Python version requirement

Locate the Petoi_Workspace folder.

Empty Petoi Workspace folder in Windows Explorer

Create and activate the virtual environment

Right-click the folder, then select Open in Terminal.

Create the environment. Replace 3.10 with your installed Python version.

Creating a virtual environment from PowerShell

Activate the environment:

If PowerShell blocks activation, run cmd. Then run the activation command again.

PowerShell error while activating the virtual environment
Opening Command Prompt from PowerShell

Install GPU dependencies

Update pip and install the Jupyter kernel:

Install PyTorch with CUDA:

PyTorch and CUDA packages installed in the virtual environment

Verify that PyTorch detects your GPU:

Continue only when the command returns True.

Register and select the kernel

Register the virtual environment as a Jupyter kernel:

Registering the Petoi Workspace Jupyter kernel

In Colab, select the Python (Petoi Workspace) kernel. Reconnect to the local runtime if prompted.

Selecting a local kernel in Google Colab
Connecting Google Colab to a local kernel

If the connection resets, connect to the local runtime again.

Reconnecting to the local runtime in Google Colab

Rerun the GPU check. It should show your GPU.

GPU available in the local Colab runtime

Before start training, remember to relocate your folder:

Install Ultralytics

Run this in a Colab cell after connecting to the local runtime:

Confirm that it is installed in the virtual environment:

The displayed path must contain venv\Lib\site-packages.

Ultralytics installed in the virtual environment

If the package is missing, activate the virtual environment and install it again.

Checking the Ultralytics installation with pip show

Restart the Colab session after installing packages. Then reconnect to the local runtime.

Restarting the Google Colab kernel

Train with local files

Before training, confirm that the notebook uses your project folder. Training files save there.

If a restart changes the working folder, select the project folder again in Jupyter.

Selecting the project folder before training

Export the final model

Exit the local environment before continuing in cloud training.

Exiting the local environment before cloud export

Upload the model to Colab by dragging it from the Files pane.

Preparing the cloud environment for model export

Continue with the cloud export steps by running the code block.

Running the cloud export command

Run the remaining code blocks to complete the export.

The NPU must show 100% utilization during camera inference. Otherwise, verify the full_integer_quant export.

NPU utilization during camera inference

Last updated