-1

I've found the information that so as to use Estimator Model on GPU I need the following code:

# 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))

Source of code: https://github.com/tensorflow/models/blob/master/official/wide_deep/census_main.py

Is this correct? Because I got the error:

NameError: name 'inter_op' is not defined

UPD: What is inter_op supposed to be like? How to choose its value?

James Flash
  • 528
  • 7
  • 15
  • 2
    You need to define inter_op. It should be the number of parallel threads you want. – Ruzihm Sep 21 '18 at 16:37
  • I know but how to do it? What is it like? – James Flash Sep 21 '18 at 16:39
  • Possible duplicate of [Meaning of inter\_op\_parallelism\_threads and intra\_op\_parallelism\_threads](https://stackoverflow.com/questions/41233635/meaning-of-inter-op-parallelism-threads-and-intra-op-parallelism-threads) – Ruzihm Sep 21 '18 at 16:43
  • Threads. Okey. One second – James Flash Sep 21 '18 at 16:44
  • My question is not exact dupliate because the main problem is to run on GPU rather than what is the meaning of threads variables – James Flash Sep 21 '18 at 17:19
  • if all you want to do is run on the GPU, then `config = tf.ConfigProto()` and then `sess = tf.Session( config = config)` will run that session on your GPU by default. You don't need to set any ConfigProto parameters manually. – Ruzihm Sep 21 '18 at 17:29
  • I can't use tf.Session because I employ tf.Estimator. Nevertheless, thank you very much for help – James Flash Sep 21 '18 at 19:21
  • Use `runConfig = tf.ConfigProto()` – Ruzihm Sep 21 '18 at 19:40

1 Answers1

3

You need to define the variables before you use them, as well as set the GPU count to a non-zero number.

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))
Ruzihm
  • 19,749
  • 5
  • 36
  • 48