Skip to main content
Chunkr uses GPU acceleration to significantly improve document processing performance. This guide covers GPU configuration for NVIDIA GPUs.

Prerequisites

Hardware Requirements

  • NVIDIA GPU with CUDA support (compute capability 6.0+)
  • At least 6GB GPU memory (12GB+ recommended for production)
  • Multiple GPUs supported for increased throughput

Software Requirements

  • NVIDIA GPU drivers (version 470.x or later)
  • NVIDIA Container Toolkit
  • Docker Engine 19.03 or later
  • Docker Compose V2

Installing NVIDIA Container Toolkit

1

Add NVIDIA package repository

2

Install nvidia-container-toolkit

3

Configure Docker daemon

4

Verify installation

Test GPU access from Docker:
You should see your GPU(s) listed in the output.

GPU Configuration in Docker Compose

Chunkr’s default compose.yaml configures GPU access for ML services:

Segmentation Backend

Configuration details:
  • replicas: 6 - Six worker processes share available GPUs
  • count: all - All GPUs are available to workers
  • capabilities: [gpu] - Enables GPU support
  • /dev/shm - Shared memory for faster data transfer

OCR Backend

Configuration details:
  • replicas: 3 - Three OCR workers for parallel processing
  • Full GPU access for text recognition
The /dev/shm volume mount enables faster GPU memory transfers and is critical for performance.

Performance Tuning

Batch Size Configuration

Adjust batch sizes based on your GPU memory:
Recommended batch sizes:
  • 6GB GPU: MAX_BATCH_SIZE=2
  • 8GB GPU: MAX_BATCH_SIZE=4 (default)
  • 12GB+ GPU: MAX_BATCH_SIZE=8

Replica Count Optimization

Adjust worker replicas based on GPU count and memory: Single GPU (8GB+):
Multiple GPUs:

Model Parameters

Fine-tune model inference parameters:

Multi-GPU Configuration

To specify exact GPU allocation:
Or limit to a specific count:

Monitoring GPU Usage

Real-time Monitoring

Monitor GPU utilization in real-time:

Per-Container GPU Stats

GPU Memory Usage

Switching to CPU-Only Mode

If GPUs are unavailable or for testing, use CPU mode:
The CPU configuration removes GPU requirements and adjusts settings:
CPU mode is significantly slower. Expect 5-10x longer processing times compared to GPU acceleration.

Troubleshooting

GPU not detected

Check NVIDIA driver:
If this fails, reinstall NVIDIA drivers. Verify Docker GPU access:
Check container toolkit:

Out of memory errors

  1. Reduce batch size:
  2. Decrease replica count:
  3. Monitor GPU memory:

Performance issues

  1. Check GPU utilization - Should be >70% during processing
  2. Verify shared memory - Ensure /dev/shm is mounted
  3. Review batch settings - Optimize MAX_BATCH_SIZE and BATCH_WAIT_TIME
  4. Check for GPU throttling - Monitor temperature with nvidia-smi

Docker Compose GPU errors

Error: “could not select device driver”
Error: “failed to initialize NVML”

Best Practices

  1. Monitor GPU temperature - Keep below 80°C for optimal performance
  2. Use appropriate batch sizes - Balance throughput vs. memory usage
  3. Scale replicas carefully - More replicas isn’t always faster
  4. Regular driver updates - Keep NVIDIA drivers current
  5. Shared memory mounting - Always include /dev/shm volume

Next Steps