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 printsWhat it means
2.x.x+cpu None None False, or None None with no suffixA CPU-only build. Go to cause 1.
a CUDA version (e.g. 12.6) and FalseA GPU build that can't reach the GPU: driver, environment or container.
a HIP version (e.g. 7.2...) and FalseAn 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/cu126

Pick 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

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

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).

← All error fixes