Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Serving
  • Issue
  • #598

S
Serving
  • 项目概览

PaddlePaddle / Serving
大约 2 年 前同步成功

通知 187
Star 833
Fork 253
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 105
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 10
  • Wiki 2
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
S
Serving
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 105
    • Issue 105
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 10
    • 合并请求 10
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 2
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 5月 22, 2020 by saxon_zh@saxon_zhGuest

python端Client跨线程调用predict报错(numpy输入)

Created by: barrierye

python端client跨线程用numpy预测的时候会偶发性报错(在不报错的情况下预测结果正常),list暂时没遇到这种情况。 可能是GIL的释放导致变量生命周期管理异常(list对应的predict的GIL部分不知道什么时候不见了)

报错信息:

# python profile_org_client.py
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0522 18:25:04.466261 28517 naming_service_thread.cpp:209] brpc::policy::ListNamingService("127.0.0.1:9393"): added 1
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 765, in run
    self.__target(*self.__args, **self.__kwargs)
  File "profile_org_client.py", line 37, in func
    feed={"x": x}, fetch=["price"])
  File "/home/barriery/.local/lib/python2.7/site-packages/paddle_serving_client/__init__.py", line 342, in predict
    result_map[name].shape = shape
ValueError: cannot reshape array of size 0 into shape (1,1)

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 765, in run
    self.__target(*self.__args, **self.__kwargs)
  File "profile_org_client.py", line 37, in func
    feed={"x": x}, fetch=["price"])
  File "/home/barriery/.local/lib/python2.7/site-packages/paddle_serving_client/__init__.py", line 342, in predict
    result_map[name].shape = shape
ValueError: cannot reshape array of size 0 into shape (1,1)

复现代码:

from paddle_serving_client import Client
import numpy as np
import sys
import threading
import time

from line_profiler import LineProfiler
client = Client()
client.load_client_config("uci_housing_client/serving_client_conf.prototxt")
client.connect(["127.0.0.1:9393"])

import paddle

lx = [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584,
        0.6283, 0.4919, 0.1856, 0.0795, -0.0332]
x = np.array(lx, dtype='float')

def func(num):

    for i in range(num):
        fetch_map = client.predict(
            feed={"x": x}, fetch=["price"])
        # print(fetch_map)

thread_num = 3
each_thread = 1000
ths = []
start = time.time()

for i in range(thread_num):
    th = threading.Thread(target=func, args=(each_thread, ))
    th.start()
    ths.append(th)

for i in range(thread_num):
    ths[i].join()

end = time.time()
print("time: {}".format(end - start))
指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/Serving#598
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7