首页 新闻 会员 周边

运行Keras模型,设置CPU使用上限时,会报错是怎么回事呢?

0
[已关闭问题] 关闭于 2019-09-11 08:15

跑个keras算法库的模型,为防止电脑被占用过多资源,我设置了CPU的使用内核数,具体代码如下:

import tensorflow as tf
import keras.backend.tensorflow_backend as KTF

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #忽略CPU编译不支持警告
config = tf.ConfigProto()
config.device_count = {'CPU': 4} #该句代码注释掉,才不会报错
config.intra_op_parallelism_threads = 4
config.inter_op_parallelism_threads = 4
config.allow_soft_placement = True
config.log_device_placement = True #不打印设备分配日志
sess = tf.Session(config=config)
KTF.set_session(sess)
运行发现报错:Assignment not allowed to repeated field "device_count" in protocol message object。。
很是让人奇怪~~~
这个该怎么解决呢?

老笨啊的主页 老笨啊 | 初学一级 | 园豆:6
提问于:2019-09-06 09:28
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册