What the False result means
is_available() is deliberately quiet. In the PyTorch source it returns False at once if the build was not compiled with CUDA. Otherwise it asks the CUDA runtime for a device count through cudaGetDeviceCount and returns True only if the count is above zero. The comment in the code says the check never throws and returns 0 if the driver is missing or cannot be initialized.
So the boolean hides the reason. The reason usually appears as a warning printed on first use, in the form "UserWarning: CUDA initialization: …". The messages PyTorch can print there include "Found no NVIDIA driver on your system", "The NVIDIA driver on your system is too old (found version 12080)" and "CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start". The driver number here is an example.
Scroll up in your log for that warning before you change anything. It usually names the cause directly.
References: PyTorch source: torch/cuda/__init__.py (is_available) · PyTorch source: c10/cuda/CUDAFunctions.cpp
Causes of torch.cuda.is_available() False, ranked
The most common cause is a CPU-only PyTorch build. It happens when pip or conda resolves a wheel without CUDA, or when a requirements file pins a +cpu build. torch.version.cuda returns None and torch.__version__ often ends in +cpu.
Second is a driver older than the CUDA runtime the wheel was built with. The PyTorch release matrix lists PyTorch 2.15 with stable CUDA 13.2 and experimental CUDA 13.4 builds. NVIDIA’s release notes set the minimum driver for any CUDA 13.x application at branch 580 or newer, and for 12.x at 525 or newer. A machine on a 570 driver can run a CUDA 12.6 build but not a CUDA 13.2 one.
Third is a container started without GPU access, for example docker run without --gpus. Fourth is CUDA_VISIBLE_DEVICES set to an empty string or a wrong index, which hides every GPU. Fifth is the wrong Python environment: the notebook kernel or script uses a different interpreter from the one where you installed the CUDA build. Last is a GPU or driver in a bad state, where nvidia-smi itself fails.
References: PyTorch release compatibility matrix (RELEASE.md) · PyTorch CUDA semantics
Run these diagnostic commands in order
Run python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available(), torch.cuda.device_count())" with the same interpreter your code uses. Then run nvidia-smi in the same shell or container. Its header shows the driver version and the highest CUDA version that driver supports.
Print echo $CUDA_VISIBLE_DEVICES; an empty value set on purpose hides all GPUs, while an unset variable shows them all. Run which python and pip show torch to confirm the interpreter and install location match. For a full report, python -m torch.utils.collect_env prints the PyTorch build, CUDA runtime, driver and GPU list in one block, which is also what PyTorch issue templates ask for.
| Command | Healthy result | Problem result |
|---|---|---|
| torch.version.cuda | A version such as 13.2 | None: CPU-only build |
| torch.cuda.device_count() | 1 or more | 0: no visible device |
| nvidia-smi | Table with driver and GPUs | Command not found or fails |
| echo $CUDA_VISIBLE_DEVICES | Unset or valid indices | Empty string or wrong index |
| which python | The env with the CUDA build | A different interpreter |
| python -m torch.utils.collect_env | CUDA build, driver and GPUs listed | CUDA used to build: None |
References: PyTorch CUDA semantics · NVIDIA System Management Interface · PyTorch source: torch/utils/collect_env.py
Fix a CPU-only or mismatched PyTorch build
Reinstall from the PyTorch wheel index for a CUDA version your driver supports. Use the selector on the PyTorch Get Started page to get the exact command. On 24 November 2026 the index at download.pytorch.org/whl/cu132 serves PyTorch 2.15.0, so the command is pip install torch --index-url https://download.pytorch.org/whl/cu132. Uninstall the old build first so pip does not keep it.
If you cannot upgrade the driver to 580 or newer, install an older PyTorch built for CUDA 12. The release matrix lists PyTorch 2.14 with a CUDA 12.6 build, and the cu126 index serves 2.14.1, which runs on any 525-or-newer driver under CUDA minor version compatibility.
You do not need a system CUDA toolkit for the PyTorch wheels; they ship their own CUDA runtime libraries. What you need is a new enough NVIDIA driver. The CUDA driver version is insufficient guide covers driver upgrades and forward compatibility.
References: PyTorch Get Started locally · PyTorch release compatibility matrix (RELEASE.md) · NVIDIA CUDA Toolkit release notes: driver versions
Fix containers, hidden devices and the wrong environment
In Docker, install the NVIDIA Container Toolkit on the host and pass the GPUs in. NVIDIA’s sample workload is docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi; if that prints a GPU table, the host side works and the problem is inside your image. The container uses the host driver, so the image’s CUDA version must not need a newer driver than the host has. See Docker with NVIDIA GPUs.
For hidden devices, unset CUDA_VISIBLE_DEVICES or set it to valid indices before Python starts. PyTorch’s source warns that changing it after the program starts can cause a CUDA unknown error. For Jupyter, install the CUDA build into the environment the kernel uses, or register that environment as a kernel.
One more trap: the CUDA notes say a process that has run is_available() may fail with a CUDA initialization error in later forks. If a DataLoader or multiprocessing worker reports no GPU, use the spawn start method, or set PYTORCH_NVML_BASED_CUDA_CHECK=1 for an NVML-based check that avoids this.
References: NVIDIA Container Toolkit sample workload · PyTorch source: c10/cuda/CUDAFunctions.cpp · PyTorch CUDA semantics
Symptom, check and fix table
Work down this table from the top. Each fix is cheap to try and the earlier rows are the most frequent.
| Symptom | Likely cause | Check | Fix |
|---|---|---|---|
| torch.version.cuda is None | CPU-only wheel | pip show torch, version suffix | Reinstall from a cu index URL |
| Warning: driver too old | Driver below 580 for CUDA 13 | nvidia-smi driver version | Upgrade driver or use a cu126 build |
| Warning: found no NVIDIA driver | No driver or no GPU passed in | nvidia-smi on host and in container | Install driver; add --gpus all |
| device_count() is 0, no warning | CUDA_VISIBLE_DEVICES hides GPUs | echo $CUDA_VISIBLE_DEVICES | Unset or set valid indices |
| Works in shell, not in notebook | Different Python environment | sys.executable in each | Install into the kernel env |
| False only in worker processes | CUDA initialized before fork | Start method of the workers | Use spawn or the NVML check |
| nvidia-smi itself fails | Driver or hardware fault | dmesg for NVIDIA errors | Reboot or replace the machine |
References: PyTorch release compatibility matrix (RELEASE.md) · NVIDIA CUDA Toolkit release notes: driver versions · NVIDIA Container Toolkit sample workload · PyTorch CUDA semantics
Prevent it on the next machine
Pin the index URL in your requirements or lock file, not only the version, so a fresh install gets the same CUDA build. Add a start-up assertion that fails fast: assert torch.cuda.is_available(), torch.version.cuda. A job that silently runs on the CPU for an hour costs more than one that crashes in a second.
Record the driver version with the job, and check it against your wheel’s CUDA version when you move to a new machine. Container images make this repeatable; portable GPU workloads covers packaging a job so it runs the same way across providers.
References: NVIDIA CUDA Toolkit release notes: driver versions
When the GPU itself is the problem
If nvidia-smi fails on the host, or the GPU disappears after an error, the fix is outside PyTorch: a driver reinstall, a reboot, or a replacement machine. On a rented GPU, report it to the operator with the nvidia-smi output and kernel log rather than spending hours on it.
A related case is a card too old for current builds. If your GPU is not supported by a current CUDA release, a newer data center card such as the L4 for light inference or the A100 for training removes the constraint. Size the memory first with the VRAM calculator.
References: NVIDIA System Management Interface
Checklist and next step
Read the CUDA initialization warning. Print torch.version.cuda and device_count(). Run nvidia-smi in the same environment. Match the wheel’s CUDA version to the driver. Pass --gpus all to containers. Check CUDA_VISIBLE_DEVICES and the interpreter path. Add a start-up assertion.
If you want a machine where the driver and GPU are ready when you log in, NeuraMesh rents cloud GPUs by the hour. Choose a GPU, plan, count, hours and region on rent GPUs, and you receive a confirmed quotation before anything is charged.
NeuraMesh prices for these GPUs
| GPU | Memory | Data center | Value |
|---|---|---|---|
| RTX 4090 | 24 GB | $0.46 | $0.40 |
| L40S | 48 GB | $1.26 | $0.54 |
| A100 | 80 GB | $1.56 | $0.98 |
| H100 | 80 GB | $2.88 | $2.00 |
Every order is confirmed in a quotation before you pay. See all GPU prices.
Questions readers ask
Why do I get torch.cuda.is_available() False when nvidia-smi works?
Usually PyTorch is a CPU-only build or was built for a newer CUDA than the driver supports. Print torch.version.cuda: None means CPU-only. If it shows 13.2, the driver must be branch 580 or newer under NVIDIA’s minor version compatibility rules.
Do I need to install the CUDA toolkit for PyTorch?
Not for the official pip wheels. They bundle the CUDA runtime libraries they need. You need a compatible NVIDIA driver, which nvidia-smi reports. A system CUDA toolkit matters only if you compile CUDA extensions yourself.
Which PyTorch build should I install for an older driver?
Pick a build whose CUDA major version your driver supports. NVIDIA lists 525 or newer for CUDA 12.x and 580 or newer for CUDA 13.x. On a driver between 525 and 580, use a CUDA 12.6 build, which the cu126 index serves for PyTorch 2.14.
Why is the GPU missing inside Docker?
The container was probably started without GPU access. Install the NVIDIA Container Toolkit on the host and run the container with --gpus all. Test with NVIDIA’s sample command, which runs nvidia-smi inside an Ubuntu container.
Can CUDA_VISIBLE_DEVICES cause this?
Yes. An empty value hides every GPU, and an index that does not exist leaves none visible. Set it before Python starts; PyTorch warns that changing it after start can produce a CUDA unknown error.
Sources and editorial notes
- PyTorch source: torch/cuda/__init__.py (is_available)
- PyTorch source: c10/cuda/CUDAFunctions.cpp
- PyTorch release compatibility matrix (RELEASE.md)
- PyTorch CUDA semantics
- NVIDIA System Management Interface
- PyTorch source: torch/utils/collect_env.py
- PyTorch Get Started locally
- NVIDIA CUDA Toolkit release notes: driver versions
- NVIDIA Container Toolkit sample workload
Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.
Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.


