opendatalab/MinerU · error · ValueError
CUDA is not available.
Error message
CUDA is not available.
What it means
Raised by set_lmdeploy_backend() in the VLM backend when device_type is 'cuda' but torch.cuda.is_available() is False. The function needs a working CUDA runtime to then choose turbomind vs pytorch backend by OS and compute capability, so a CUDA-less environment fails fast here.
Source
Thrown at mineru/backend/vlm/utils.py:66
elif version.parse(compute_capability) < version.parse("8.0"):
if version.parse(vllm_version) >= version.parse("0.10.2"):
logger.info(f"compute_capability: {compute_capability} < 8.0, but vllm version: {vllm_version} >= 0.10.2, enable custom_logits_processors")
return True
else:
logger.info(f"compute_capability: {compute_capability} < 8.0 and vllm version: {vllm_version} < 0.10.2, disable custom_logits_processors")
return False
else:
logger.info(f"compute_capability: {compute_capability} >= 8.0 and vllm version: {vllm_version} >= 0.10.1, enable custom_logits_processors")
return True
def set_lmdeploy_backend(device_type: str) -> str:
if device_type.lower() in ["ascend", "maca", "camb"]:
lmdeploy_backend = "pytorch"
elif device_type.lower() in ["cuda"]:
import torch
if not torch.cuda.is_available():
raise ValueError("CUDA is not available.")
if is_windows_environment():
lmdeploy_backend = "turbomind"
elif is_linux_environment():
major, minor = torch.cuda.get_device_capability()
compute_capability = f"{major}.{minor}"
if version.parse(compute_capability) >= version.parse("8.0"):
lmdeploy_backend = "pytorch"
else:
lmdeploy_backend = "turbomind"
else:
raise ValueError("Unsupported operating system.")
else:
raise ValueError(f"Unsupported lmdeploy device type: {device_type}")
return lmdeploy_backend
def set_default_gpu_memory_utilization() -> float:
from vllm import __version__ as vllm_versionView on GitHub (pinned to 4fe4bde114)
Solutions
- Check torch.cuda.is_available() and torch.version.cuda in your environment.
- If GPU exists: install a CUDA-enabled torch build matching your driver, and verify nvidia-smi works.
- If no GPU: use a different backend (e.g. transformers on CPU/MPS, mlx-engine on Apple Silicon, or an http-client backend pointed at a GPU server).
- Unset or fix CUDA_VISIBLE_DEVICES.
Example fix
# before
backend = set_lmdeploy_backend("cuda") # ValueError: CUDA is not available.
# after
import torch
assert torch.cuda.is_available(), "need CUDA-enabled torch + driver"
backend = set_lmdeploy_backend("cuda") Defensive patterns
Strategy: validation
Validate before calling
import torch
def cuda_ready() -> bool:
return torch.cuda.is_available()
if not cuda_ready():
choose_non_lmdeploy_backend() # transformers / http-client Type guard
def can_use_lmdeploy_cuda() -> bool:
import torch
return torch.cuda.is_available() Try / catch
try:
backend = set_lmdeploy_backend("cuda")
except ValueError as e:
if "CUDA is not available" in str(e):
raise RuntimeError("install CUDA-enabled torch or pick another backend") from e
raise Prevention
- Install torch with the right CUDA index URL (e.g. --index-url https://download.pytorch.org/whl/cu121).
- Smoke-test torch.cuda.is_available() in CI before GPU jobs.
- Check CUDA_VISIBLE_DEVICES is not empty in service environments.
When it happens
Trigger: device_type='cuda' passed to (or defaulted for) lmdeploy engine setup on a machine with no NVIDIA GPU, nvidia drivers, or a CPU-only torch build; CUDA_VISIBLE_DEVICES set to an empty/invalid value.
Common situations: CPU-only torch wheel installed in a GPU container; driver/library mismatch so torch cannot initialize CUDA; remote device hidden by CUDA_VISIBLE_DEVICES="".
Related errors
- Unsupported lmdeploy device type: {device_type}
- Unsupported lmdeploy device type: {device_type}
- NPU is selected as device, but torch_npu is not available. P
- NPU is selected as device, but torch_npu is not available. P
- Unsupported operating system.
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/a28c414199a6d4bd.
Report an issue: GitHub.