Skip to content

Enable PaddleOCR GPU on Linux / CUDA 12 - #25

Open
chsbusch-dot wants to merge 2 commits into
codeproject:mainfrom
chsbusch-dot:cuda12-paddle-gpu
Open

Enable PaddleOCR GPU on Linux / CUDA 12#25
chsbusch-dot wants to merge 2 commits into
codeproject:mainfrom
chsbusch-dot:cuda12-paddle-gpu

Conversation

@chsbusch-dot

Copy link
Copy Markdown

Upstream notes "GPU support on Linux is not currently supported." In practice that's three separate, fixable issues. This PR fixes all three so the ALPR module reports inferenceDevice=GPU on a Linux / CUDA-12 host.

Tested on an RTX A5000 (CUDA 12.4 / 12.7 driver, cuDNN 8.9, Python 3.8).

Changes

  • requirements.linux.cuda12.txtpaddlepaddle-gpu was unpinned, but PyPI only ships CUDA ≤ 11.7 builds, so the CUDA-12 build was never installed and ALPR silently ran on CPU. Pin paddlepaddle-gpu==2.6.2.post120 and add Paddle's cu120 package index via --extra-index-url. (Runs on CUDA 12.0–12.7 drivers via minor-version forward compatibility.)
  • modulesettings.linux.json"InstallGPU": false forced the adapter's enable_GPU off even when a capable GPU was present (use_gpu = enable_GPU and can_use_GPU). Set to true.
  • install.sh — PaddlePaddle dlopens the unversionedlibcudnn.so, but Ubuntu's cuDNN package ships only libcudnn.so.8, causing PreconditionNotMetError: Cannot load cudnn shared library. Symlink libcudnn.so → libcudnn.so.8 on Linux x86_64 during install (guarded: only if the versioned lib exists and the link is missing).

Notes

  • Do not bump to PaddlePaddle 3.x to get a newer CUDA build — it drops Python 3.8 and breaks PaddleOCR 2.7.0.3. This stays on 2.6.2.post120 + paddleocr==2.7.0.3.
  • The .post120 wheel is China-hosted (paddlepaddle.org.cn / bcebos.com); on networks that can't reach it, download the wheel elsewhere and pip install the local file. The InstallGPU flip and libcudnn.so symlink need no network and apply regardless.

Testing

python -c "import paddle; paddle.utils.run_check()" # -> "PaddlePaddle works well on 1 GPU"

and the ALPR module status reports inferenceDevice: GPU.

chsbusch-dotand others added 2 commits July 2, 2026 11:51
CodeProject.AI's ALPR runs PaddleOCR on CPU on CUDA-12 Linux hosts due to
three issues; this fixes all three so the module uses the GPU:
- requirements.linux.cuda12.txt had a bare `paddlepaddle-gpu`, but PyPI only
ships CUDA<=11.7 builds, so a non-CUDA-12 build (or none) was installed. Pin
2.6.2.post120 and add Paddle's cu120 package index so the real CUDA-12 wheel
is used. (Works on CUDA 12.0-12.7 drivers via forward compat.)
- modulesettings.linux.json hardcoded "InstallGPU": false (stale "GPU only
installs easily on Windows" assumption). Flip to true so the adapter's
enable_GPU isn't forced off.
- install.sh: Paddle dlopens the unversioned libcudnn.so, but Ubuntu ships
only libcudnn.so.8. Symlink it during install so cuDNN loads.
Verified on an RTX A5000 (CUDA 12.4/12.7 driver, cuDNN 8.9) container: ALPR
now reports inferenceDevice=GPU.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tall
The CUDA-12 wheel is served only from Paddle's China-hosted index, which many
networks/VMs cannot reach — so the requirements install silently gets no CUDA
build and ALPR runs on CPU. install.sh now falls back to a wheel placed in the
module's wheels/ folder when paddlepaddle isn't already installed. Adds
wheels/README.md documenting where to get the wheel.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chsbusch-dot
chsbusch-dot marked this pull request as ready for review July 2, 2026 19:15
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@chsbusch-dot