查看: 1917|回复: 6

Limit the resource usage for tensorflow backend

[复制链接]

665

主题

1234

帖子

6567

积分

xdtech

Rank: 5Rank: 5

积分
6567
发表于 2019-2-9 20:57:06 | 显示全部楼层 |阅读模式
When I use tensorflow as backend I got an high memory usage on my GPUs. I check that is possible to limit memory usage by using `tf.ConfigProto`


```shell
config = tf.ConfigProto(
    gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5),
    device_count = {'GPU': 1}
)


sess_1 = tf.Session(graph=graph_1, config=config)
sess_2 = tf.Session(graph=graph_2, config=config)
```


would it be useful to add this option in keras? if yes where is the best place to do it without corrupt keras design principles?


You can configure and pass a tensorflow session to Keras


```
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.3
set_session(tf.Session(config=config))
```
On the other hand I can't find it in the documentation, so I don't know if that's a stable feature. (I just finally thought of looking for `ConfigProto` in the source to see if I could "fix" this problem for myself.)

回复

使用道具 举报

81

主题

162

帖子

493

积分

推广大使

积分
493
发表于 2019-2-22 18:10:34 | 显示全部楼层
意思就是
设定的GPU占用比率太高
实际满足不了
回复

使用道具 举报

81

主题

162

帖子

493

积分

推广大使

积分
493
发表于 2019-2-22 18:10:48 | 显示全部楼层
这个选项
最好是
不要用
回复

使用道具 举报

81

主题

162

帖子

493

积分

推广大使

积分
493
发表于 2019-2-22 18:10:58 | 显示全部楼层
其实交给tf
自动管理
师最好的
回复

使用道具 举报

166

主题

616

帖子

1万

积分

xdtech

Rank: 5Rank: 5

积分
10723
发表于 2019-2-25 18:34:27 | 显示全部楼层
哈哈
这个有,好
之前有个报错就是与此相关
回复

使用道具 举报

166

主题

616

帖子

1万

积分

xdtech

Rank: 5Rank: 5

积分
10723
发表于 2019-2-25 18:34:39 | 显示全部楼层
最好是
让tensorflow
自己来定GPU使用
回复

使用道具 举报

166

主题

616

帖子

1万

积分

xdtech

Rank: 5Rank: 5

积分
10723
发表于 2019-2-25 18:34:47 | 显示全部楼层
当然,要并发
就得自己来
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表