torch.cuda.is_available() Returns False on RunPod: What It Means and What To Do Before Billing Starts A developer documented how torch.cuda.is_available() silently returning False on rented GPU pods like RunPod and Vast.ai caused training scripts to fall back to CPU while still billing at full GPU rates. The writeup explains that a CPU-only PyTorch build, an empty CUDA_VISIBLE_DEVICES, or an unloaded driver can all trigger the failure without an exception, and recommends replacing the standard cuda-or-cpu device pattern with a hard RuntimeError guard plus a pre-flight diagnostic tool, ComputeFence, to catch the problem before a paid job starts. You SSH into your pod. You run your training script. The loss starts printing. Everything looks normal. Except it is running at 24 seconds per iteration instead of 0.4. That is how I found out torch.cuda.is available had returned False on a Vast.ai pod a failure that hits RunPod users equally. No exception. No warning. My script resolved to CPU and kept running. I was paying full GPU rates and training on CPU the entire time. Why this happens without an error torch.cuda.is available returns False when PyTorch cannot find a usable CUDA installation. The reasons vary: None of these throw an exception at import time. PyTorch imports cleanly. nvidia-smi may show the GPU. The failure only surfaces when your code tries to use CUDA or never surfaces at all if your script silently falls back to CPU. The silent fallback is the expensive case Most training scripts use the standard pattern: python device = "cuda" if torch.cuda.is available else "cpu" When CUDA is unavailable, the script continues on CPU with no error and no warning. On a rented pod you typically will not notice until you check iteration speed or run nvidia-smi and see GPU utilisation at 0%. By then you have already paid for the warmup time, the dependency install, and however long training ran before you caught it. The hard guard below stops your training script from running but the pod is still billing while you diagnose. The goal is to catch this before you start the job, not after. Diagnose it in 10 seconds python3 -c "import torch; print torch. version , torch.version.cuda, torch.cuda.is available " If is available prints False, check: nvidia-smi pip show torch | grep -i version echo $CUDA VISIBLE DEVICES If torch.version.cuda is None, you have a CPU-only build. That is the most common cause on a fresh pod with the wrong template selected. Fix by cause Cause Fix ───────────────────────────────────────────────────────────────────── CPU-only build torch.version.cuda is None pip install --force-reinstall torch --index-url .../whl/cu124 CUDA VISIBLE DEVICES set to "" or -1 unset CUDA VISIBLE DEVICES or export CUDA VISIBLE DEVICES=0 Driver not loaded or incompatible Terminate the pod and rent a fresh one driver issues don't resolve inside the container Reinstalling PyTorch: A plain pip install torch will often do nothing if torch is already installed pip sees the version requirement as satisfied. Force a clean replacement: bash pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu124 https://download.pytorch.org/whl/cu124 Check pytorch.org/get-started/locally for the right CUDA build for your environment. Do not assume cu124 is correct for every pod. Add a hard guard to your training script The standard "cuda" if torch.cuda.is available else "cpu" pattern is a liability on rented compute. Replace it: python import torch if not torch.cuda.is available : raise RuntimeError "CUDA not available. Check PyTorch build, CUDA VISIBLE DEVICES, " "and nvidia-smi before starting a paid job." device = torch.device "cuda" This turns a silent CPU fallback into a hard error at line one. Catch it automatically before every job bash uvx computefence doctor Real output from a machine with no PyTorch installed: ComputeFence v0.3.3 — Pre-flight diagnostic ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4 WARNINGS · 0 BLOCKERS · 2 PASSED Environment ✓ Python 3.14.3 ⚠ PyTorch not found — skipping GPU checks Fix: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 https://download.pytorch.org/whl/cu118 This output is from a Mac with no PyTorch installed the fix command shows cu118 as a safe default. On a Linux pod the right CUDA wheel depends on your driver version; check pytorch.org/get-started/locally for the correct build. When PyTorch is present but CUDA is unavailable, the torch cuda check fires instead. Chain it with your training command so the job never starts if something is wrong: bash uvx computefence doctor && python train.py GitHub: github.com/Francisco-Booth/ComputeFence Install: pip install computefence