如何在GPU支持下运行python代码 [英] How to run python code with support of GPU

查看:1479
本文介绍了如何在GPU支持下运行python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个flask服务,用于接受带有照相机URL的请求,作为在照相机框架中查找对象(桌子,椅子等)的参数.我已经在烧瓶中编写了接受POST请求的代码.

I have created a flask service for accepting requests with camera URLs as parameters for finding objects(table, chair etc...) in the camera frame. I have written code in flask for accepting POST requests.

@app.route('/rest/detectObjects', methods=['GET','POST'])
def detectObjects()
...
json_result = function_call_for_detecting_objects()
...
return

在该函数中,它加载用于对象检测的tf模型并返回结果. Flask服务器需要同时处理大量请求.因此,我需要使用GPU执行该功能,因为摄像机的访问时间和用于对象检测的图像处理需要大量时间和CPU利用率.拥有4 GB的GeForce GTX 1050 Ti/PCIe/SSE2.我该如何使我的python脚本为此使用GPU?

In the function, its loads the tf model for object detection and returns the result. A large amount of request needs to be processed simultaneously by the flask server. So I need to execute the function using GPU as the camera access time and image processing for object detection takes much time and CPU utilization. Have a 4 GB GeForce GTX 1050 Ti/PCIe/SSE2. How can I make my python script to make use of GPU for this?

推荐答案

安装tensorflow gpu将使脚本自动检测gpu.如果未检测到GPU,请检查驱动程序版本(Cuda和Cudnn).如果没有版本不匹配或错误发生,则脚本可以识别存在的gpu,并将利用gpu运行.

Installing tensorflow gpu will make the script to detect gpu automatically. if it is not detecting the gpu, check the driver versions(Cuda and cudnn). If no version mismatch or errors occur, then the script can identify the gpu present and will run utilizing the gpu.

这篇关于如何在GPU支持下运行python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆