Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

NotImplementedError in oneDNN PIR conversion breaks CPU inference in PaddlePaddle 3.3.0

Open glenn-jocher opened this issue 10 months ago • 12 comments

bug描述 Describe the Bug

Environment

  • PaddlePaddle version: 3.3.0 (just released on PyPI)
  • Python version: 3.12
  • OS: Ubuntu Linux (x86_64)
  • Hardware: CPU with oneDNN (default configuration)

Issue Description

CPU inference using paddle.inference fails with NotImplementedError in PaddlePaddle 3.3.0. This regression breaks inference for models exported from frameworks like Ultralytics YOLO. The issue occurs in the PIR (Paddle Intermediate Representation) to oneDNN conversion layer.

This worked correctly in PaddlePaddle 3.2.x and earlier.

Steps to Reproduce

import paddle.inference as pdi
import numpy as np

# Load exported PaddlePaddle model
model_dir = "yolo11n_paddle_model"
config = pdi.Config(f"{model_dir}/model.pdmodel", f"{model_dir}/model.pdiparams")
predictor = pdi.create_predictor(config)

# Setup input
input_handle = predictor.get_input_handle(predictor.get_input_names()[0])
input_handle.copy_from_cpu(np.random.randn(1, 3, 640, 640).astype(np.float32))

# Run inference - FAILS in 3.3.0
predictor.run()

Error Message

NotImplementedError: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>].
  [Hint: Expected false, but it was true.] (at /paddle/paddle/fluid/pir/transforms/onednn/onednn_instruction.cc:116)

Expected vs Actual Behavior

- Expected: Inference completes successfully (as in 3.2.x)
- Actual: NotImplementedError raised during predictor.run()

Workaround

Downgrade to PaddlePaddle 3.2.2:
pip install paddlepaddle==3.2.2

Impact

This is a breaking change affecting:
- All CPU inference using oneDNN (default on Linux)
- Ultralytics YOLO PaddlePaddle export users
- Any application using paddle.inference on CPU

### 其他补充信息 Additional Supplementary Information

- Ultralytics CI failure: https://github.com/ultralytics/ultralytics/actions
- Affected code path: onednn_instruction.cc:116

glenn-jocher avatar Jan 13 '26 12:01 glenn-jocher

I see the same issue when I am getting started on PaddleOCR.

davidkhala avatar Jan 16 '26 05:01 davidkhala

When can a fix be released? I see there is a PR that needs some more work. This bug is preventing upgrades to 3.3.

alexaryn avatar Feb 05 '26 21:02 alexaryn

I am using version 3.4.0 and I am having the same issue. Which version is stable so that try to use PaddleOCR?

mpilioun avatar Feb 10 '26 10:02 mpilioun

Having the same issue, is there any fix possibly on the way? Thanks!

sawoz avatar Feb 11 '26 23:02 sawoz

Also have the same problem also.

GarlicToothpaste avatar Feb 15 '26 11:02 GarlicToothpaste

PaddleOCR 3.4.0 + PaddlePaddle 3.3.0: MKLDNN Backend Crash

Symptoms

When running PaddleOCR inference on CPU, the process crashes with:

NotImplementedError: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support
[pir::ArrayAttribute<pir::DoubleAttribute>]
(at /paddle/paddle/fluid/framework/new_executor/instruction/onednn/onednn_instruction.cc:116)

Other variations of the same root cause:

  • ResourceExhaustedError: Fail to alloc memory of 24546115584 size
  • PaddleOCR.predict() got an unexpected keyword argument 'cls'

Root Cause

PaddleOCR 3.4.0 uses PaddleX as its inference backend. For CPU inference, PaddleX defaults to run_mode="mkldnn" (Intel oneDNN). You can verify this yourself:

from paddlex.inference.models.common.static_infer import get_default_run_mode

print(get_default_run_mode("PP-OCRv4_mobile_det", "cpu"))  # "mkldnn"
print(get_default_run_mode("en_PP-OCRv4_mobile_rec", "cpu"))  # "mkldnn"

PaddlePaddle 3.3.0 has a bug where its new PIR (Paddle Intermediate Representation) is incompatible with the MKLDNN instruction converter. The crash happens deep inside the static inference engine at predictor.run().

Important: Setting FLAGS_use_mkldnn=0 as an environment variable does not help. PaddleX controls the inference backend through its own PaddlePredictorOption.run_mode and ignores the Paddle-level flag.

Fix

Pass enable_mkldnn=False to the PaddleOCR() constructor:

from paddleocr import PaddleOCR

ocr = PaddleOCR(
    lang="en",
    ocr_version="PP-OCRv4",
    enable_mkldnn=False,  # prevents MKLDNN/PIR crash
)

results = list(ocr.predict(image_array))

How it works

The enable_mkldnn kwarg flows through the following chain:

  1. PaddleOCR.__init__(**kwargs) passes unknown kwargs to super().__init__()
  2. PaddleXPipelineWrapper.__init__() calls parse_common_args(kwargs)
  3. parse_common_args() recognizes enable_mkldnn and stores it in common config
  4. PaddleX configures the inference predictor with run_mode="paddle" instead of run_mode="mkldnn"

This bypasses the broken MKLDNN/PIR code path entirely.

Docker Compose

As additional insurance, set the environment variable in your docker-compose.yml:

services:
  worker:
    environment:
      - FLAGS_use_mkldnn=0
      - PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True

The second variable skips a slow connectivity check to HuggingFace on startup.

Affected Versions

  • PaddleOCR 3.4.0
  • PaddlePaddle 3.3.0
  • CPU-only inference on x86_64 Linux

GPU inference is not affected since it uses CUDA, not MKLDNN.

makdinoven avatar Feb 18 '26 16:02 makdinoven

This error occurred because I forgot to activate the correct conda environment containing the proper PaddlePaddle installation. After activating the correct environment, CPU inference worked normally. This was an environment issue rather than a framework bug.

krudo-taco avatar Feb 24 '26 21:02 krudo-taco

Any update on this? I see you have https://github.com/PaddlePaddle/Paddle/pull/77430 for fixing it.

ynaftali-island avatar Mar 16 '26 16:03 ynaftali-island

哪个版本可用?

jianboy avatar Aug 04 '26 05:08 jianboy

Still reproduces on the latest PyPI release, with a newer PaddleOCR pairing than the ones reported above:

  • paddlepaddle 3.3.1 (current latest on PyPI) + paddleocr 3.7.0, Python 3.12, linux/amd64
  • Same message, onednn_instruction.cc:116: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttributepir::DoubleAttribute]
  • paddlepaddle==3.2.2, same image and same code: loads and runs fine.

It does not need a real document or an exported YOLO model — a blank image is enough:

ocr = paddleocr.PaddleOCR( ocr_version="PP-OCRv6", lang="en", enable_mkldnn=True, use_doc_orientation_classify=False, use_doc_unwarping=False, use_textline_orientation=False, ) ocr.predict(np.full((64, 256, 3), 255, dtype=np.uint8)) # raises

#77430 merged to develop (12bff203) │ 2026-04-16 , but the fix appears to have missed every published release.

For those asking which version to use: 3.2.2 is the newest release without this bug.

Question — is a 3.3.2 (or 3.4) release planned that would carry 12bff203? A patch release seems like the only thing that will stop the duplicates here, since the merged fix is currently unreachable from PyPI.

jialu98 avatar Aug 31 '26 19:08 jialu98

Confirmed on Windows with a self-contained PaddleOCR reproducer. Environment

  • Windows 11 x64
  • Python 3.12.10
  • paddlepaddle 3.3.0 CPU
  • paddleocr 3.7.0
  • paddlex 3.7.2
  • oneDNN 3.6.2
import numpy as np
from paddleocr import PaddleOCR

ocr = PaddleOCR(
    text_detection_model_name="PP-OCRv5_mobile_det",
    text_recognition_model_name="eslav_PP-OCRv5_mobile_rec",
    use_doc_orientation_classify=False,
    use_doc_unwarping=False,
    use_textline_orientation=False,
    device="cpu",
)
list(ocr.predict(np.full((128, 512, 3), 255, dtype=np.uint8)))
This fails at predictor.run() with:
NotImplementedError: (Unimplemented)
ConvertPirAttribute2RuntimeAttribute not support
[pir::ArrayAttribute<pir::DoubleAttribute>]
(at ..\paddle\fluid\framework\new_executor\instruction\onednn\onednn_instruction.cc:118)

The same code and models work with paddlepaddle==3.2.2.

Moodrost avatar Sep 16 '26 15:09 Moodrost

Hitting this same regression from a completely different workload.

PaddleOCR (specifically the PP-OCRv6_medium_det text detection model), not YOLO, which suggests this isn't specific to one export path but a general oneDNN PIR-conversion regression in 3.3.0/3.3.1.

Environment:

paddlepaddle 3.3.1 (also reproduces on 3.3.0)
Linux, CPU inference, enable_mkldnn=True (the library default)
Model: PP-OCRv6_medium_det (PaddleOCR 3.7.0 / PaddleX 3.7.2)

Error:

NotImplementedError: (Unimplemented) ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>]
Same failure signature as the original report, same onednn_instruction.cc:116 origin.

Confirmed workaround: downgrading to paddlepaddle==3.2.2 resolves it with enable_mkldnn=True still on. Disabling oneDNN on 3.3.1 also avoids the crash, but we measured 3-6x slower inference for identical output vs. 3.2.2+oneDNN, so that's not a viable workaround for a latency-sensitive service, the version pin is the only practical fix on our end for now.

Happy to help narrow this down to a minimal repro if that's useful, this is currently blocking us from upgrading past 3.2.2.

Jarrar-Haider5 avatar Sep 22 '26 12:09 Jarrar-Haider5