LogoGLM-OCR
  • Features
  • API Pricing
  • Blog
GLM-OCR Local Deployment: Ollama vs vLLM vs SGLang
2025/01/10

GLM-OCR Local Deployment: Ollama vs vLLM vs SGLang

Compare different local deployment options for GLM-OCR including Ollama, vLLM, and SGLang. Learn which option is best for your use case.

Introduction

GLM-OCR supports multiple local deployment options, each with different trade-offs between ease of use, performance, and flexibility. This guide compares Ollama, vLLM, and SGLang to help you choose the right option.

Deployment Options Overview

FeatureOllamavLLMSGLang
Ease of SetupVery EasyModerateModerate
PerformanceGoodExcellentExcellent
GPU MemoryEfficientHighHigh
BatchingBasicAdvancedAdvanced
Production ReadyYesYesYes
Best ForDevelopmentProductionProduction

Option 1: Ollama

Ollama is the simplest way to run GLM-OCR locally.

Installation

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Pull GLM-OCR model
ollama pull glm-ocr

Available Models

ModelSizeUse Case
glm-ocr:latest2.2GBDefault, balanced
glm-ocr:q8_01.6GBMemory constrained
glm-ocr:bf162.2GBBest quality

Usage

# Interactive mode
ollama run glm-ocr

# Direct recognition
ollama run glm-ocr Text Recognition: ./document.png
ollama run glm-ocr Table Recognition: ./table.png

API Server

# Start Ollama server (runs by default)
ollama serve

# API call
curl http://localhost:11434/api/generate -d '{
  "model": "glm-ocr",
  "prompt": "Text Recognition:",
  "images": ["base64_encoded_image"]
}'

Pros and Cons

Pros:

  • One-line installation
  • Simple CLI interface
  • Automatic model management
  • Low memory footprint with quantized models

Cons:

  • Limited batching capabilities
  • Less control over inference parameters
  • Not optimized for high-throughput scenarios

Option 2: vLLM

vLLM provides high-performance inference with advanced batching.

Installation

# Install vLLM
pip install -U vllm --extra-index-url https://wheels.vllm.ai/nightly

# Install Transformers (required for GLM-OCR)
pip install git+https://github.com/huggingface/transformers.git

Start Server

vllm serve zai-org/GLM-OCR \
    --allowed-local-media-path / \
    --port 8080 \
    --tensor-parallel-size 1 \
    --max-model-len 8192

Configuration Options

OptionDescriptionDefault
--tensor-parallel-sizeNumber of GPUs1
--max-model-lenMax context length8192
--gpu-memory-utilizationGPU memory usage0.9
--max-num-batched-tokensBatch size8192

API Usage

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8080/v1",
    api_key="not-needed"
)

response = client.chat.completions.create(
    model="zai-org/GLM-OCR",
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": "file:///path/to/image.png"}},
            {"type": "text", "text": "Text Recognition:"}
        ]
    }],
    max_tokens=4096
)

Pros and Cons

Pros:

  • Excellent throughput with continuous batching
  • OpenAI-compatible API
  • Advanced memory management
  • Production-ready

Cons:

  • Higher GPU memory requirements
  • More complex setup
  • Requires CUDA

Option 3: SGLang

SGLang offers efficient serving with advanced scheduling.

Installation

pip install sglang
pip install git+https://github.com/huggingface/transformers.git

Start Server

python -m sglang.launch_server \
    --model zai-org/GLM-OCR \
    --port 8080 \
    --tp 1

Configuration Options

OptionDescriptionDefault
--tpTensor parallelism1
--dpData parallelism1
--mem-fraction-staticStatic memory0.8

API Usage

import sglang as sgl

@sgl.function
def ocr_recognition(s, image_path, task="Text Recognition:"):
    s += sgl.user(sgl.image(image_path) + task)
    s += sgl.assistant(sgl.gen("response", max_tokens=4096))

# Run
state = ocr_recognition.run(image_path="document.png")
print(state["response"])

Pros and Cons

Pros:

  • Efficient RadixAttention for caching
  • Advanced scheduling algorithms
  • Good for complex workflows
  • Supports structured generation

Cons:

  • Newer, less mature ecosystem
  • Steeper learning curve
  • Requires CUDA

Performance Comparison

Throughput Test

Test conditions: 100 A4 document images, single GPU (RTX 4090)

DeploymentThroughputLatency (p50)Latency (p99)
Ollama0.5 img/s1.8s3.2s
vLLM1.8 img/s0.5s1.2s
SGLang1.7 img/s0.6s1.3s

Memory Usage

DeploymentGPU MemorySystem RAM
Ollama (q8_0)4GB2GB
Ollama (bf16)6GB2GB
vLLM8GB4GB
SGLang8GB4GB

Choosing the Right Option

Use Ollama When:

  • Quick prototyping and development
  • Limited GPU memory (< 8GB)
  • Simple CLI-based workflows
  • Single-user scenarios

Use vLLM When:

  • Production deployment
  • High-throughput requirements
  • OpenAI API compatibility needed
  • Multiple concurrent users

Use SGLang When:

  • Complex multi-step workflows
  • Need for structured generation
  • Advanced caching requirements
  • Research and experimentation

Docker Deployment

Ollama Docker

FROM ollama/ollama

RUN ollama pull glm-ocr

EXPOSE 11434
CMD ["ollama", "serve"]

vLLM Docker

FROM vllm/vllm-openai:latest

ENV MODEL_NAME=zai-org/GLM-OCR

CMD ["--model", "${MODEL_NAME}", "--port", "8080"]

Docker Compose

version: '3.8'
services:
  glm-ocr:
    image: vllm/vllm-openai:latest
    ports:
      - "8080:8080"
    volumes:
      - ./models:/root/.cache/huggingface
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    command: ["--model", "zai-org/GLM-OCR", "--port", "8080"]

Monitoring and Scaling

Health Checks

import requests

def check_health(endpoint):
    try:
        response = requests.get(f"{endpoint}/health")
        return response.status_code == 200
    except:
        return False

Load Balancing

upstream glm_ocr {
    server localhost:8080;
    server localhost:8081;
    server localhost:8082;
}

server {
    listen 80;
    location / {
        proxy_pass http://glm_ocr;
    }
}

Conclusion

Each deployment option has its strengths:

  • Ollama: Best for development and simple use cases
  • vLLM: Best for production with high throughput needs
  • SGLang: Best for complex workflows and research

Choose based on your specific requirements for performance, ease of use, and deployment environment.

Related Articles

  • GLM-OCR Quick Start Guide
  • GLM-OCR Introduction
  • Table Recognition with GLM-OCR
All Posts

Author

avatar for GLM-OCR Team
GLM-OCR Team

Categories

  • Deployment
  • Tutorial
IntroductionDeployment Options OverviewOption 1: OllamaInstallationAvailable ModelsUsageAPI ServerPros and ConsOption 2: vLLMInstallationStart ServerConfiguration OptionsAPI UsagePros and ConsOption 3: SGLangInstallationStart ServerConfiguration OptionsAPI UsagePros and ConsPerformance ComparisonThroughput TestMemory UsageChoosing the Right OptionUse Ollama When:Use vLLM When:Use SGLang When:Docker DeploymentOllama DockervLLM DockerDocker ComposeMonitoring and ScalingHealth ChecksLoad BalancingConclusionRelated Articles

More Posts

Mathematical Formula Recognition: GLM-OCR LaTeX Output Guide
FeatureTutorial

Mathematical Formula Recognition: GLM-OCR LaTeX Output Guide

Learn how to use GLM-OCR for high-accuracy mathematical formula recognition with LaTeX output, perfect for academic documents and scientific papers.

avatar for GLM-OCR Team
GLM-OCR Team
2025/01/12
Complex Table Recognition: How GLM-OCR Handles Merged Cells
FeatureTutorial

Complex Table Recognition: How GLM-OCR Handles Merged Cells

Learn how GLM-OCR excels at recognizing complex tables with merged cells, multi-level headers, and diverse layouts commonly found in business documents.

avatar for GLM-OCR Team
GLM-OCR Team
2025/01/13
GLM-OCR Quick Start: Complete Document Parsing Guide
Tutorial

GLM-OCR Quick Start: Complete Document Parsing Guide

Learn how to get started with GLM-OCR for document parsing. This guide covers API integration, Ollama local deployment, vLLM, and SGLang deployment options.

avatar for GLM-OCR Team
GLM-OCR Team
2025/01/14
LogoGLM-OCR

Lightweight Professional OCR Model with State-of-the-Art Performance

GitHubGitHubTwitterX (Twitter)DiscordEmail
Product
  • Features
  • Pricing
  • FAQ
Resources
  • Blog
Links
  • Hugging Face
  • GitHub
  • Ollama
Legal
  • Cookie Policy
  • Privacy Policy
  • Terms of Service
© 2026 GLM-OCR All Rights Reserved.
MossAI ToolsAiTop10 Tools DirectoryZ-ImageSubmit AI Tools – The ultimate platform to discover, submit, and explore the best AI tools across various categories.Featured on ShowMeBestAIFeatured on Wired BusinessShowMySitesFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFazier badgePower Up ToolsFeatured on DeepLaunch.ioGLM-OCR Free Online OCR Tool - Featured AI Agent on AI Agents DirectoryFeatured on newtool.siteListed on BuildWayMossAI ToolsAiTop10 Tools DirectoryZ-ImageSubmit AI Tools – The ultimate platform to discover, submit, and explore the best AI tools across various categories.Featured on ShowMeBestAIFeatured on Wired BusinessShowMySitesFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFazier badgePower Up ToolsFeatured on DeepLaunch.ioGLM-OCR Free Online OCR Tool - Featured AI Agent on AI Agents DirectoryFeatured on newtool.siteListed on BuildWay