简体   繁体   English

Keras模型服务-GPU与CPU

[英]Keras Model Serving- GPU vs CPU

I would like to put my Keras NER model up to my website which is Django based. 我想将我的Keras NER模型放到基于Django的网站上。

My question is that when served, should the model be run on CPU or GPU? 我的问题是,投放后,该模型应在CPU还是GPU上运行? How would a GPU handle let's say hundreds of users sending requests at the same time since it cant do multi threading like CPUs can. 假设GPU不能像CPU一样执行多线程处理,那么如何处理数百个用户同时发送请求。

Thanks for your time. 谢谢你的时间。

"hundreds of users" will necessitate using a GPU. “数百个用户”将需要使用GPU。

knowing what your users are doing might give more insight, but I would consider having a dedicated instance for your model. 知道您的用户正在做什么可能会提供更多的见解,但我会考虑为您的模型准备一个专用的实例。 Design a small program that is persistent and waits for input data using a queue strategy. 设计一个持久的小程序,并使用队列策略等待输入数据。

Let's say you have "100s" of users uploading "text documents" for your ner model. 假设您有上百个用户为您的神经网络模型上传“文本文档”。 Your web application would gather/validate the text upload/post and make a socket connection to your model server, pass the text, receive the response, parse the response and respond to the user accordingly. 您的Web应用程序将收集/验证文本上传/发布,并建立与模型服务器的套接字连接,传递文本,接收响应,解析响应并相应地响应用户。

Your model server has a socket listener that upon connection, passes the socket+data request to a queue. 您的模型服务器具有一个套接字侦听器,该侦听器在连接后会将套接字+数据请求传递到队列。 Your model sits and waits...looking at that queue--takes any item in the queue, processes and passes the results back via the included socket(serialized handle). 您的模型坐下来等待...看着那个队列-取出队列中的任何项目,处理并通过附带的套接字(序列化句柄)将结果传递回去。 It's a bit messy in python but works fine. 它在python中有点混乱,但效果很好。 The reasons to have a persistent model running: 1) for "100s" of users, spinning up a model app each time takes several seconds. 运行持久模型的原因:1)对于“ 100个”用户,每次启动模型应用程序都需要几秒钟。 having it already initialized and ready to go will help user experience. 将其初始化并准备好使用将有助于用户体验。 2) using one gpu server you don't want competition for gpu resources. 2)使用一台gpu服务器,您不希望竞争gpu资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM