detect_gpu: Detect a usable GPU for Ollama inference

View source: R/gpu.R

detect_gpuR Documentation

Detect a usable GPU for Ollama inference

Description

Probes the system for a GPU that Ollama can offload models to. Does not require Ollama itself; the checks are OS-level so users can verify their hardware is set up before pulling any models.

Usage

detect_gpu()

Details

Checks in order:

  1. macOS with Apple Silicon (Metal is used automatically).

  2. nvidia-smi returning success – an NVIDIA GPU with a working CUDA driver.

  3. rocm-smi returning success – an AMD GPU with a working ROCm driver.

Ollama itself decides how much of a model to offload to the GPU (based on free VRAM); this function only reports whether the underlying hardware is available. To verify Ollama is actually using the GPU during a run, look at ⁠ollama ps⁠ in a terminal: the SIZE (GPU) column shows how many bytes are on the GPU.

Value

A list with:

  • available: logical

  • kind: one of "apple", "nvidia", "amd", or "none"

  • detail: a short human-readable string (e.g. the GPU model name, or the reason detection failed)

Examples

info <- detect_gpu()
info$available
info$kind

screenllm documentation built on Sept. 24, 2026, 5:11 p.m.