Environment Variables

July 15, 2026 ยท View on GitHub

Runtime environment variables read by the oar-ocr crates. Project-specific variables use the OAR_ prefix (OAR_VL_ for the Vision-Language crate).

Summary

VariableCrateDefaultPurpose
OAR_HOMEoar-ocr-core~/.oarModel cache directory for auto-download
OAR_VL_DTYPEoar-ocr-vlautoCompute dtype for VL models
OAR_VL_ATTN_FULL_SEQ_THRESHOLDoar-ocr-vl8192PaddleOCR-VL vision attention path selection
OAR_VL_DISABLE_FLASH_ATTNoar-ocr-vlunsetDisable CUDA FlashAttention
OAR_VL_DISABLE_GQAoar-ocr-vlunsetUse expanded-K/V GQA fallback
OAR_VL_DISABLE_CUDA_GRAPHoar-ocr-vlunsetDisable shared decoder CUDA graphs
OAR_VL_DISABLE_SPECULATIVEoar-ocr-vlunsetDisable GLM-OCR speculative decoding
OAR_PADDLEOCR_VL_DISABLE_CUDA_GRAPHoar-ocr-vlunsetDisable PaddleOCR-VL CUDA graphs
OAR_GLMOCR_DISABLE_MTPoar-ocr-vlunsetDisable GLM-OCR MTP
OAR_GLMOCR_DISABLE_CUDA_GRAPHoar-ocr-vlunsetDisable GLM-OCR CUDA graphs
OAR_HUNYUAN_DISABLE_CUDA_GRAPHoar-ocr-vlunsetDisable HunyuanOCR CUDA graphs
OAR_HUNYUAN_DISABLE_AR_CUDA_GRAPHoar-ocr-vlunsetDisable HunyuanOCR AR CUDA graph
OAR_MINERU_DISABLE_CUDA_GRAPHoar-ocr-vlunsetDisable MinerU CUDA graphs
OAR_MINERU_DISABLE_GPU_SAMPLINGoar-ocr-vlunsetDisable MinerU GPU sampling
OAR_MINERU_DIFFUSION_DISABLE_GPU_SAMPLINGoar-ocr-vlunsetDisable MinerU-Diffusion GPU sampling
CUDA_COMPUTE_CAPoar-ocr-vl buildautoCUDA PTX target architecture
NVCCoar-ocr-vl buildnvccCUDA compiler path
CUDA_LAUNCH_BLOCKINGoar-ocr-coreset to 1 if unsetONNX Runtime CUDA workaround
RUST_LOGexamplesinfoLog filter

OAR_HOME

Directory where the auto-download feature caches model files (default ~/.oar). Bare model file names passed to the builders are downloaded here and verified against their expected SHA-256. See models.md for the exact path resolution rules.

OAR_HOME=/data/oar-models cargo run --release --example ocr -- doc.jpg

OAR_VL_DTYPE

Overrides the automatic weight/compute dtype selection for Vision-Language models (PaddleOCR-VL, GLM-OCR, HunyuanOCR, MinerU2.5/Pro, and MinerU-Diffusion).

Accepted values (case-insensitive):

  • bf16 (alias bfloat16)
  • f16 (aliases fp16, float16, half)
  • f32 (aliases fp32, float32)

Without the override, devices that advertise BF16 support use it after a runtime kernel probe. If the probe fails (for example on pre-Ampere CUDA GPUs), inference falls back to F16. CPU and devices without advertised BF16 support use F32.

OAR_VL_DTYPE=f16 cargo run --release --features cuda,download-binaries -p oar-ocr-vl --example paddleocr_vl -- ...

OAR_VL_ATTN_FULL_SEQ_THRESHOLD

Maximum sequence length (in vision patches) for which PaddleOCR-VL's vision attention may use the single-shot full-matrix path. Longer sequences use the numerically equivalent chunked path, which needs far less peak memory. Default 8192. Set 0 to force chunked attention.

Independently of this threshold, the full path is skipped automatically whenever its softmax scratch would not fit in the free device memory, so low-VRAM GPUs normally don't need this variable.

OAR_VL_ATTN_FULL_SEQ_THRESHOLD=0 cargo run --release --features cuda,download-binaries -p oar-ocr-vl --example paddleocr_vl -- ...

VL Performance and Debug Overrides

The following presence-based switches select portable fallbacks or disable optional accelerations. Setting a variable to any value enables the switch.

VariableScopeEffect
OAR_VL_DISABLE_FLASH_ATTNAll CUDA VLM backendsUse the eager attention fallback instead of FlashAttention
OAR_VL_DISABLE_GQABackends using grouped-query attentionExpand K/V heads before eager attention instead of using the grouped implementation
OAR_VL_DISABLE_CUDA_GRAPHPaddleOCR-VL, GLM-OCR, MinerU2.5/ProDisable decoder CUDA graph capture and replay
OAR_VL_DISABLE_SPECULATIVEGLM-OCRDisable MTP speculative decoding
OAR_PADDLEOCR_VL_DISABLE_CUDA_GRAPHPaddleOCR-VL variantsDisable decoder CUDA graphs only for PaddleOCR-VL
OAR_GLMOCR_DISABLE_MTPGLM-OCRDo not load or use the MTP predictor
OAR_GLMOCR_DISABLE_CUDA_GRAPHGLM-OCRDisable autoregressive and MTP CUDA graphs
OAR_HUNYUAN_DISABLE_CUDA_GRAPHHunyuanOCRDisable target, autoregressive, and DFlash CUDA graphs
OAR_HUNYUAN_DISABLE_AR_CUDA_GRAPHHunyuanOCRDisable only the single-token autoregressive CUDA graph
OAR_MINERU_DISABLE_CUDA_GRAPHMinerU2.5/ProDisable decoder CUDA graphs
OAR_MINERU_DISABLE_GPU_SAMPLINGMinerU2.5/ProUse the host sampling fallback instead of the CUDA greedy sampler
OAR_MINERU_DIFFUSION_DISABLE_GPU_SAMPLINGMinerU-DiffusionUse the host sampling fallback instead of the CUDA sampler

These switches are primarily useful for compatibility checks, debugging, and numerical comparisons. The accelerated paths remain enabled by default when the active device and dtype support them.

CUDA Build Overrides

With the cuda feature enabled, oar-ocr-vl compiles its custom kernels to PTX. CUDA_COMPUTE_CAP overrides automatic GPU detection and accepts values such as 89, 8.9, sm_89, or compute_89. Compute capability 8.0 or newer is required. NVCC overrides the CUDA compiler executable.

CUDA_COMPUTE_CAP=89 NVCC=/usr/local/cuda/bin/nvcc \
    cargo build -p oar-ocr-vl --features cuda,download-binaries

CUDA_LAUNCH_BLOCKING

Standard CUDA variable, listed here because the classic (ONNX Runtime) pipeline sets it to 1 at startup when it is not already set, to work around onnxruntime#4829 (PP-FormulaNet's autoregressive Loop corrupting CUDA-EP arena buffers). Preset any value (e.g. 0) to keep your own setting. Note this serializes CUDA kernel launches process-wide.

RUST_LOG

Standard tracing_subscriber::EnvFilter filter used by the examples, e.g. RUST_LOG=oar_ocr_vl=debug to see why the vision attention picked the chunked path.