Skip to content

Paddle在M系列mac机器上 pypi预编译包进行静态图infer时会hang住 #63344

@ltcs11

Description

@ltcs11

请提出你的问题 Please ask your question

使用设备为macbook pro M2 ,系统版本14.4.1

在使用pip安装的paddlepaddle(包括2.3.2,2.4.2,2.5.2),均在运行静态图的infer过程中hang住,其中2.3.2还会出现segmentFault后退出

采用的是官方教程中的示例代码,包括使用inference API也出现同样问题

import paddle
import numpy as np

paddle.enable_static()

startup_prog = paddle.static.default_startup_program()
main_prog = paddle.static.default_main_program()
with paddle.static.program_guard(main_prog, startup_prog):
    image = paddle.static.data(name="img", shape=[64, 784])
    w = paddle.create_parameter(shape=[784, 200], dtype='float32')
    b = paddle.create_parameter(shape=[200], dtype='float32')
    hidden_w = paddle.matmul(x=image, y=w)
    hidden_b = paddle.add(hidden_w, b)
exe = paddle.static.Executor(paddle.CPUPlace())
exe.run(startup_prog)

print('model saved')
path_prefix = "./infer_model"
paddle.static.save_inference_model(path_prefix, [image], [hidden_b], exe)

# [inference_program, feed_target_names, fetch_targets] = (
#     paddle.static.load_inference_model(path_prefix, exe))
# tensor_img = np.array(np.random.random((64, 784)), dtype=np.float32)
# results = exe.run(inference_program,
#               feed={feed_target_names[0]: tensor_img},
#               fetch_list=fetch_targets)
import paddle.inference as paddle_infer
config = paddle_infer.Config(path_prefix + '.pdmodel', path_prefix + '.pdiparams')
predictor = paddle_infer.create_predictor(config)
# 获取输入的名称
input_names = predictor.get_input_names()
input_handle = predictor.get_input_handle(input_names[0])

# 设置输入
fake_input = np.random.randn(64, 784).astype("float32")
input_handle.copy_from_cpu(fake_input)
predictor.run()
output_names = predictor.get_output_names()
output_handle = predictor.get_output_handle(output_names[0])
output_data = output_handle.copy_to_cpu() # numpy.ndarray类型
print('model tested')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions