4. Running an application

This section describes how to run a simple application, the MNIST example, using TensorFlow 2.

  1. Install example requirements

    You can now install the requirements that the model needs.

    $ cd $TUTORIALS_DIR/simple_applications/tensorflow2/mnist/
    $ pip install -r requirements.txt
    
  2. Run example

You run the code with the command:

$ python3 mnist.py

The example has no command line options.

If the code has run successfully, you should see an output similar to that in Listing 4.1.

Listing 4.1 Example of output for TensorFlow 2 application.
 2022-01-10 12:20:09.746730: I tensorflow/compiler/plugin/poplar/driver/poplar_platform.cc:44] Poplar version: 2.3.0 (d9e4130346) Poplar package: 88f485e763
 2022-01-10 12:20:11.195463: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
 2022-01-10 12:20:11.435997: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes)
 2022-01-10 12:20:11.436536: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 2245780000 Hz
 2022-01-10 12:20:12.922858: I tensorflow/compiler/plugin/poplar/driver/poplar_executor.cc:1714] Device /device:IPU:0 attached to IPU: 0
 2022-01-10 12:20:13.609918: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
 Epoch 1/4
 Compiling module a_inference_train_function_513__XlaMustCompile_true_config_proto___n_007_n_0...02_001_000__executor_type____.380:
 [##################################################] 100% Compilation Finished [Elapsed: 00:00:15.4]
 2022-01-10 12:20:29.517778: I tensorflow/compiler/jit/xla_compilation_cache.cc:347] Compiled cluster using XLA!  This line is logged at most once for the lifetime of the process.
 2000/2000 [==============================] - 18s 9ms/step - loss: 0.9729
 Epoch 2/4
 2000/2000 [==============================] - 1s 533us/step - loss: 0.3478
 Epoch 3/4
 2000/2000 [==============================] - 1s 610us/step - loss: 0.2876
 Epoch 4/4
 2000/2000 [==============================] - 1s 595us/step - loss: 0.2545

You have run an application that demonstrates how to use the IPU to train a simple 2-layer, fully-connected model on the MNIST dataset using TensorFlow 2.