Free | No tracking | Every fact with a source|German and English

Error / Graphics card and drivers

RuntimeError: No CUDA GPUs are available (PyTorch does not see a usable NVIDIA graphics card)

PyTorch is installed with CUDA, but on startup it can't find a graphics card it is allowed to use.

The message

RuntimeError: No CUDA GPUs are available

Affects: Python

Why is this happening?

Most often, the card is hidden by the environment variable CUDA_VISIBLE_DEVICES: If it is set to -1, an empty value, or a number that does not exist (for example 1, even though only card 0 is present), no program can see the GPU. This kind of value often remains from a test or a startup file. Less often, the NVIDIA driver is damaged or missing.

How to fix it

  1. Check in the terminal with nvidia-smi whether Windows recognizes the card at all. If you get an error or no card, reinstall the NVIDIA driver.
  2. Check the variable: in PowerShell $env:CUDA_VISIBLE_DEVICES, in Command Prompt echo %CUDA_VISIBLE_DEVICES%. If it says -1, nothing meaningful, or a number that is too high, that's the cause.
  3. Delete the variable in the environment variables (sysdm.cpl → tab „Erweitert“ → „Umgebungsvariablen…“) and also check startup files (.bat) to see whether they contain set CUDA_VISIBLE_DEVICES=.
  4. If you want to choose a specific card: The numbers start at 0 in the order from nvidia-smi. With only one graphics card, it is always 0.
  5. Then close all terminals, open a new one, and restart the program.
  6. Test in your environment: python -c "import torch; print(torch.cuda.is_available(), torch.cuda.device_count())" should output True and at least 1.

Better not: Do not set CUDA_VISIBLE_DEVICES permanently for the whole system, otherwise the value will affect all programs.

Set up from scratch again

If it still doesn’t work after that, a fresh setup step by step often helps:

Terms for this

Similar errors

Sources

Checked on Oct 27, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.