Skip to content

Commit 4e2afe5

Browse files
Merge pull request #2564 from jasonrandrews/review
review TensorFlow on Axion Learning Path
2 parents 39250b0 + 09e9fff commit 4e2afe5

File tree

4 files changed

+90
-97
lines changed

4 files changed

+90
-97
lines changed

content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cascade:
77

88
minutes_to_complete: 30
99

10-
who_is_this_for: This learning path is intended for software developers deploying and optimizing TensorFlow workloads on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
10+
who_is_this_for: This is an introductory topic for software developers deploying and optimizing TensorFlow workloads on Arm64 Linux environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
1111

1212
learning_objectives:
1313
- Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors)
@@ -32,7 +32,7 @@ armips:
3232
tools_software_languages:
3333
- TensorFlow
3434
- Python
35-
- tf.keras
35+
- Keras
3636

3737
operatingsystems:
3838
- Linux
Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,53 @@
11
---
2-
title: TensorFlow Baseline Testing on Google Axion C4A Arm Virtual Machine
2+
title: Test TensorFlow baseline performance on Google Axion C4A Arm virtual machines
33
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## TensorFlow Baseline Testing on GCP SUSE VMs
10-
This section helps you check if TensorFlow is properly installed and working on your **Google Axion C4A Arm64 VM**. You will run small tests to confirm that your CPU can perform TensorFlow operations correctly.
9+
## Perform baseline testing
1110

11+
This section helps you verify that TensorFlow is properly installed and working on your Google Axion C4A VM. You'll run tests to confirm that your CPU can perform TensorFlow operations correctly.
1212

13-
### Verify Installation
14-
This command checks if TensorFlow is installed correctly and prints its version number.
13+
### Check available devices
1514

16-
```console
17-
python -c "import tensorflow as tf; print(tf.__version__)"
18-
```
19-
20-
You should see an output similar to:
21-
```output
22-
2.20.0
23-
```
24-
25-
### List Available Devices
26-
This command shows which hardware devices TensorFlow can use — like CPU or GPU. On most VMs, you’ll see only CPU listed.
15+
This command shows which hardware devices TensorFlow can use, such as CPU or GPU. On most VMs, you'll see only CPU listed:
2716

2817
```console
2918
python -c "import tensorflow as tf; print(tf.config.list_physical_devices())"
3019
```
3120

32-
You should see an output similar to:
21+
The output is similar to:
22+
3323
```output
3424
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
3525
```
3626

37-
### Run a Simple Computation
38-
This test multiplies two large matrices to check that TensorFlow computations work correctly on your CPU and measures how long it takes.
27+
### Run a computation test
3928

40-
```python
29+
This test multiplies two large matrices to verify that TensorFlow computations work correctly on your CPU and measures execution time:
30+
31+
```console
4132
python -c "import tensorflow as tf; import time;
4233
a = tf.random.uniform((1000,1000)); b = tf.random.uniform((1000,1000));
4334
start = time.time(); c = tf.matmul(a,b); end = time.time();
4435
print('Computation time:', end - start, 'seconds')"
4536
```
46-
- This checks **CPU speed** and the correctness of basic operations.
47-
- Note the **computation time** as your baseline.
4837

49-
You should see an output similar to:
38+
This checks CPU performance for basic operations and provides a baseline measurement.
39+
40+
The output is similar to:
41+
5042
```output
5143
Computation time: 0.008263111114501953 seconds
5244
```
53-
### Test Neural Network Execution
54-
Create a new file for testing a simple neural network using your text editor ("edit" is shown as an example):
5545

56-
```console
57-
edit test_nn.py
58-
```
59-
This opens a new Python file where you’ll write a short TensorFlow test program.
60-
Paste the code below into the `test_nn.py` file:
46+
### Test neural network execution
47+
48+
Use a text editor to create a new file named `test_nn.py` for testing a simple neural network.
49+
50+
Add the following code to create and train a basic neural network using random data:
6151

6252
```python
6353
import keras
@@ -80,21 +70,21 @@ model.compile(optimizer='adam', loss='mse')
8070
# Train for 1 epoch
8171
model.fit(x, y, epochs=1, batch_size=32)
8272
```
83-
This script creates and trains a simple neural network using random data — just to make sure TensorFlow’s deep learning functions work properly.
8473

85-
**Run the Script**
74+
This script creates a simple neural network to verify that TensorFlow's deep learning functions work properly on the Arm platform.
75+
76+
### Run the neural network test
8677

87-
Execute the script with Python:
78+
Execute the script:
8879

8980
```console
9081
python test_nn.py
9182
```
9283

93-
**Output**
84+
TensorFlow displays training progress similar to:
9485

95-
TensorFlow will print training progress, like:
9686
```output
9787
32/32 ━━━━━━━━━━━━━━━━━━━━ 0s 1ms/step - loss: 0.1024
9888
```
9989

100-
This confirms that TensorFlow is working properly on your Arm64 VM.
90+
This confirms that TensorFlow is working correctly on your Arm VM and can perform both basic computations and neural network training.
Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
---
2-
title: TensorFlow Benchmarking
2+
title: Benchmark TensorFlow model performance using tf.keras
33
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9+
## Benchmark TensorFlow models
910

10-
## TensorFlow Benchmarking with tf.keras
11-
This guide benchmarks multiple TensorFlow models (ResNet50, MobileNetV2, and InceptionV3) using dummy input data. It measures average inference time and throughput for each model running on the CPU.
11+
This section benchmarks multiple TensorFlow models (ResNet50, MobileNetV2, and InceptionV3) using dummy input data. You'll measure average inference time and throughput for each model running on the CPU.
1212

13-
`tf.keras` is **TensorFlows high-level API** for building, training, and benchmarking deep learning models. It provides access to **predefined architectures** such as **ResNet**, **MobileNet**, and **Inception**, making it easy to evaluate model performance on different hardware setups like **CPU**, **GPU**, or **TPU**.
13+
tf.keras is TensorFlow's high-level API for building, training, and benchmarking deep learning models. It provides access to predefined architectures such as ResNet, MobileNet, and Inception, making it easy to evaluate model performance on different hardware setups.
1414

15-
### Activate your TensorFlow virtual environment
16-
This step enables your isolated Python environment (`tf-venv`) where TensorFlow is installed. It ensures that all TensorFlow-related packages and dependencies run in a clean, controlled setup without affecting system-wide Python installations:
15+
### Activate your virtual environment
16+
17+
Enable your isolated Python environment where TensorFlow is installed:
1718

1819
```console
1920
source ~/tf-venv/bin/activate
2021
python -c "import tensorflow as tf; print(tf.__version__)"
2122
```
22-
### Install required packages for the benchmark
23-
Here, you install TensorFlow 2.20.0 and NumPy, the core libraries needed for model creation, computation, and benchmarking. NumPy supports efficient numerical operations, while TensorFlow handles deep learning workloads (these packages are likely already installed FYI):
23+
24+
This ensures that all TensorFlow-related packages run in a clean, controlled setup without affecting system-wide Python installations.
25+
26+
### Install required packages
27+
28+
Install TensorFlow and NumPy for model creation and benchmarking:
2429

2530
```console
2631
pip install tensorflow==2.20.0 numpy
2732
```
2833

29-
### Create a Python file named tf_cpu_benchmark.py:
30-
This step creates a Python script (`tf_cpu_benchmark.py`) using your text editor (showing "edit" as an example below) that will run TensorFlow model benchmarking tests:
34+
These packages are likely already installed from the previous installation steps. NumPy supports efficient numerical operations, while TensorFlow handles deep learning workloads.
3135

32-
```console
33-
edit tf_cpu_benchmark.py
34-
```
36+
### Create the benchmark script
37+
38+
Use an editor to create a Python script named `tf_cpu_benchmark.py` that will run TensorFlow model benchmarking tests.
39+
40+
Add the following code to benchmark three different model architectures:
3541

36-
Paste the following code:
3742
```python
3843
import tensorflow as tf
3944
import time
@@ -66,24 +71,19 @@ for name, constructor in models.items():
6671
print(f"{name} average inference time per batch: {avg_time:.4f} seconds")
6772
print(f"{name} throughput: {throughput:.2f} images/sec")
6873
```
69-
- **Import libraries** – Loads TensorFlow and `time` for model creation and timing.
70-
- **Define models** – Lists three TensorFlow Keras models: **ResNet50**, **MobileNetV2**, and **InceptionV3**.
71-
- **Set parameters** – Configures `batch_size = 32` and runs each model **50 times** for stable benchmarking.
72-
- **Create model instances** – Initializes each model **without pretrained weights** for fair CPU testing.
73-
- **Generate dummy input** – Creates random data shaped like real images **(224×224×3)** for inference.
74-
- **Warm-up phase** – Runs one inference to **stabilize model graph and memory usage**.
75-
- **Benchmark loop** – Measures total time for 50 runs and calculates **average inference time per batch**.
76-
- **Compute throughput** – Calculates how many **images per second** the model can process.
77-
- **Print results** – Displays **average inference time and throughput** for each model.
74+
75+
This script creates model instances without pretrained weights for fair CPU testing, generates random image data for inference, includes a warm-up phase to stabilize model performance, and measures inference time over 50 runs to calculate average performance and throughput.
7876

7977
### Run the benchmark
78+
8079
Execute the benchmarking script:
8180

8281
```console
8382
python tf_cpu_benchmark.py
8483
```
8584

86-
You should see an output similar to:
85+
The output is similar to:
86+
8787
```output
8888
Benchmarking ResNet50...
8989
ResNet50 average inference time per batch: 1.2051 seconds
@@ -98,23 +98,18 @@ InceptionV3 average inference time per batch: 0.8971 seconds
9898
InceptionV3 throughput: 35.67 images/sec
9999
```
100100

101-
### Benchmark Metrics Explanation
101+
### Understand the results
102+
103+
The benchmark provides key performance metrics. Average inference time per batch measures how long it takes to process one batch of input data, with lower values indicating faster performance. Throughput shows how many images the model can process per second, with higher values indicating better efficiency.
102104

103-
- **Average Inference Time per Batch (seconds):** Measures how long it takes to process one batch of input data. Lower values indicate faster inference performance.
104-
- **Throughput (images/sec):** Indicates how many images the model can process per second. Higher throughput means better overall efficiency.
105-
- **Model Type:** Refers to the neural network architecture used for testing (e.g., ResNet50, MobileNetV2, InceptionV3). Each model has different computational complexity.
105+
### Performance summary
106106

107-
### Benchmark summary
108-
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
107+
The following table shows results from running the benchmark on a `c4a-standard-4` (4 vCPU, 16 GB memory) aarch64 VM in GCP using SUSE:
109108

110-
| **Model** | **Average Inference Time per Batch (seconds)** | **Throughput (images/sec)** |
111-
|------------------|-----------------------------------------------:|-----------------------------:|
112-
| **ResNet50** | 1.2051 | 26.55 |
113-
| **MobileNetV2** | 0.2909 | 110.02 |
114-
| **InceptionV3** | 0.8971 | 35.67 |
109+
| Model | Average Inference Time per Batch (seconds) | Throughput (images/sec) |
110+
|-------------|-------------------------------------------:|------------------------:|
111+
| ResNet50 | 1.2051 | 26.55 |
112+
| MobileNetV2 | 0.2909 | 110.02 |
113+
| InceptionV3 | 0.8971 | 35.67 |
115114

116-
- **Arm64 VMs show strong performance** for lightweight CNNs like **MobileNetV2**, achieving over **110 images/sec**, indicating excellent optimization for CPU-based inference.
117-
- **Medium-depth models** like **InceptionV3** maintain a **balanced trade-off between accuracy and latency**, confirming consistent multi-core utilization on Arm.
118-
- **Heavier architectures** such as **ResNet50** show expected longer inference times but still deliver **stable throughput**, reflecting good floating-point efficiency.
119-
- **Arm64 provides energy-efficient yet competitive performance**, particularly for **mobile, quantized, or edge AI workloads**.
120-
- **Overall**, Arm64 demonstrates that **TensorFlow workloads can run efficiently on cloud-native ARM processors**, making them a **cost-effective and power-efficient alternative** for AI inference and model prototyping.
115+
The results demonstrate strong performance for lightweight CNNs like MobileNetV2, achieving over 110 images/sec on the aarch64 platform. Medium-depth models like InceptionV3 maintain balanced performance between accuracy and latency. Heavier architectures such as ResNet50 show longer inference times but deliver stable throughput, confirming that TensorFlow workloads run efficiently on Arm processors and provide a cost-effective alternative for AI inference tasks.

content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/installation.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,51 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## TensorFlow Installation on GCP SUSE VM
10-
TensorFlow is a widely used **open-source machine learning library** developed by Google, designed for building and deploying ML models efficiently. On Arm64 SUSE VMs, TensorFlow can run on CPU natively, or on GPU if available.
9+
## Install TensorFlow on Google Axion C4A
1110

12-
### System Preparation
13-
Update the system and install Python3 and pip3 to a compatible version with tensorflow (please enter "y" when prompted to confirm the install):
11+
TensorFlow is an open-source machine learning library developed by Google for building and deploying ML models efficiently. On aarch64 SUSE VMs, TensorFlow runs natively on CPU or GPU if available.
12+
13+
### Update your system
14+
15+
Update the system and install Python 3.11 with pip and virtual environment support:
1416

1517
```console
1618
sudo zypper refresh
1719
sudo zypper install python311 python311-pip python311-venv
1820
```
19-
This ensures your system is up-to-date and installs Python with the essential tools required for TensorFlow setup.
2021

21-
**Verify Python version:**
22+
Enter "y" when prompted to confirm the installation. This ensures your system has the essential tools required for TensorFlow setup.
23+
24+
### Verify Python installation
2225

23-
Confirm that Python and pip are correctly installed and identify their versions to ensure compatibility with TensorFlow requirements.
26+
Confirm that Python and pip are correctly installed:
2427

2528
```console
2629
python3.11 --version
2730
pip3 --version
2831
```
2932

30-
Your particular versions may vary a bit but typically your version output should resemble:
33+
The output is similar to:
3134

3235
```output
3336
Python 3.11.10
3437
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
3538
```
3639

37-
### Create a Virtual Environment (Recommended)
38-
Set up an isolated Python environment (`tf-venv`) so that TensorFlow and its dependencies don’t interfere with system-wide packages or other projects.
40+
### Create a virtual environment
41+
42+
Set up an isolated Python environment to keep TensorFlow dependencies separate from system packages:
3943

4044
```console
4145
python3.11 -m venv tf-venv
4246
source tf-venv/bin/activate
4347
```
44-
Create and activate an isolated Python environment to keep TensorFlow dependencies separate from system packages.
48+
49+
This creates and activates a virtual environment named `tf-venv` that prevents package conflicts.
4550

4651
### Upgrade pip
47-
Upgrade pip to the latest version for smooth and reliable package installation.
52+
53+
Upgrade pip to the latest version for reliable package installation:
4854

4955
```console
5056
pip3 install --upgrade pip
@@ -58,21 +64,23 @@ pip3 install tensorflow==2.20.0
5864
```
5965

6066
{{% notice Note %}}
61-
TensorFlow 2.18.0 introduced compatibility with NumPy 2.0, incorporating its updated type promotion rules and improved numerical precision.
62-
You can view [this release note](https://blog.tensorflow.org/2024/10/whats-new-in-tensorflow-218.html)
67+
TensorFlow 2.18.0 introduced compatibility with NumPy 2.0, incorporating its updated type promotion rules and improved numerical precision. You can review [What's new in TensorFlow 2.18](https://blog.tensorflow.org/2024/10/whats-new-in-tensorflow-218.html) for more information.
6368

64-
The [Arm Ecosystem Dashboard](https://developer.arm.com/ecosystem-dashboard/) recommends Tensorflow version 2.18.0, the minimum recommended on the Arm platforms.
69+
The [Arm Ecosystem Dashboard](https://developer.arm.com/ecosystem-dashboard/) recommends TensorFlow version 2.18.0 as the minimum recommended version on Arm platforms.
6570
{{% /notice %}}
6671

67-
### Verify installation:
68-
Run a quick Python command to check that TensorFlow was installed successfully and print the installed version number for confirmation.
72+
### Verify the installation
73+
74+
Check that TensorFlow installed successfully and display the version:
6975

7076
```console
7177
python -c "import tensorflow as tf; print(tf.__version__)"
7278
```
7379

74-
You should see an output similar to:
80+
The output is similar to:
81+
7582
```output
7683
2.20.0
7784
```
78-
TensorFlow installation is complete. You can now go ahead with the baseline testing of TensorFlow in the next section.
85+
86+
Your TensorFlow installation is now complete and ready for use.

0 commit comments

Comments
 (0)