Skip to content

How-ToGPU

How to Train a Custom YOLO Object Detection Model on Your Own PC

Ultralytics YOLO lets you train your own object-detection AI on your PC, so your images never leave your machine. Following Ultralytics' official docs, we cover installing PyTorch and Ultralytics, labelling images in YOLO format, writing a dataset file, training on your GPU, key settings, resuming and Windows quirks.

By , Systems & Technical Editor

5 min read

How to Train a Custom YOLO Object Detection Model on Your Own PC

Ultralytics YOLO is a free, open-source toolkit for training your own object-detection AI: teach it to spot your products on a shelf, birds at a feeder or faults on a circuit board, then run the model on your PC. Training on your own graphics card means your images never leave your machine and there's no cloud bill. Contains no training times or accuracy results of our own.

If you only want to use a ready-made detector for home security cameras rather than train one, our guide to setting up Frigate for local AI object detection is the better starting point.

What you need

Item

What Ultralytics documents

Python

3.8 or newer

PyTorch

1.8 or newer; install a CUDA build first if you have an NVIDIA card

GPU

Optional. Training uses GPU 0 when one is available and falls back to the CPU otherwise

Other GPUs

AMD via a PyTorch ROCm build on Linux, Intel via device=xpu:0, Apple silicon via device=mps

Model

A pretrained checkpoint such as yolo26n.pt, which downloads automatically

Data

Your own labelled images in YOLO format (covered below)

Ultralytics doesn't publish a minimum VRAM figure for training. Memory use depends on the model size, image size and batch size, and the training page offers an automatic batch mode (covered in step 5) that sizes the batch to your card. A 16GB card such as the ASUS RTX 5060 Ti 16GB Dual OC (the 16GB model, not the 8GB version) gives more room for larger models and bigger batches than an 8GB card. NVIDIA lists the RTX 5060 Ti with 16GB or 8GB of GDDR7, so check which version you're buying.

Step 1: Install PyTorch, then Ultralytics

Ultralytics' quickstart notes that PyTorch requirements vary by operating system and CUDA version, and recommends installing PyTorch first if you need a specific build. On Windows with an NVIDIA card, follow our guide to installing PyTorch with CUDA on Windows. AMD owners should see installing PyTorch with ROCm on Windows, though Ultralytics' own docs describe AMD training on Linux, and Intel Arc owners can use installing PyTorch for Intel Arc on Windows.

Then, inside a Python virtual environment, install the package:

pip install -U ultralytics

Ultralytics also documents a conda-forge install and an official Docker image. If you'd rather keep AI tools in Linux, see how to set up WSL2 for GPU local AI.

Step 2: Check it works

Run a first prediction from the terminal:

yolo predict model=yolo26n.pt

The pretrained weights download automatically, the model runs on two bundled sample images, and the command prints where it saved the annotated results (runs/detect/predict on a first run). If this falls back to the CPU on a PC with an NVIDIA card, PyTorch can't see your GPU; our guide to fixing "PyTorch CUDA not available" covers the usual causes.

Step 3: Label your images

Each training image needs a matching text file describing the objects in it. Ultralytics' YOLO format rules are:

  • One .txt file per image, with the same name. Images with no objects don't need a file.

  • One row per object: class x_center y_center width height.

  • Box coordinates are normalised from 0 to 1, so divide pixel values by the image width and height.

  • Class numbers start at 0.

You won't type these by hand. A free labelling tool draws the boxes and writes the files for you: X-AnyLabeling (a desktop app), CVAT Community and Label Studio (both run as local web apps) all list YOLO export. If you have a COCO-format dataset instead, Ultralytics' datasets page documents a convert_coco tool for converting it to YOLO labels.

Step 4: Write a dataset YAML file

Split your labelled images into a training set and a validation set, organised as in Ultralytics' small COCO8 example dataset (its YAML points at images/train and images/val), then create a YAML file such as mydata.yaml:

path: datasets/mydata
train: images/train
val: images/val
names:
  0: robin
  1: blue tit

path is the dataset root, train and val are relative to it, and names maps each class number to a name. The validation set is what Ultralytics uses to pick the best checkpoint, so keep some images out of training.

Step 5: Start training

Start from a pretrained model, which Ultralytics recommends for training, rather than from scratch:

yolo detect train data=mydata.yaml model=yolo26n.pt epochs=100 imgsz=640

Useful settings from the training documentation:

Argument

What it does

device=0

Use the first GPU; device=cpu forces CPU, device=mps uses Apple silicon

batch=-1

Auto batch size for about 60% of available CUDA memory; batch=0.70 targets 70%

imgsz=640

Training image size (the default)

patience=100

Stop early if validation results don't improve for this many epochs (100 is the default)

cache=True

Keep images in RAM for faster loading, at the cost of more memory; cache=disk uses the drive

workers=8

Data-loading worker threads (8 is the default)

Ultralytics' training tips page suggests 300 epochs as a starting point, reducing it if the model overfits early. Mixed-precision (AMP) training is on by default on CUDA GPUs, which lowers memory use. If you hit out-of-memory errors, reduce the batch size step by step; you can watch usage with our guide to checking VRAM usage on Windows.

Windows tip: if you start training from a Python script and get a RuntimeError about multiprocessing, wrap your training code in an if __name__ == "__main__": block, as Ultralytics advises.

Step 6: Resume, test and use your model

Training saves checkpoints at the end of each epoch. If a run is interrupted, resume it with:

yolo train resume model=path/to/last.pt

Ultralytics saves the checkpoint with the best validation results as best.pt, alongside last.pt, in the training run's folder. Test it on new images with yolo predict model=path/to/best.pt source=path/to/images, or point source=0 at a webcam.

Multi-GPU and licence notes

  • Two GPUs: Ultralytics supports device=0,1, but its docs say multi-GPU training doesn't work on Windows with the official PyTorch wheels for torch 2.4 and later. Use Linux or WSL2, or train on one GPU on Windows.

  • Licence: Ultralytics is released under AGPL-3.0, which suits students, researchers and hobbyists. Ultralytics sells an Enterprise Licence for using its software and models in commercial products without the AGPL's open-source requirements, so check before using a model in a business.

The bottom line

Install CUDA-enabled PyTorch and then pip install -U ultralytics, label your images in YOLO format, describe them in a short YAML file and run yolo detect train from a pretrained YOLO26 checkpoint. Use batch=-1 to size batches to your graphics card, and train on Linux or WSL2 if you want to use two GPUs. Forge PC hasn't tested it.

In this article

Sources

  1. 01Ultralytics Docs: Install Ultralytics (Quickstart)
  2. 02Ultralytics Docs: Model Training with Ultralytics YOLO (Train mode)
  3. 03Ultralytics Docs: Object Detection Datasets Overview
  4. 04Ultralytics Docs: Model Training Tips & Best Practices
  5. 05Ultralytics README (GitHub)
  6. 06X-AnyLabeling README (GitHub)
  7. 07CVAT README (GitHub)
  8. 08Label Studio Docs: Export annotations and data
  9. 09NVIDIA GeForce RTX 5060 family specifications

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

Best GPU for Blender in 2026

Best Picks

Best GPU for Blender in 2026

Building or upgrading a PC for Blender rendering? The GPU and its VRAM matter most. We pick the RTX 5070 Ti, RTX 5090, RTX 5060 Ti 16GB, Arc B580, RX 9070 XT and Radeon AI PRO R9700 using the Blender manual, official specs and Puget Systems' credited test results.

Hannah Vance8 min

Best Free Emulators for PC in 2026

Best Picks

Best Free Emulators for PC in 2026

The best free emulators for PC in 2026: RetroArch for retro systems in one app, PCSX2 for PS2, Dolphin for GameCube and Wii, DuckStation for PS1 and PPSSPP for PSP. We compare the systems each covers, licences, BIOS needs, hardware requirements and features from each project's official site, and explain how to stay legal with your own games and BIOS dumps.

Hannah Vance6 min

DLAA vs DLSS: Which NVIDIA Setting Should You Use?

Versus

DLAA vs DLSS: Which NVIDIA Setting Should You Use?

DLAA and DLSS Super Resolution use the same NVIDIA AI model but do opposite jobs: DLSS renders at a lower resolution and upscales for more frames, while DLAA stays at native resolution and uses AI purely for anti-aliasing. Using NVIDIA's documentation, we compare image quality goals, performance, RTX support and models, and show how to enable DLAA with the NVIDIA app.

Callum Reid5 min

How to Set Up PCSX2 on Windows: Play Your PS2 Games on PC

How-To

How to Set Up PCSX2 on Windows: Play Your PS2 Games on PC

PCSX2 can play much of the PlayStation 2 library on a Windows PC at higher resolutions than the original console. Using PCSX2's official documentation, we explain the hardware you need, how to install it, how to dump the BIOS from your own PS2 and your game discs, which renderer to choose, how to save safely and what to check if games run slowly.

Marcus Thorne8 min