【发布时间】:2018-08-14 00:55:03
【问题描述】:
所以我在 tensorflow 中训练一个 NN,同时我正在监控我的 GPU 负载。
从截图中我看到 Tensorflow 基本上只使用 GPU 内存,这正常吗?我认为他们利用我所有的 cuda 核心来执行一些计算等。
有没有人详细了解这些东西?
提前致谢!
代码来了...
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.INFO)
# ... some file reading here
def train_input_fn(features, labels, batch_size):
return tf.estimator.inputs.pandas_input_fn(
x = features,
y = labels,
num_epochs = 1,
shuffle = True,
batch_size = batch_size)
def eval_input_fn(features, labels):
return tf.estimator.inputs.pandas_input_fn(
x = features,
y = labels,
num_epochs = 1,
shuffle = True)
def pred_input_fn(features):
return tf.estimator.inputs.pandas_input_fn(
x = features,
num_epochs = 1,
shuffle = False)
model_dir = './DNN_Linear_Combined_Regressor'
file_writer = tf.summary.FileWriter(model_dir)
estimator = tf.estimator.DNNLinearCombinedRegressor(
model_dir = model_dir,
linear_feature_columns = wide_columns,
dnn_feature_columns = deep_columns,
dnn_optimizer = tf.train.AdamOptimizer(learning_rate=0.001),
dnn_hidden_units = [64,64,64,8],
batch_norm = True,
dnn_dropout = 0.1
)
train_spec = tf.estimator.TrainSpec(input_fn = train_input_fn(train, y_train, batch_size=5000))
eval_spec = tf.estimator.EvalSpec(input_fn = eval_input_fn(valid, y_valid))
tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)
【问题讨论】:
-
您应该发布您的代码,以便我们查看您是否做错了什么。 TensorFlow 应该同时使用 GPU 内存和计算。
-
可以参考编辑
-
尝试更改批量大小 (stackoverflow.com/questions/52159053/…)
标签: python tensorflow gpu