How to run tensorflow benchmark tool on GPU? https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/benchmark
Tensorflow includes an abstract class that provides helpers for TensorFlow benchmarks: Benchmark
So, a Benchmark object can be made and used to execute a benchmark on part of a tensorflow graph.
In the code below, a benchmark object is instantiated and then, the run_op_benchmark method is called.
The run_op_benchmark is passed in the session, the conv_block Tensor (in this case), a feed_dict, a number of burn iterations, the desired minimum number of iterations, a boolean flag to keep the benchmark from also computing memory usage and a convenient name.
The method returns a dictionary containing the benchmark results:
benchmark = tf.test.Benchmark()
results = benchmark.run_op_benchmark(sess=sess, op_or_tensor=z_tf,
feed_dict={x_tf: x_np}, burn_iters=2,
min_iters=n_iter,
store_memory_usage=False, name='example')
For a code-snippet running on TensorFlow-GPU v2.3, refer to my answer https://stackoverflow.com/a/63591009/2478346
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With