我已经找到了可以在GPU上使用Estimator Model的信息,我需要以下代码:
# Create a tf.estimator.RunConfig to ensure the model is run on CPU, which
# trains faster than GPU for this model.
run_config = tf.estimator.RunConfig().replace(
session_config=tf.ConfigProto(device_count={'GPU': 0},
inter_op_parallelism_threads=inter_op,
intra_op_parallelism_threads=intra_op))
代码源: https://github.com/tensorflow/models/blob/master/official/wide_deep/census_main.py
这是正确的吗?因为我得到了错误:
NameError: name 'inter_op' is not defined
UPD:inter_op应该是什么样的?如何选择其价值?
答案 0 :(得分:3)
您需要先定义变量,然后再使用它们,并将GPU计数设置为非零数字。
inter_op = 10
intra_op = 10
session_config=tf.ConfigProto(device_count={'GPU': 1},
inter_op_parallelism_threads=inter_op,
intra_op_parallelism_threads=intra_op))