跑个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。。
很是让人奇怪~~~
这个该怎么解决呢?