限制 Keras 中使用的内核数 [英] Limit number of cores used in Keras

查看:21
本文介绍了限制 Keras 中使用的内核数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台有 64 个内核的共享机器,在上面我有大量要运行的 Keras 函数.问题是 Keras 似乎会自动使用所有可用的内核,而我不能这样做.

I have a shared machine with 64 cores on which I have a big pipeline of Keras functions that I want to run. The thing is that it seems that Keras automatically uses all the cores available and I can't do that.

我使用 Python,我想在 for 循环中运行 67 个神经网络.我想使用一半的可用内核.

I use Python and I want to run 67 neural networks in a for loop. I would like to use half of the available cores.

我在 Keras 中找不到任何限制内核数量的方法...你有什么线索吗?

I can't find any way of limiting the number of cores in Keras... Do you have any clue?

推荐答案

正如@Yu-Yang 建议的那样,我在每次合身之前都使用了这条线:

As @Yu-Yang suggested, I used this line before each fit I do :

from keras import backend as K
K.set_session(K.tf.Session(config=K.tf.ConfigProto(intra_op_‌​parallelism_threads=‌​32, inter_op_parallelism_threads=32)))

检查CPU使用率(htop):

Check the CPU usage (htop) :

这篇关于限制 Keras 中使用的内核数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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