published fresh until

PyTorch: Torch not compiled with CUDA enabled. Why?

Summary As of October 2026 (checked 2026-10-28), check the torch build in the failing interpreter first; use the official installation selector for CUDA, or remove CUDA-only calls when CPU execution is intended.

Not for CUDA OOM or no kernel image, see pytorch-cuda-oom-device-assert-kernel-image-weights-only-errors

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

AssertionError: Torch not compiled with CUDA enabled

The installed PyTorch build cannot initialize the CUDA path your code called.

First action — run python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())" using the same interpreter that fails.

Evidence status — the official assertion identifies a missing CUDA binding; public reports support selecting a CUDA-enabled binary or removing an unintended CUDA call, without proving a fix for your hardware.

Not for: PyTorch CUDA out of memory, device-side asserts or no-kernel-image errors; see pytorch-cuda-oom-device-assert-kernel-image-weights-only-errors.

How to diagnose and choose the next action

1. Record the build output above and the failing traceback. If a notebook fails, run the equivalent statements inside its kernel; a terminal can use a different interpreter. 2. Inspect the exact initialization call. The official CUDA module raises this assertion when torch._C lacks _cuda_getDeviceCount (main checked 2026-10-28). It checks this before calling CUDA initialization. This is evidence about the imported build, not proof that a particular driver repair is needed. 3. If NVIDIA CUDA execution is intended, use the official Get Started Locally selector (checked 2026-10-28). Select your operating system, package manager, language and supported compute platform; use its generated command in the intended environment. Do not substitute a remembered wheel index or CUDA version. 4. If CPU execution is intended, follow the traceback to the CUDA request and change that path to CPU. Inspect helpers as well as the top-level device variable. Replacing one variable does not change a later explicit .cuda() call. 5. Run the diagnostic in the intended interpreter after selecting its PyTorch build, then execute a tiny tensor operation on the intended device before loading the full model. A CUDA-enabled build alone does not establish runtime GPU availability.

Diagnostic: Torch not compiled with CUDA enabled

The exact assertion is in the source above. It is distinct from other initialization failures later in the same function. Do not use it as a universal diagnosis for every torch.cuda.is_available() result of False.

What to test

  • Confirm the interpreter running the application imports the intended torch build.
  • If CUDA is the target, create a small tensor with torch.ones(1, device="cuda") and inspect its device before a full workload.
  • If CPU is the target, run the previously failing path, including helpers and checkpoint-loading code, without a CUDA request.

Public evidence

  • In the CUDA-enabled-binary discussion, ptrblck recommends the installation commands for a CUDA-enabled binary on 2023-04-30 (checked 2026-10-28). Michel777 replies the same day, “I did it - it works !” This is an individual confirmation, not compatibility evidence for a current GPU.
  • Dicko's CPU execution report, 2023-01-03 (checked 2026-10-28), was resolved after finding a CUDA reference in another file: “fixed it to cpu and all working fine now.” This supports tracing the actual call rather than reinstalling blindly.

Pitfalls

Installing a CUDA toolkit does not add a missing binding to the torch build already imported. Do not choose CUDA simply because the machine has some kind of GPU. Do not copy historical installation commands from a forum reply; use the current official selector. A successful import does not test device initialization.

A prompt for your agent

Read the linked current PyTorch installation selector and CUDA initialization source before proposing changes; your remembered installation matrix may be old. Inspect the imported torch build in the failing interpreter and identify the CUDA call in the traceback. Decide whether this program intends CUDA or CPU execution. Give the selector-generated command only after matching the actual platform; otherwise show the unintended CUDA call to change. Test one tensor operation before the full model.

Limits

No package installation, GPU initialization or model workload was tested here. No driver-specific diagnosis is established. The public confirmations are historical; operating-system, GPU and binary compatibility must be checked for the reader's setup.

Started from a post by @pytorch, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# PyTorch: Torch not compiled with CUDA enabled. Why?
Summary: As of October 2026 (checked 2026-10-28), check the torch build in the failing interpreter first; use the official installation selector for CUDA, or remove CUDA-only calls when CPU execution is intended.
Copy for agent
get the whatworks thread pytorch-torch-not-compiled-with-cuda-enabled-build-check and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread pytorch-torch-not-compiled-with-cuda-enabled-build-check
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks