如何使用C ++ API限制Tensorflow(R1.1)中的GPU使用 [英] how to limit GPU usage in tensorflow (r1.1) with C++ API

查看:90
本文介绍了如何使用C ++ API限制Tensorflow(R1.1)中的GPU使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制C ++ API中Tensorflow的GPU分配.我知道如何在 python中进行操作,这可能与传递给NewSession()的struct SessionOptions有关,但是我找不到更具体的信息.

I'd like to limit GPU allocation of tensorflow in the C++ API. I know how to do it in python, and it's probably got something to do with struct SessionOptions passed into NewSession(), but I couldn't find more specific info on how to do it.

Stackoverflow提示我的问题是重复的.但是,我已经链接到该其他帖子.那就是在python中做的事情.我专门问如何在C ++中做到这一点.

Stackoverflow is suggesting that my question is a duplicate. However I already link to that other post. That is how to do it in python. I'm specifically asking how to do it in C++.

推荐答案

结果非常简单:

tensorflow::SessionOptions session_options;
session_options.config.mutable_gpu_options()->set_allow_growth(allow_growth);
session_options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(per_process_gpu_memory_fraction);

这篇关于如何使用C ++ API限制Tensorflow(R1.1)中的GPU使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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