Executable programs and extensions
Last updated
When PyTorch seems to use the CPU despite an NVIDIA GPU
When PyTorch runs on CPU, diagnose it in the same environment
An NVIDIA GPU1 can be visible while a PyTorch2 model still runs on CPU3. In the same terminal or notebook that ran the model, use nvidia-smi to check driver detection, a read-only Python snippet to inspect the PyTorch build and CUDA4 availability, then examine model placement and application logs. nvidia-smi, torch.version.cuda, and nvcc --version report different things.
If document summarization in an IDE is slow and CPU-bound while nvidia-smi on the same computer shows a GPU, check the system, Python environment, and model device in sequence. A terminal and IDE may use different Python installations, so run diagnostics in the environment where the failure occurred.
Check whether the driver detects the GPU
Run nvidia-smi to inspect the driver version, GPU detection, and memory use. If the command is missing or no device appears, check the operating system and driver before changing PyTorch packages. In WSL2, the Windows host provides the CUDA GPU driver; do not install a Linux NVIDIA driver inside WSL.
The CUDA Version shown by nvidia-smi is the level supported by the driver, not the installed development toolkit version. Check the toolkit compiler with nvcc --version. A prebuilt PyTorch package may include CUDA runtime5 components even when nvcc is absent, but a compatible driver is still required.
| How to check | What it tells you |
|---|---|
| nvidia-smi | GPU detected by the driver and its supported CUDA level |
| torch.version.cuda | CUDA build version of the currently imported PyTorch |
| nvcc --version | Compiler version of the installed CUDA development toolkit |

Run CUDA diagnostics in the failing Python environment
Run the code below in the same terminal or notebook where the model failed. It prints the Python path, PyTorch build, and CUDA availability for the current process; it does not run a model or tensor operation or change files.
First check that the Python path points to the expected environment. If not, correct the IDE interpreter and rerun. If torch.version.cuda is None, the imported PyTorch is likely not a CUDA build; torch.cuda.is_available() reports whether this process can use CUDA. These values may differ from the driver's CUDA level shown by nvidia-smi.
From CUDA 11 onward, minor-version compatibility within a major release is available under minimum driver conditions, with some feature limitations. New features, GPU architectures, PTX compilation, and library combinations may have additional requirements. If the result is False or an error identifies the driver, check the PyTorch selector and NVIDIA compatibility table.
import sys
import torch
print("Python:", sys.executable)
print("PyTorch:", torch.__version__)
print("PyTorch CUDA build:", torch.version.cuda)
print("CUDA available:", torch.cuda.is_available())
if torch.cuda.is_available():
print("GPU:", torch.cuda.get_device_name(0))
print("Device count:", torch.cuda.device_count())
Check the actual device in model parameters and app logs
CUDA available: True and a GPU name show that Python found a device. For a single-GPU model, next(model.parameters()).device can reveal parameter placement, but CPU may still be used if code selects it or tensor devices do not match. For a distributed model, inspect application logs and distribution settings instead of relying on the first parameter.
Run the same document summary and check whether logs record GPU selection or CPU fallback. A short request may show low GPU utilization, and VRAM6 use indicates model loading but not necessarily computation. PyTorch ROCm7 builds can use torch.cuda.* as a compatibility interface; on AMD, distinguish the backend with torch.version.hip8 and its installation guide. CUDA-specific libraries and custom operations may not work in other builds.

Change one item based on the diagnostic result
If nvidia-smi cannot find the GPU, check the card connection and whether the operating-system driver supports the GPU. For WSL2, inspect both host and guest configuration. If the GPU and driver appear but is_available() is False, examine the failing process's Python path and PyTorch build. Select the OS, package manager, Python, and compute platform in the official PyTorch selector, then install its recommended combination in the project environment.
If CUDA is True but the model remains on CPU, check the application's CUDA backend and GPU offload9 settings, and whether the model and context fit available VRAM and headroom. Insufficient memory can move some computation to CPU or cause failure. Change one relevant option at a time, rather than changing PyTorch and the application together, then retest with the same document.
Rerun the same task and collect error details
After changing a setting, rerun the same document summary in the same IDE notebook. Check logs for GPU/backend selection and runtime errors. If the problem persists, collect the GPU model and OS, driver version and CUDA display from nvidia-smi, Python path from the failing notebook, PyTorch version, torch.version.cuda, is_available() result, application device setting, and error message.
Redact personal directory names from the Python path before sharing it. Full environment variables or a success from another Python session are not needed to explain the current failure.
Terminology notes
GPU — A processor designed to handle many calculations in parallel. It performs model computations during AI inference.
Back to the textPyTorch — A software framework for building and running AI models. Check the compatible PyTorch version and hardware support along with the model.
Back to the textCPU — The central processor that runs the operating system and general-purpose instructions; in AI workloads it also handles tasks such as preprocessing and data movement.
Back to the textCUDA — A software platform for general-purpose computing on NVIDIA GPUs.
Back to the textRuntime — The software environment that provides facilities needed while a program runs. In local AI, it can also refer to a model execution engine.
Back to the textVRAM — Memory used by a graphics card’s GPU to store model weights and intermediate values.
Back to the textROCm — AMD’s software platform for AI and high-performance computing on GPUs. Support depends on the combination of GPU, operating system, driver, and framework versions.
Back to the textHIP — An API and runtime for portable GPU C++ code. It helps with porting CUDA code.
Back to the textOffloading — Moving some model data from GPU memory to system RAM or storage when capacity is limited. This adds data transfer.
Back to the text
Frequently asked questions
- What should you check first in this article?
- An NVIDIA GPU can be visible while a PyTorch model still runs on CPU. In the same terminal or notebook that ran the model, use nvidia-smi to check driver detection, a read-only Python snippet to inspect the PyTorch build and CUDA availability, then examine model placement and application logs. nvidia-smi, torch.version.cuda, and nvcc --version report different things.
- How much memory does it need?
- Run nvidia-smi to inspect the driver version, GPU detection, and memory use. If the command is missing or no device appears, check the operating system and driver before changing PyTorch packages. In WSL2, the Windows host provides the CUDA GPU driver; do not install a Linux NVIDIA driver inside WSL.
Read next
Executable programs and extensions
Do you need an NVIDIA GPU and CUDA for local AI?
Executable programs and extensions
Ollama: connecting a model on your computer to other apps
memory and model
How much VRAM or unified memory does a local LLM need?
Executable programs and extensions
How to Back Up and Restore a Local LLM You Already Use
