简体   繁体   English

在Flask / Bottle中将tensorflow模型用作REST API

[英]Serving tensorflow model as a REST API in Flask / Bottle

I'm serving my tensorflow model in a Python bottle(or flask) framework but I would like to know how to enable the GPU. 我在Python瓶(或烧瓶)框架中服务我的tensorflow模型,但我想知道如何启用GPU。

This is how Im creating the session. 我就是这样创建会话的。

with tf.Session(graph=graph) as sess:
        np_pred_confs, np_pred_boxes = sess.run([pred_confs, pred_boxes], feed_dict=feed_dict_testing)

What should be changed to enable the use of the GPU as I'm running the code on a GPU machine. 我在GPU机器上运行代码时应进行哪些更改以启用GPU的使用。

You need nothing extra to use GPU but just installing GPU version tensorflow. 您只需要安装GPU版本的tensorflow就可以使用GPU。 It will automatically use gpu. 它将自动使用gpu。 Further, you need install cuda and cudnn for GPU version tensorflow. 此外,您需要为GPU版本tensorflow安装cuda和cudnn。

Apart from installing the GPU version of TensorFlow, you also need to install: 除了安装TensorFlow的GPU版本之外,您还需要安装:

  1. the necessary GPU drivers - and specifically NVIDIA only 必要的GPU驱动程序-仅限于NVIDIA
  2. CUDA Toolkit 8.0 and CUDA工具包8.0
  3. cuDNN v6 or v6.1 (select "Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0" ) cuDNN v6或v6.1 (选择“对于CUDA 8.0,下载cuDNN v6.0(2017年4月27日)”

See the per-OS install notes: 请参阅每个操作系统的安装说明:

You'll know that it's working correctly if you see this when you run the getting started example]( https://www.tensorflow.org/get_started/get_started#complete_program ): 如果您在运行入门示例时看到此消息,就会知道它正常工作]( https://www.tensorflow.org/get_started/get_started#complete_program ):

 Found device 0 with properties: name: GeForce GTX... 

and

 Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 

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

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