9951 explained code solutions for 126 technologies


tesseract-ocrHow can I set up tesseract OCR with GPU acceleration?


  1. Install CUDA and cuDNN according to your GPU type.

  2. Install tesseract-ocr with GPU acceleration enabled:

$ git clone https://github.com/tesseract-ocr/tesseract
$ cd tesseract
$ ./autogen.sh
$ ./configure --enable-gpu --with-cuda-dir=/usr/local/cuda --with-cudnn-dir=/usr/local/cudnn
$ make
$ sudo make install
  1. Test GPU acceleration:
$ tesseract --list-langs

Output example

List of available languages (4):
eng
osd
  1. Set environment variables:
$ export TESSERACT_ENABLE_GPU=1
$ export TESSERACT_GPU_EXECUTABLE=/usr/local/cuda/bin/nvcc
  1. Run tesseract with GPU acceleration:
$ tesseract --oem 1 --psm 3 --tessdata-dir /usr/local/share/tessdata <image> <output>
  1. Check the GPU usage with nvidia-smi command.

  2. For more information, see the Tesseract OCR documentation.

Edit this code on GitHub