Most deep learning projects in a vision lab stall at the install screen, not at the math. The GPU driver, the CUDA toolkit and the training library each carry a version, and a mismatch surfaces as an import error, a segfault or an out-of-memory message before one image is trained on. This guide gives the order of operations that works: install the newest GPU driver first, choose the CUDA toolkit your training library actually supports, then prove the whole stack with the library's own example run before your parts go anywhere near it. You will also learn to read one measured VRAM number and predict with plain arithmetic whether a bigger batch fits, and to decide which machine trains and which one runs inference on the line.
The stack in three layers
Decide the order before you download anything. The environment is three layers, each with its own rule:
- GPU driver — always the newest available. The driver exposes the card to every toolkit you will ever install on that machine. A current driver runs toolkits far older than itself, because each toolkit declares a minimum driver version, never a maximum.
- CUDA toolkit — the version the training library names. The library's release notes list the toolkit versions it was built and tested against. One of those goes on the machine, not whatever the archive front page shows this week.
- Training library and its add-ons — last. The library sits on top of the toolkit and fails loudly when the two disagree, which is exactly what you want during set-up.
The one-way rule underneath all three: a newer driver with an older toolkit works; an older driver with a newer toolkit fails when the library loads its runtime. That asymmetry decides everything else in this guide. If the host itself is still an open question, the CPU and GPU checks for a machine vision deep learning setup size the box before the software goes on.
Install the driver first, and keep it current
Install the newest driver the card and OS support before any toolkit touches the disk. Toolkit installers often offer to bundle a driver; that copy is rarely the newest, so let a standalone driver install stand on its own. Reboot once, read the version back from the GPU utility that shipped with it, and write the number into the project folder.
Two habits keep this layer stable. After a Windows feature update, reinstall the driver: the update can substitute its own display driver, and the version you validated is gone without a trace in the training logs. And treat the driver version as part of the deployment record, alongside the toolkit and library versions — when the same run behaves differently on two machines, the driver is the first difference to check.
Choose the CUDA version your library supports
The toolkit decision is written down for you. The training library's release notes list the toolkit versions it supports; download one of those from the toolkit archive and install exactly that version. Grabbing the newest toolkit instead is the classic failure: a library built against older releases fails to load its CUDA runtime, and the error points at a version mismatch rather than at your code.
The compatibility direction is what makes this safe. A machine whose driver already carries support for toolkit releases up to CUDA 11 installs the CUDA 10.2 toolkit its library asked for and trains without a change, because the driver does not object to the older toolkit. The reverse has never been true.
Toolkits install side by side in their own versioned folders, so a second framework with a different requirement does not force a rebuild; install both and let each framework find its own through its configuration. The same discipline applies one layer up, in the GPU vision Python environment compatibility checks.
What training spends VRAM on
Three consumers share the card's memory, and only one of them moves with your batch size.
- Weights and gradients — fixed for a given model. The batch never touches them; the model architecture sets them.
- Activations per sample — the feature maps held for every image in the batch, plus the buffers the backward pass reads. This term scales close to linearly with batch size and input resolution.
- Framework overhead — algorithm workspaces, kernel binaries and loader buffers, typically a few hundred MB.
Small datasets mislead people here. A 67.5 MB folder of compressed training images sounds tiny, yet each image is decoded to raw float pixels, copied through augmentation, held through the forward pass and read again for gradients. In the run below, each sample slot costs 40 MB — about 38 times the whole source folder.
The second line isolates the batch term, so one measured run predicts every other batch size on the same card and model. And if the prior question is why a card at all, why GPUs beat CPUs for deep learning training covers the throughput case.
Worked example: batch 64 on a 5 GB card
Inputs. A mainstream desktop card with 5 GB of VRAM. The training library's bundled classification example, run with its default batch size of 64. A source dataset of 67.5 MB of images on disk. The GPU utility reports a peak of about 2.5 GB during the first epoch — half the card.
Rule in words. Activations dominate a classification run, and they scale with the batch. Divide the measured peak by the batch to get the per-slot working set; multiply that figure by any new batch to predict its peak; keep the predicted peak at or below 80% of VRAM so fragmentation and the occasional larger sample cannot push the run over.
Arithmetic.
- Peak to per-slot: 2.5 GB × 1,024 MB/GB = 2,560 MB, and 2,560 MB ÷ 64 = 40 MB per sample slot.
- Inflation check: 2,560 MB ÷ 67.5 MB ≈ 38, so the run holds about 38 times its source data in memory.
- Batch 96 prediction: 2.5 GB × 96 ÷ 64 = 3.75 GB, which is 75% of the card.
- Batch 128 prediction: 2.5 GB × 128 ÷ 64 = 5.0 GB — the full card, so the first out-of-memory error.
- Largest batch under the 80% line: 5 GB × 0.8 = 4.0 GB allowed, and 64 × (4.0 ÷ 2.5) = 102.4, so step to the next configured value below it, 96.
Decision. Keep batch 64 as the working default; it sits at 50% with room for a larger input resolution later. Raise to batch 96 when throughput matters: 3.75 GB leaves a 1.25 GB margin. Batch 128 does not fit this card and model — cut input resolution or model width instead of forcing it. The estimate errs slightly pessimistic, because the weights and gradients do not grow with the batch, and pessimistic is the safe direction.
Prove the stack with the library's own example
Run the library's bundled example before your own dataset. It exercises driver, toolkit and library together, and one pass there clears all three at once.
- Install the newest driver for the card and reboot.
- Install the toolkit version named in the library's release notes.
- Install the training library and its deep-learning add-ons.
- Open the bundled classification example and start a pass with its default batch size, 64.
- Watch peak VRAM in the GPU utility, or the GPU graph in the Windows task manager, through the first epoch.
- Record driver, toolkit, library, batch size and peak VRAM in the project folder.
If the example completes one pass, the environment is proven. Your own dataset changes the VRAM numbers you measured, not the stack underneath them. If it fails, the section below maps the message to the layer that caused it.
Where training and inference belong
Training and inference want different machines. Training saturates a card for hours, spikes VRAM to the limit and stops for nothing; a line-side controller answers camera requests against cycle-time deadlines. Put the training on a workstation or a dedicated box away from production, and deploy the finished model to the controller on the line.
For heavy training, a purpose-built quad-GPU training server does the job in one box:
- LAN ports
- 2 LAN ports
- USB 3 ports
- 3-4 USB 3 ports
For line-side inference, choose a controller that takes an accelerator card and still drives the camera and light chain:
- LAN ports
- 3-4 LAN ports
- USB 3 ports
- 2 USB 3 ports
- PoE
- PoE camera ports
- Light outputs
- 6 built-in channels
That controller pairs an Ultra 7 255H with 16 GB × 2 of memory, adds PCIe expansion and carries PoE camera ports and 6 built-in light channels. Ready-made inference terminals shorten the path further, with the runtime integration already in the box:
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
The dual-card terminal adds PoE camera ports and 8 built-in light channels; the single-card terminal covers the chain with 4 built-in light channels and 5+ LAN ports. Browse the vision controllers to match ports and memory to your camera count; for the workstation that hosts training, an industrial mini PC collection is a reasonable place to compare candidate hosts.
Pin the deployment stack once the model ships. The SDK version pinning that keeps edge inference devices from crashing is the same discipline: one recorded runtime, changed deliberately.
Four failures and what each one means
- Out of memory at the first batch. The batch is larger than the card allows, or a previous training process still holds memory. Halve the batch, restart the training process clean, and compare the new peak against the prediction. When the crash arrives as a segmentation fault instead of a clean message, the GPU memory and CUDA fixes for YOLO training segmentation faults walk the same fault family.
- The library cannot load its CUDA runtime. The toolkit and the library disagree. Install the toolkit version the release notes name; do not upgrade the toolkit hoping the error disappears.
- The GPU vanishes after a Windows feature update. The update substituted its own display driver. Reinstall the newest driver, reboot, and rerun the bundled example to confirm the stack again.
- Runs at batch 32, dies at batch 64. Activations doubled past the card. Use the scaling line from the worked example to compute the largest batch before the next attempt, rather than searching for a working value by trial.
Checks before you start training
- Driver version recorded from the GPU utility — every toolkit you install leans on it.
- Toolkit matches the release notes exactly — the archive lists versions, the notes choose one.
- Bundled example completes one pass — driver, toolkit and library proved together, before your data is involved.
- Peak VRAM recorded at your working batch — with the largest safe batch computed from it at the 80% line.
- Installers archived in the project folder — a rebuild becomes minutes of installing, not hours of searching.
- Training machine separated from the line-side controller — the deployment runtime is pinned and recorded on its own.
When the usual advice is wrong
Three pieces of folklore cost engineers real time.
Install the latest CUDA is the wrong default. The library's supported list decides, not the release news. The newest toolkit under a library built for older releases fails at load time, while a years-old toolkit runs happily on a current driver.
VRAM scales with dataset size is wrong. A 67.5 MB folder drove a 2.5 GB peak in the worked example. The loader streams samples; the batch and the model set the memory, and the disk sets how long an epoch takes.
Training and inference must share versions is also wrong. The model file crosses the gap; the runtime on the inference PC must match only itself. Pin the deployment runtime, record the training environment alongside the model, and change each deliberately — the same one-version-everywhere discipline that fixes Docker SDK version mismatches.
If you are sizing the machine that hosts all of this, work through the other systems guides, then compare hosts in an industrial panel PC range once your GPU and port needs are settled. Once the stack is proven and the numbers are recorded, the environment stops being the risk and the inspection becomes the work. For help matching a controller to your camera count, contact the applications team.
Questions
Can I run two CUDA toolkit versions on one machine?
Yes. Each toolkit installs side by side in its own versioned folder, and your build or runtime picks one through its library search path. Install every version your frameworks call for, keep the newest GPU driver on top of both, and record which toolkit trained each model so the deployment machine can be matched to it.
Does a bigger image dataset need more VRAM?
No. Dataset size drives disk space and epoch time, not VRAM. Peak memory is set by model size, batch size and input resolution, because the loader streams samples from disk instead of holding every image. Collect images for coverage, not for memory, and size VRAM once from a measured run at your working batch.
Why does training run out of memory partway through an epoch?
A crash that arrives mid-run usually means memory crept up after a clean start: growing augmentation caches, a validation pass stacked on training, or a second process sharing the card. Restart clean, watch the peak across a whole epoch rather than the first batches, and if the top still touches the card limit, drop the batch by half.
Does the deployment GPU have to match the training GPU?
No. A trained model runs on any GPU the inference runtime supports; the network architecture travels, not the silicon it trained on. What changes between cards is VRAM and throughput, so validate inference latency against the line's cycle time on the actual deployment card before the model ships.
Must the inference PC run the same CUDA version as the training machine?
Not necessarily. Export the trained model in the format your runtime library reads, then pin the deployment machine to the CUDA version that runtime supports. What must match is the runtime stack on the inference PC, not the toolkit that did the training. Keep a record of both versions alongside the model file.



