Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用http方式GPU环境推理模型调用报错 #1023

Closed
yihuiluo235 opened this issue Feb 7, 2021 · 1 comment
Closed

使用http方式GPU环境推理模型调用报错 #1023

yihuiluo235 opened this issue Feb 7, 2021 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@yihuiluo235
Copy link

yihuiluo235 commented Feb 7, 2021

环境docker 基于 hub.baidubce.com/paddlepaddle/serving latest-cuda10.0-cudnn7
同样代码在cpu环境下没有问题
其他版本信息
paddle-serving-app (0.2.0) paddle-serving-client (0.4.0) paddle-serving-server-gpu (0.4.0.post10) paddlepaddle-gpu (1.8.5.post107)
报错信息如下:
image

相关运行代码
python3 uwsgi.py
curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"x": [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]}], "fetch":["multiclass_nms_0.tmp_0"]}' http://127.0.0.1:9393/uci/prediction

`#coding=utf-8
from paddle_serving_server_gpu.web_service import WebService
from paddle_serving_app.reader import *
from PIL import Image
from io import BytesIO

import cv2
import numpy as np
import sys
import base64

preprocess = Sequential([
File2Image(), BGR2RGB(), Resize(
(608, 608), interpolation=cv2.INTER_LINEAR), Div(255.0), Transpose(
(2, 0, 1))
])

class UciService(WebService):
def preprocess(self, feed=[], fetch=[]):
print(feed)
#data = base64.b64decode(feed[0]["image"].encode('utf8'))
#data = np.fromstring(data, np.uint8)
#im = cv2.imdecode(data, cv2.IMREAD_COLOR)
#调用本地图片进行测试
car_im = preprocess("./22.jpg")
is_batch = True
print(car_im.shape)
print(np.array(list(car_im.shape[1:])).shape)
feed = [{
"image": car_im,
"im_size": np.array(list(car_im.shape[1:]))
}]
return feed, fetch, is_batch
def postprocess(self, feed={}, fetch=[], fetch_map=None):
print(fetch)
print(fetch_map)
return fetch

#配置预测服务
uci_service = UciService(name = "uci")
uci_service.load_model_config("./car_server")
uci_service.prepare_server(workdir="./workdir", port=9393, device="gpu", gpuid=0)
uci_service.run_rpc_service()
uci_service.run_web_service()
#获取flask服务
app_instance = uci_service.get_app_instance()
`

@TeslaZhao
Copy link
Collaborator

image
请检查一下feed的shape

@TeslaZhao TeslaZhao self-assigned this Feb 18, 2021
@TeslaZhao TeslaZhao added the question Further information is requested label Feb 18, 2021
@paddle-bot paddle-bot bot closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants