Skip to content

Commit 39250b0

Browse files
Merge pull request #2561 from DougAnsonAustinTX/tensorflow_LP_review
tensorflow_LP_tech_review: updates to the tensorflow LP steps and code snippets
2 parents 6445683 + 40f7dd9 commit 39250b0

File tree

7 files changed

+51
-35
lines changed

7 files changed

+51
-35
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
title: Deploy TensorFlow on Google Cloud C4A (Arm-based Axion VMs)
33

4+
draft: true
5+
cascade:
6+
draft: true
7+
48
minutes_to_complete: 30
59

610
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.

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ This command checks if TensorFlow is installed correctly and prints its version
1616
```console
1717
python -c "import tensorflow as tf; print(tf.__version__)"
1818
```
19+
20+
You should see an output similar to:
21+
```output
22+
2.20.0
23+
```
24+
1925
### List Available Devices
2026
This command shows which hardware devices TensorFlow can use — like CPU or GPU. On most VMs, you’ll see only CPU listed.
2127

@@ -45,29 +51,28 @@ You should see an output similar to:
4551
Computation time: 0.008263111114501953 seconds
4652
```
4753
### Test Neural Network Execution
48-
Create a new file for testing a simple neural network:
54+
Create a new file for testing a simple neural network using your text editor ("edit" is shown as an example):
4955

5056
```console
51-
vi test_nn.py
57+
edit test_nn.py
5258
```
5359
This opens a new Python file where you’ll write a short TensorFlow test program.
5460
Paste the code below into the `test_nn.py` file:
5561

5662
```python
57-
import tensorflow as tf
58-
from tensorflow.keras.models import Sequential
59-
from tensorflow.keras.layers import Dense
63+
import keras
64+
from keras import layers
6065
import numpy as np
6166

6267
# Dummy data
6368
x = np.random.rand(1000, 20)
6469
y = np.random.rand(1000, 1)
6570

6671
# Define the model
67-
model = Sequential([
68-
Dense(64, activation='relu', input_shape=(20,)),
69-
Dense(1)
70-
])
72+
model = keras.Sequential()
73+
model.add(keras.Input(shape=(20,)))
74+
model.add(layers.Dense(64,activation="relu"))
75+
model.add(layers.Dense(1))
7176

7277
# Compile the model
7378
model.compile(optimizer='adam', loss='mse')

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ This guide benchmarks multiple TensorFlow models (ResNet50, MobileNetV2, and Inc
1313
`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 like **CPU**, **GPU**, or **TPU**.
1414

1515
### 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.
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:
1717

1818
```console
1919
source ~/tf-venv/bin/activate
2020
python -c "import tensorflow as tf; print(tf.__version__)"
2121
```
22-
### Install required packages
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.
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):
2424

2525
```console
2626
pip install tensorflow==2.20.0 numpy
2727
```
2828

2929
### Create a Python file named tf_cpu_benchmark.py:
30-
This step creates a Python script (`tf_cpu_benchmark.py`) that will run TensorFlow model benchmarking tests.
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:
3131

3232
```console
33-
vi tf_cpu_benchmark.py
33+
edit tf_cpu_benchmark.py
3434
```
3535

3636
Paste the following code:
@@ -104,16 +104,7 @@ InceptionV3 throughput: 35.67 images/sec
104104
- **Throughput (images/sec):** Indicates how many images the model can process per second. Higher throughput means better overall efficiency.
105105
- **Model Type:** Refers to the neural network architecture used for testing (e.g., ResNet50, MobileNetV2, InceptionV3). Each model has different computational complexity.
106106

107-
### Benchmark summary on x86_64
108-
To compare the benchmark results, the following results were collected by running the same benchmark on a `x86 - c4-standard-4` (4 vCPUs, 15 GB Memory) x86_64 VM in GCP, running SUSE:
109-
110-
| **Model** | **Average Inference Time per Batch (seconds)** | **Throughput (images/sec)** |
111-
|------------------|-----------------------------------------------:|-----------------------------:|
112-
| **ResNet50** | 1.3690 | 23.37 |
113-
| **MobileNetV2** | 0.4274 | 74.87 |
114-
| **InceptionV3** | 0.8799 | 36.37 |
115-
116-
### Benchmark summary on Arm64
107+
### Benchmark summary
117108
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
118109

119110
| **Model** | **Average Inference Time per Batch (seconds)** | **Throughput (images/sec)** |
@@ -122,10 +113,8 @@ Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm6
122113
| **MobileNetV2** | 0.2909 | 110.02 |
123114
| **InceptionV3** | 0.8971 | 35.67 |
124115

125-
### TensorFlow benchmarking comparison on Arm64 and x86_64
126-
127116
- **Arm64 VMs show strong performance** for lightweight CNNs like **MobileNetV2**, achieving over **110 images/sec**, indicating excellent optimization for CPU-based inference.
128117
- **Medium-depth models** like **InceptionV3** maintain a **balanced trade-off between accuracy and latency**, confirming consistent multi-core utilization on Arm.
129118
- **Heavier architectures** such as **ResNet50** show expected longer inference times but still deliver **stable throughput**, reflecting good floating-point efficiency.
130-
- Compared to **x86_64**, **Arm64 provides energy-efficient yet competitive performance**, particularly for **mobile, quantized, or edge AI workloads**.
119+
- **Arm64 provides energy-efficient yet competitive performance**, particularly for **mobile, quantized, or edge AI workloads**.
131120
- **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.
22.3 KB
Loading
12.5 KB
Loading

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ layout: learningpathall
1010
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.
1111

1212
### System Preparation
13-
Update the system and install Python3 and pip:
13+
Update the system and install Python3 and pip3 to a compatible version with tensorflow (please enter "y" when prompted to confirm the install):
1414

1515
```console
1616
sudo zypper refresh
17-
sudo zypper update -y
18-
sudo zypper install -y python3 python3-pip python3-venv
17+
sudo zypper install python311 python311-pip python311-venv
1918
```
2019
This ensures your system is up-to-date and installs Python with the essential tools required for TensorFlow setup.
2120

@@ -24,15 +23,22 @@ This ensures your system is up-to-date and installs Python with the essential to
2423
Confirm that Python and pip are correctly installed and identify their versions to ensure compatibility with TensorFlow requirements.
2524

2625
```console
27-
python3 --version
26+
python3.11 --version
2827
pip3 --version
2928
```
3029

30+
Your particular versions may vary a bit but typically your version output should resemble:
31+
32+
```output
33+
Python 3.11.10
34+
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
35+
```
36+
3137
### Create a Virtual Environment (Recommended)
3238
Set up an isolated Python environment (`tf-venv`) so that TensorFlow and its dependencies don’t interfere with system-wide packages or other projects.
3339

3440
```console
35-
python3 -m venv tf-venv
41+
python3.11 -m venv tf-venv
3642
source tf-venv/bin/activate
3743
```
3844
Create and activate an isolated Python environment to keep TensorFlow dependencies separate from system packages.
@@ -41,14 +47,14 @@ Create and activate an isolated Python environment to keep TensorFlow dependenci
4147
Upgrade pip to the latest version for smooth and reliable package installation.
4248

4349
```console
44-
pip install --upgrade pip
50+
pip3 install --upgrade pip
4551
```
4652

4753
### Install TensorFlow
4854
Install the latest stable TensorFlow version for Arm64:
4955

5056
```console
51-
pip install tensorflow==2.20.0
57+
pip3 install tensorflow==2.20.0
5258
```
5359

5460
{{% notice Note %}}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ To create a virtual machine based on the C4A instance type:
2626

2727
![Create a Google Axion C4A Arm virtual machine in the Google Cloud Console with c4a-standard-4 selected alt-text#center](images/gcp-vm.png "Creating a Google Axion C4A Arm virtual machine in Google Cloud Console")
2828

29-
- Under **OS and Storage**, select **Change**, then choose an Arm64-based OS image. For this Learning Path, use **SUSE Linux Enterprise Server**. Pick the preferred version for your Operating System. Ensure you select the **Arm image** variant. Click **Select**.
29+
30+
- Under **OS and Storage**, select **Change**, then choose an Arm64-based OS image. For this Learning Path, use **SUSE Linux Enterprise Server**.
31+
- If using use **SUSE Linux Enterprise Server**. Select "Pay As You Go" for the license type.
32+
- Once appropriately selected, please Click **Select**.
3033
- Under **Networking**, enable **Allow HTTP traffic**.
3134
- Click **Create** to launch the instance.
35+
- Once created, you should see a "SSH" option to the right in your list of VM instances. Click on this to launch a SSH shell into your VM instance:
36+
37+
![Invoke a SSH session via your browser alt-text#center](images/gcp-ssh.png "Invoke a SSH session into your running VM instance")
38+
39+
- A window from your browser should come up and you should now see a shell into your VM instance:
40+
41+
![Terminal Shell in your VM instance alt-text#center](images/gcp-shell.png "Terminal shell in your VM instance")
42+
43+
Next, let's install tensorflow!

0 commit comments

Comments
 (0)