torch.cuda.is_available() returns False
The most common cause is a CPU-only PyTorch build, which is what Windows gets by default. The others are the driver, the environment, or on AMD, permissions. One command tells you which.
Diagnose it first
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.version.hip, torch.cuda.is_available())"| What it prints | What it means |
|---|---|
2.x.x+cpu None None False, or None None with no suffix | A CPU-only build. Go to cause 1. |
a CUDA version (e.g. 12.6) and False | A GPU build that can't reach the GPU: driver, environment or container. |
a HIP version (e.g. 7.2...) and False | An AMD ROCm build that can't see the GPU. Go to AMD. |
1. You installed a CPU-only build
Calling CUDA functions on it raises AssertionError: Torch not compiled with CUDA enabled.On Windows, a plain pip install torch from PyPI always gives you this: PyPI's Windows wheels are CPU-only (their CUDA dependencies are declared for Linux only), so the GPU build has to come from PyTorch's own index:
pip uninstall torch
pip install torch==2.14.0 --index-url https://download.pytorch.org/whl/cu126Pick the CUDA build that matches your GPU and driver with the install checker: an older GPU may need a specific build, and a newer one may need a newer build than cu126. On Linux, a plain pip install torch does get a CUDA build, but some tools and environments pull the +cpu one; uninstall and reinstall from the right index. macOS has no CUDA at all (Apple GPUs use the mps backend).
2. The NVIDIA driver is missing or too old
Run nvidia-smi. If the command fails, no driver is loaded; install one from NVIDIA (PyTorch reports this as Found no NVIDIA driver on your system). If it works, compare the driver with what your build needs: PyTorch warns that The NVIDIA driver on your system is too old andis_available() returns False. See the driver error page for the numbers.
3. The GPU is hidden from the process
CUDA_VISIBLE_DEVICESset to an empty string or to device numbers that don't exist hides every GPU. Check withecho $CUDA_VISIBLE_DEVICES.- Under WSL2, install the NVIDIA driver on Windows only. Installing a Linux NVIDIA driver inside WSL2 breaks GPU access.
4. You're inside a container without GPU access
Docker containers only see the GPU when started with --gpus all (or the Compose / Kubernetes equivalent) and the NVIDIA Container Toolkit is installed on the host. The CUDA Toolkit itself only needs to be inside the image; the host needs just the driver and the toolkit.
5. AMD: a ROCm build that can't see the GPU
- ROCm builds use the same
torch.cudaAPI, sois_available()is the right check. - Your user needs access to the GPU device files, which ROCm's install guide grants through the
renderandvideogroups. Check withgroups. - Run
rocminfo: if your GPU'sgfxname isn't listed, the driver or ROCm installation is the problem, not PyTorch. - If the GPU is visible but its gfx target isn't one ROCm or the PyTorch build supports, see hipErrorNoBinaryForGpu and ROCm on consumer GPUs.
Sources: PyPI's Windows wheel metadata for torch 2.14.0; error text from PyTorch's torch/cuda/__init__.py and c10/cuda/CUDAFunctions.cpp; WSL2 and container requirements from NVIDIA's CUDA on WSL and Container Toolkit guides (see CUDA versions).