Troubleshooting¶
Run clef doctor first (clef doctor --json for a bug report). On Windows + WSL use .\clef.ps1 doctor.
Contents: CUDA - ROCm under WSL2 - MPS (macOS) - CPU - Common
CUDA¶
Untested on hardware at the time of writing; these are the known failure modes of the stack.
CUDA not available/ backend falls to cpu: the installed torch is a CPU build, or the driver is missing. Checknvidia-smi, thenpython -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())". Reinstall fromrequirements/cuda.txt.- Driver / toolkit mismatch (
CUDA driver version is insufficient,no kernel image is available): the driver must support the CUDA version of the torch wheel (nvidia-smishows the maximum supported CUDA version at the top right). Update the driver; you do not need a system CUDA toolkit for the wheels. - "The fast path is not available" warning (transformers):
flash-linear-attentionandcausal-conv1dare missing. The model still runs through a slower torch fallback. Installflash-linear-attention(part of the CUDA lock file) andcausal-conv1d;clef doctorshows which one is missing. causal-conv1dfails to build: it compiles CUDA code and needsnvccmatching the torch CUDA version, a C++ compiler andninja. Prefer a prebuilt wheel matching your torch/CUDA/Python, or install the CUDA toolkit of the same major.minor astorch.version.cuda. If it cannot be built, run without it; correctness is unchanged. Built from source on WSL2 + Ubuntu 24.04 withcuda-toolkit-12-8(do not install thecudaorcuda-driversmetapackages inside WSL),uv pip install ninja setuptools wheel, thenCUDA_HOME=/usr/local/cuda-12.8 TORCH_CUDA_ARCH_LIST=8.9 MAX_JOBS=6 uv pip install causal-conv1d --no-build-isolation(set the arch list to your card; it took about 23 minutes). On an RTX 4070 Ti it did not change speed measurably (p50 170.3 to 167.5 ms), so skipping it costs little there.CLEF_QUANTerrors: on CUDAint8andnf4usebitsandbytes(pip install bitsandbytes, part of thecudaextra); if it cannot find the CUDA libraries, checkpython -m bitsandbytes.CLEF_QUANT_BACKEND=torchaoneedspip install "clef-local[quant]".nf4exists only in bitsandbytes. Quantized probabilities differ slightly from bf16 (numbers on CUDA are pending hardware; on ROCm see Smaller GPUs).- Out of memory on load or under load: bf16 needs ~19.5 GB peak. Close other GPU users, use a 24 GB card, or
lower the footprint:
CLEF_OFFLOAD=cpu CLEF_MAX_DEVICE_MEMORY_GB=<N-1>(lossless) orCLEF_QUANT=int8; the Smaller GPUs table says what fits where. Preflight (CLEF_PREFLIGHT=1) reports this before loading andclef doctorprints a recommendation. At runtime an OOM returns 503 and the server keeps running; lowerCLEF_MAX_MICROBATCHorCLEF_MAX_TOKENS, or raise the cap. - bf16 on older GPUs (pre-Ampere): bf16 is not supported; clef falls back to fp16 with a warning. Check parity with
bench/parity.py.
ROCm under WSL2¶
This is the verified setup (RX 7900 XTX, ROCm 7.2).
No CUDA GPUs are available/ torch sees no device:HSA_ENABLE_DXG_DETECTION=1must be set (clef sets it automatically when/dev/dxgexists; required until ROCm 7.13+ in WSL). If you run torch yourself, export it./dev/dxgmissing: update the Windows AMD Adrenalin driver, make sure WSL2 (not WSL1) is used (wsl -l -v), thenwsl --shutdown.- Permission denied on
/dev/dxgor/dev/kfd: add your user to therendergroup (sudo usermod -aG render $USER), then restart the distro. - WSL stops the server a few seconds after you close the terminal: WSL shuts an idle distro down ~15 s after the
last
wsl.exesession exits.clef.ps1 startkeeps a hidden keep-alive session for this reason; use it (or the systemd user service withsystemd=truein/etc/wsl.conf, seedeploy/wsl.conf.sample) instead of a barewsl -e clef serve --detach. - MSYS path conversion (Git Bash):
wsl ... /mnt/c/...arguments get rewritten toC:/Program Files/Git/.... Prefix the command withMSYS_NO_PATHCONV=1, or use PowerShell. expandable_segmentsis not supported on ROCm/WSL: do not setPYTORCH_ALLOC_CONF=expandable_segments:True(it logs a warning and is ignored at best).- First forwards take seconds to minutes: one-time Triton/SDPA kernel compilation per input shape. The startup
warmup covers the length buckets; caches live in
~/.triton/cache. The first warmup after a fresh install takes ~110 s, later ones ~12 s. - Out of memory in WSL: set
memory=26GBin%USERPROFILE%\.wslconfig(for a 32 GB host); it applies afterwsl --shutdown. - causal-conv1d: its HIP build does not work on WSL-ROCm yet.
flash-linear-attentionis active and the torch fallback for the convolution is already fast; the fast-path warning is expected forcausal_conv1donly. - bench refuses to run: the server holds ~19.6 GB of VRAM; stop it first (
clef stop) or pass--force. - AMD telemetry under WSL is partial: measured on the RX 7900 XTX (ROCm 7.2),
amdsmireports GPU utilization and temperature, but no power, and its VRAM usage is nonsense (clef drops it and charts the allocator figure instead).rocm-smiis not tried under WSL. Without theamdsmiPython package, telemetry shows "unavailable"; that is harmless.
MPS (macOS)¶
Untested on hardware at the time of writing.
- bf16 on macOS < 14: MPS bf16 needs macOS 14+. clef falls back to fp16 with a warning; update macOS or check
parity with
bench/parity.py. - Memory pressure / the Mac becomes unresponsive: the model takes ~19.5 GB of unified memory; 32 GB is the
realistic floor. Close other apps, lower
CLEF_MAX_MICROBATCH, keep images small (CLEF_MAX_PIXELS). Preflight warns when free memory looks too low. NotImplementedError: ... not currently implemented for the MPS device: clef setsPYTORCH_ENABLE_MPS_FALLBACK=1automatically so unsupported ops run on the CPU. If you import torch yourself before clef, export it in your shell.- fla Triton kernels not available: expected. Triton does not run on macOS, so the torch fallback is used and the transformers fast-path warning is normal.
CLEF_QUANT=nf4is refused: nf4 needs bitsandbytes (NVIDIA or AMD).CLEF_QUANT=int8works through torchao (pip install torchao, already in thempsextra) but is not validated on Apple Silicon.CLEF_OFFLOAD=cpudoes nothing: a Mac shares one memory pool between device and host, so offload has no effect there (a warning is logged). UseCLEF_QUANT=int8instead.- Slow first request: MPS compiles kernels lazily; the startup warmup covers the common shapes.
- Closing the lid / sleep stops the server: use the launchd agent in
deploy/and keep the Mac awake (caffeinate -i).
CPU¶
CLEF_OFFLOADhas no effect: the CPU backend already runs from host RAM.- Out of memory / the machine swaps: the model needs ~40 GB of RAM on CPU (weights plus activations). Use a GPU backend if you have one.
- Very slow: expected, seconds per record. CPU mode is for development and CI (the unit tests never load the
model). Set
CLEF_WARMUP=0to skip the warmup. - Backend detected as cpu on a machine with a GPU: you installed a CPU torch build. Reinstall from the matching
lock file, or force a device with
CLEF_DEVICE=cuda|rocm|mpsto get an explicit error with a hint.
Smaller-memory modes¶
See Smaller GPUs for the numbers.
- Load fails with a "not enough memory" message under
CLEF_OFFLOAD=cpu: even streaming every layer does not fit underCLEF_MAX_DEVICE_MEMORY_GB. Raise the cap (the smallest one measured to work is 7 GB; 6 crashed while loading on WSL2 because too many layers had to be pinned) or addCLEF_QUANT=int8. - Host RAM or WSL2 memory: offload keeps what it moved off the GPU in pinned host memory (~6 GB at a 15 GB cap,
~15 GB at 7 GB). On WSL2 raise
memory=in.wslconfig. Loading briefly uses more (memory-mapped weight files). - A very long input returns 503
GpuOutOfMemorywith offload: activations exceeded the 2.5 GB reserve. LowerCLEF_MAX_MICROBATCH, shorten the input or raise the cap. The server stays up. - Slower than bf16: expected. The layers kept on the host are copied over PCIe each forward (p50 +15% at a 15 GB cap, 3.6x at 7 GB).
Jobs, webhooks and compatibility routes¶
400 webhook.url: ...on submit: webhooks are off until the operator setsCLEF_WEBHOOK_ALLOW; the host (or IP / CIDR for a private address) must be listed. Link-local, multicast and reserved addresses are always refused.- A webhook never arrives: check
webhook.deliveriesinGET /v1/jobs/{id}(last_status,last_error). The allow-list is re-checked, and the host re-resolved, on every attempt. Retries stop afterCLEF_WEBHOOK_ATTEMPTS. 404for a job you submitted: another API key. Jobs are visible only to the key that created them (and to keys with theadminscope); a key without thejobsscope gets403.409onPOST /v1/jobs:CLEF_MAX_JOBSqueued or running jobs; retry afterRetry-After. On cancel / delete it means the job is already finished / still active.- A job stays
queued: look atwaiting_reasoninGET /v1/jobs/{id}:off_hours(its window opens atnext_window_at;urgentskips it),active_limit(CLEF_JOB_ACTIVEjobs are already running) or empty (it is about to be admitted). A job that staysrunningwithout progress and saysoff_hoursorturnis waiting for its window or for other jobs' chunks. While the model is loading a job waits instead of failing. 400 missing_schemafrom/v1/chat/completions: clef decides, it does not generate text. Send aresponse_formatJSON schema (or one forced tool); see compatibility.huggingface_hubcannot find the model: pass the full route,model="http://127.0.0.1:8910/hf/models/clef-flash", instead of settingHF_ENDPOINT.POST /v1/evaluaterejects the rows: more thanCLEF_MAX_EVAL_ROWS(500), or a gold label that is not in the label set. Large sets: submit anevaluatejob.
Common¶
- Port already in use: something else answers on 8910.
clef statusshows whether it is clef. Stop it (clef stop), or useCLEF_PORT=8911/clef serve --port 8911.clef serve --detachrefuses to start when the port answers. - 401 Unauthorized: keys are configured; send
X-API-Key: <key>orAuthorization: Bearer <key>. Check the key name in the keys file (name:key). See remote-access.md. - 429 Too Many Requests:
CLEF_RATE_LIMITis exceeded for that key; waitRetry-Afterseconds or raise the limit. - 503 Service Unavailable: the model is still loading/warming (
clef status,/health) or the device ran out of memory. The clients retry with backoff. - Model not found: run
clef download. Path resolution:CLEF_MODEL_PATHif set, else~/models/clef-flashif it holds a release, else the pinned snapshot in the Hugging Face cache. The server never downloads on its own (/healthshowsstatus: errorwith the message). - Download fails or stalls:
clef downloadis resumable, just run it again. It needs ~21 GB free; behind a proxy setHTTPS_PROXY. SetHF_HOMEto put the cache on another disk. - Not enough disk space: the weights are ~19 GB;
clef doctorandclef downloadcheck this up front. - Where are the logs / state?
clef logs -f. The state directory is~/.local/state/clefon Linux,~/Library/Application Support/clefon macOS,%LOCALAPPDATA%\clefon Windows (CLEF_STATE_DIRoverrides;CLEF_LOG_DIRis a legacy alias). It holdsserver.log,server.pidandclef.db(jobs and saved classifiers; after an upgrade from v3.1 alsojobs.db.migratedandclassifiers.imported/, which you can delete). - Upgrading from v2: see the migration notes in the CHANGELOG.