Run TensorFlow Convolutional Neural Network (TF CNN) benchmarks in CPU

Sign up for FREE 1 month of Kindle and read all our books for free.

Get FREE domain for 1st year and build your brand new site

Reading time: 15 minutes

In this article, we will walk you through running the official benchmark of TensorFlow for Convolutional Neural Network on your machine (CPU). The process is simple and we have divided it into three simple steps.

Install TensorFlow

To install the basic version of TensorFlow, use the following command:

pip install tensorflow

To install and build TensorFlow from source code so that you can enable custom optimizations, then following this guide:

Build and install TensorFlow from source with MKL DNN support and AVX enabled

Get the benchmarking code

To get the benchmarking code, use the following command:

git clone

Once done, move to the correct location using the following command:

cd benchmarks/scripts/tf_cnn_benchmarks/

Run the TF CNN benchmarks

To see the help option, use the following command:

python --help

To run the benchmark for VGG19 model for data format NHWC, use the following command:

python --model=vgg19 --data_format=NHWC

To undergo only forward run with batch size 32 and number of batches 100, use the following command:

python --model=vgg19 --data_format=NHWC 
--forward_only --batch_size=32 --nun_batches=100

If you have install MKL enabled TensorFlow, use the following command:

python --model=vgg19 --data_format=NHWC 
--forward_only --batch_size=32 --nun_batches=100 --mkl=True 
--num_inter_threads=1 --num_intra_threads=2

Various models are available in the TF CNN benchmark such as:

  • googlenet
  • resnet50
  • vgg19
  • inception3