Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run tensorflow benchmark tool on GPU?

How to run tensorflow benchmark tool on GPU? https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/benchmark

like image 705
Misaya.Z Avatar asked Jun 07 '26 20:06

Misaya.Z


1 Answers

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

like image 120
CATALUNA84 Avatar answered Jun 10 '26 09:06

CATALUNA84