PaddleOcrNet.Gpu 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PaddleOcrNet.Gpu --version 2.2.0
                    
NuGet\Install-Package PaddleOcrNet.Gpu -Version 2.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PaddleOcrNet.Gpu" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PaddleOcrNet.Gpu" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="PaddleOcrNet.Gpu" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PaddleOcrNet.Gpu --version 2.2.0
                    
#r "nuget: PaddleOcrNet.Gpu, 2.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PaddleOcrNet.Gpu@2.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PaddleOcrNet.Gpu&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=PaddleOcrNet.Gpu&version=2.2.0
                    
Install as a Cake Tool

PaddleOcrNet.Gpu

CUDA GPU acceleration for PaddleOcrNet — high-accuracy native .NET OCR powered by PaddleOCR's neural models on ONNX Runtime.

This is a metapackage. It contains no code of its own: it pulls in PaddleOcrNet together with Microsoft.ML.OnnxRuntime.Gpu, so the CUDA execution provider is present at runtime and PaddleOcrNet can select it.

dotnet add package PaddleOcrNet.Gpu

Installing this package instead of PaddleOcrNet is all that is required — it brings the core library with it.

Usage

There is no separate GPU API. Existing code is unchanged; PaddleOcrNet detects the CUDA provider and uses it automatically:

using PaddleOcrNet.Models;
using PaddleOcrNet.Services;

await using var ocr = new PaddleOcrService();

OcrResult result = await ocr.ExtractTextFromImage("invoice.png", OcrLanguage.English);

Console.WriteLine(result.UsedGpu);   // true when a GPU provider was selected
Console.WriteLine(result.FullText);

ExecutionProvider defaults to OcrExecutionProvider.Auto, which probes the loaded ONNX Runtime and picks the best accelerator available, falling back to CPU when none is:

Platform Auto-detect order
Windows DirectML → CUDA → CPU
Linux CUDA → CPU
macOS CoreML → CPU

To pin a provider rather than auto-detecting:

await using var ocr = new PaddleOcrService(new PaddleOcrServiceOptions
{
    ExecutionProvider = OcrExecutionProvider.Cuda,   // or Cpu / DirectMl / CoreMl / Auto
});

PaddleOcrServiceOptions.UseGpu = true is kept as shorthand for forcing CUDA, but prefer leaving ExecutionProvider at Auto — it already enables a GPU when one is present.

Requirements

  • An NVIDIA GPU with the proprietary driver installed, and the CUDA 13.x toolkit with cuDNN 9 (CUDA 12 is supported by pinning ONNX Runtime yourself — see below).
  • Windows or Linux. Microsoft.ML.OnnxRuntime.Gpu ships native assets for those two platforms only. On macOS this package has nothing to contribute; install plain PaddleOcrNet and let Auto select CoreML.

Running on CUDA 12

This package brings in ONNX Runtime 1.30, whose GPU build targets CUDA 13 — as has every ONNX Runtime release since 1.27:

ONNX Runtime CUDA cuDNN
1.27.x and later 13.0 9.x
1.21.x – 1.26.x 12.8 9.x

On a machine with only the CUDA 12 toolkit, that runtime looks for cublasLt64_13.dll (libcublasLt.so.13), fails to attach the CUDA provider, and PaddleOcrNet falls back to CPU. The warning it logs names the missing library and the CUDA major version the runtime wanted, so the mismatch is visible without decoding Error 126.

There are three ways to get a GPU out of a CUDA 12 machine. Installing an older PaddleOcrNet does not help — every release so far has referenced a CUDA 13 build of ONNX Runtime (1.27 up to 2.1.0, 1.30 since 2.2.0).

1. Install the CUDA 13 runtime next to CUDA 12. The two majors coexist: their libraries are suffixed (cublasLt64_12.dll vs cublasLt64_13.dll), so adding CUDA 13 leaves existing CUDA 12 workloads alone. This keeps you on the current ONNX Runtime and needs no project changes.

2. Pin ONNX Runtime 1.26 in your own project. Pin both packages — they ship the same managed assembly and must not split — and suppress NU1605, which NuGet raises because a direct reference below a transitive one counts as a downgrade:

<PropertyGroup>
  <NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Microsoft.ML.OnnxRuntime.Gpu" Version="1.26.0" />
  <PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.26.0" />
</ItemGroup>

A direct reference always wins over the transitive one, so this is all that is needed — nothing about PaddleOcrNet itself changes, and ExecutionProvider still resolves CUDA automatically.

3. Use DirectML instead of CUDA (Windows only). DirectML runs on any DirectX 12 GPU — NVIDIA included — with no CUDA toolkit at all. Install Microsoft.ML.OnnxRuntime.DirectML instead of this package; ExecutionProvider.Auto already prefers DirectML over CUDA on Windows, so no code changes are needed:

dotnet add package Microsoft.ML.OnnxRuntime.DirectML

If CUDA is unavailable at runtime — no driver, missing libraries, no compatible device — provider selection logs the reason and falls back to CPU rather than throwing. OcrResult.UsedGpu reports what was actually used, so a silent fallback is still observable.

Diagnosing a CPU fallback

When OCR runs on CPU and you expected a GPU, ask the service what happened:

await using var ocr = new PaddleOcrService();
Console.WriteLine(ocr.GetRuntimeInfo());
PaddleOcrNet runtime:
  ONNX Runtime:        1.30.0
  Available providers: TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider
  Requested provider:  Auto
  Resolved provider:   Cuda
  Active provider:     Cpu
  GPU probe:           NVIDIA GPU detected
  Hint:                ...

Read it top-down. Available providers is fixed at build time by the ONNX Runtime package you installed: if CUDAExecutionProvider is not in that list, no runtime setting can bring it back. Resolved is the provider PaddleOcrNet attempted and Active is what it is really running on; when those differ, the accelerator failed to attach and Hint says why. The same text is on PaddleOcrService.GpuAccelerationHint, and an attach failure is written once to standard error even when no ILogger is configured.

The native-asset conflict (fixed in this package)

Before the fix, PaddleOcrNet.Gpu could never reach the GPU on any machine. PaddleOcrNet depends on Microsoft.ML.OnnxRuntime (the CPU native package) and this package adds Microsoft.ML.OnnxRuntime.Gpu, so both ended up in the graph. They ship the same asset path — runtimes/win-x64/native/onnxruntime.dll, runtimes/linux-x64/native/libonnxruntime.so — and NuGet gives that single slot to exactly one of them: the CPU package. Applications got the 246 MB onnxruntime_providers_cuda.dll deployed next to a core runtime with no CUDA support compiled in, which never loads it. GetAvailableProviders() reported only CPUExecutionProvider and AzureExecutionProvider, Auto resolved to CPU, and — because no provider was ever attempted — nothing threw and nothing logged.

This package now carries an MSBuild targets file that copies the GPU build's core runtime over the CPU one after build and after publish, so the CUDA provider has a runtime that can load it. It needs no change in your project. To opt out (for instance to deliberately ship the CPU runtime), set:

<PropertyGroup>
  <PaddleOcrNetGpuPreferGpuRuntime>false</PaddleOcrNetGpuPreferGpuRuntime>
</PropertyGroup>

On an older version, the equivalent manual fix is to keep the CPU package's natives out of the build:

<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.30.0" ExcludeAssets="native" />

Notes

  • Install either PaddleOcrNet or PaddleOcrNet.Gpu, not both — this package already references the core library and pins it to a matching version.
  • The GPU packages add a substantial native payload. For CPU-only deployments, and for Native AOT, trimmed or container images where size matters, use plain PaddleOcrNet.
  • OCR models are downloaded and cached on first use exactly as with the CPU package; GPU selection does not change model sourcing.

License

MIT © PaddleOcrNet contributors. Downloaded models are Apache-2.0 / MIT and attributed to their authors.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.1 167 11/15/2026
2.4.0 217 10/16/2026
2.3.1 178 10/13/2026
2.3.0 173 10/12/2026
2.2.1 189 9/29/2026
2.2.0 241 9/14/2026
2.1.0 234 9/4/2026
2.0.4 229 9/4/2026
2.0.3 223 9/1/2026
2.0.2 247 8/28/2026
2.0.1 238 8/27/2026
2.0.0 241 8/26/2026
1.0.0 359 6/21/2026