From 2f1d9a15d77511c69492406c2b3814b9fc799649 Mon Sep 17 00:00:00 2001 From: grloper Date: Tue, 1 Sep 2026 21:23:55 +0300 Subject: [PATCH] fix: disable oneDNN/mkldnn by default on Windows CPU PaddlePaddle 3.3+ PIR executor crashes on Windows CPU during inference with: NotImplementedError: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute]. This happens because DEFAULT_ENABLE_MKLDNN=True, and paddlex enables oneDNN when the run_mode contains mkldnn. Disable mkldnn by default on win32 so out-of-the-box CPU inference works; other platforms keep the existing behavior, and users can still opt in with PaddleOCR(enable_mkldnn=True). Refs: https://github.com/PaddlePaddle/Paddle/issues/77340 https://github.com/PaddlePaddle/PaddleOCR/issues/17869 --- paddleocr/_constants.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/paddleocr/_constants.py b/paddleocr/_constants.py index d96ba780ffa..ff30ecb8450 100644 --- a/paddleocr/_constants.py +++ b/paddleocr/_constants.py @@ -12,10 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import sys + DEFAULT_DEVICE = None DEFAULT_USE_TENSORRT = False DEFAULT_PRECISION = "fp32" -DEFAULT_ENABLE_MKLDNN = True +# oneDNN (mkldnn) is broken in the PaddlePaddle 3.3+ PIR executor on Windows +# CPU: inference crashes with `ConvertPirAttribute2RuntimeAttribute` / +# `[pir::ArrayAttribute]` (see +# https://github.com/PaddlePaddle/Paddle/issues/77340 and +# https://github.com/PaddlePaddle/PaddleOCR/issues/17869). Disable it by +# default on win32 so out-of-the-box CPU inference works; users on other +# platforms (or with a fixed Paddle) can still opt in with +# `PaddleOCR(enable_mkldnn=True)`. +DEFAULT_ENABLE_MKLDNN = False if sys.platform == "win32" else True DEFAULT_MKLDNN_CACHE_CAPACITY = 10 DEFAULT_CPU_THREADS = 10 SUPPORTED_PRECISION_LIST = ["fp32", "fp16"]