ValueError:GraphDef cannot be larger than 2GB.解决办法
在使用TensorFlow 1.X版本的estimator的时候经常会碰到类似于 ValueError:GraphDef cannot be larger than 2GB 的报错信息,可能的原因是数据太大无法写入graph。 一般来说,常见的数据构建方法如下: def input_fn(): features, labels = (np.random.sample((100,2)), np.random.sample((100,1))) dataset = tf.data.Dataset.from_tensor_slices((features,labels)) dataset = dataset.shuffle(100000).repeat().batch(batch_size) return dataset ... estimator.train(input_fn) TensorFlow在读取数据的时候会将数据也写入Graph,所以当数据量很大的时候会碰到这种情况,之前做实验在多GPU的时候也会遇到这种情况,即使我把batch size调到很低。所以解决办法有两种思路,一直不保存graph,而是使用 feed_dict 的方式来构建input pipeline。 不写入graph 我的代码环境是TensorFlow1.14,所以我以这个版本为例进行介绍。