diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/_index.md b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/_index.md index bcdd9f3272..ba2b84cdbf 100644 --- a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/_index.md +++ b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/_index.md @@ -1,6 +1,10 @@ --- title: Deploy TensorFlow on Google Cloud C4A (Arm-based Axion VMs) +draft: true +cascade: + draft: true + minutes_to_complete: 30 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. diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/baseline.md b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/baseline.md index e4f27097d5..435ae94cb9 100644 --- a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/baseline.md +++ b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/baseline.md @@ -16,6 +16,12 @@ This command checks if TensorFlow is installed correctly and prints its version ```console python -c "import tensorflow as tf; print(tf.__version__)" ``` + +You should see an output similar to: +```output +2.20.0 +``` + ### List Available Devices This command shows which hardware devices TensorFlow can use — like CPU or GPU. On most VMs, you’ll see only CPU listed. @@ -45,18 +51,17 @@ You should see an output similar to: Computation time: 0.008263111114501953 seconds ``` ### Test Neural Network Execution -Create a new file for testing a simple neural network: +Create a new file for testing a simple neural network using your text editor ("edit" is shown as an example): ```console -vi test_nn.py +edit test_nn.py ``` This opens a new Python file where you’ll write a short TensorFlow test program. Paste the code below into the `test_nn.py` file: ```python -import tensorflow as tf -from tensorflow.keras.models import Sequential -from tensorflow.keras.layers import Dense +import keras +from keras import layers import numpy as np # Dummy data @@ -64,10 +69,10 @@ x = np.random.rand(1000, 20) y = np.random.rand(1000, 1) # Define the model -model = Sequential([ - Dense(64, activation='relu', input_shape=(20,)), - Dense(1) -]) +model = keras.Sequential() +model.add(keras.Input(shape=(20,))) +model.add(layers.Dense(64,activation="relu")) +model.add(layers.Dense(1)) # Compile the model model.compile(optimizer='adam', loss='mse') diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/benchmarking.md b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/benchmarking.md index c41bbf04ff..c6fd183a97 100644 --- a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/benchmarking.md +++ b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/benchmarking.md @@ -13,24 +13,24 @@ This guide benchmarks multiple TensorFlow models (ResNet50, MobileNetV2, and Inc `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**. ### Activate your TensorFlow virtual environment -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. +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: ```console source ~/tf-venv/bin/activate python -c "import tensorflow as tf; print(tf.__version__)" ``` -### Install required packages -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. +### Install required packages for the benchmark +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): ```console pip install tensorflow==2.20.0 numpy ``` ### Create a Python file named tf_cpu_benchmark.py: -This step creates a Python script (`tf_cpu_benchmark.py`) that will run TensorFlow model benchmarking tests. +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: ```console -vi tf_cpu_benchmark.py +edit tf_cpu_benchmark.py ``` Paste the following code: @@ -104,16 +104,7 @@ InceptionV3 throughput: 35.67 images/sec - **Throughput (images/sec):** Indicates how many images the model can process per second. Higher throughput means better overall efficiency. - **Model Type:** Refers to the neural network architecture used for testing (e.g., ResNet50, MobileNetV2, InceptionV3). Each model has different computational complexity. -### Benchmark summary on x86_64 -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: - -| **Model** | **Average Inference Time per Batch (seconds)** | **Throughput (images/sec)** | -|------------------|-----------------------------------------------:|-----------------------------:| -| **ResNet50** | 1.3690 | 23.37 | -| **MobileNetV2** | 0.4274 | 74.87 | -| **InceptionV3** | 0.8799 | 36.37 | - -### Benchmark summary on Arm64 +### Benchmark summary Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE): | **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 | **MobileNetV2** | 0.2909 | 110.02 | | **InceptionV3** | 0.8971 | 35.67 | -### TensorFlow benchmarking comparison on Arm64 and x86_64 - - **Arm64 VMs show strong performance** for lightweight CNNs like **MobileNetV2**, achieving over **110 images/sec**, indicating excellent optimization for CPU-based inference. - **Medium-depth models** like **InceptionV3** maintain a **balanced trade-off between accuracy and latency**, confirming consistent multi-core utilization on Arm. - **Heavier architectures** such as **ResNet50** show expected longer inference times but still deliver **stable throughput**, reflecting good floating-point efficiency. -- Compared to **x86_64**, **Arm64 provides energy-efficient yet competitive performance**, particularly for **mobile, quantized, or edge AI workloads**. +- **Arm64 provides energy-efficient yet competitive performance**, particularly for **mobile, quantized, or edge AI workloads**. - **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. diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-shell.png b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-shell.png new file mode 100644 index 0000000000..7e2fc3d1b5 Binary files /dev/null and b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-shell.png differ diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-ssh.png b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-ssh.png new file mode 100644 index 0000000000..597ccd7fea Binary files /dev/null and b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/images/gcp-ssh.png differ diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/installation.md b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/installation.md index 54ab1d1d4b..f2aeb180d8 100644 --- a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/installation.md +++ b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/installation.md @@ -10,12 +10,11 @@ layout: learningpathall 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. ### System Preparation -Update the system and install Python3 and pip: +Update the system and install Python3 and pip3 to a compatible version with tensorflow (please enter "y" when prompted to confirm the install): ```console sudo zypper refresh -sudo zypper update -y -sudo zypper install -y python3 python3-pip python3-venv +sudo zypper install python311 python311-pip python311-venv ``` This ensures your system is up-to-date and installs Python with the essential tools required for TensorFlow setup. @@ -24,15 +23,22 @@ This ensures your system is up-to-date and installs Python with the essential to Confirm that Python and pip are correctly installed and identify their versions to ensure compatibility with TensorFlow requirements. ```console -python3 --version +python3.11 --version pip3 --version ``` +Your particular versions may vary a bit but typically your version output should resemble: + +```output +Python 3.11.10 +pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11) +``` + ### Create a Virtual Environment (Recommended) Set up an isolated Python environment (`tf-venv`) so that TensorFlow and its dependencies don’t interfere with system-wide packages or other projects. ```console -python3 -m venv tf-venv +python3.11 -m venv tf-venv source tf-venv/bin/activate ``` 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 Upgrade pip to the latest version for smooth and reliable package installation. ```console -pip install --upgrade pip +pip3 install --upgrade pip ``` ### Install TensorFlow Install the latest stable TensorFlow version for Arm64: ```console -pip install tensorflow==2.20.0 +pip3 install tensorflow==2.20.0 ``` {{% notice Note %}} diff --git a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/instance.md b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/instance.md index 2b93bc950d..ea1d56e7f1 100644 --- a/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/instance.md +++ b/content/learning-paths/servers-and-cloud-computing/tensorflow-gcp/instance.md @@ -26,6 +26,18 @@ To create a virtual machine based on the C4A instance type: ![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") -- 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**. + +- Under **OS and Storage**, select **Change**, then choose an Arm64-based OS image. For this Learning Path, use **SUSE Linux Enterprise Server**. +- If using use **SUSE Linux Enterprise Server**. Select "Pay As You Go" for the license type. +- Once appropriately selected, please Click **Select**. - Under **Networking**, enable **Allow HTTP traffic**. - Click **Create** to launch the instance. +- 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: + +![Invoke a SSH session via your browser alt-text#center](images/gcp-ssh.png "Invoke a SSH session into your running VM instance") + +- A window from your browser should come up and you should now see a shell into your VM instance: + +![Terminal Shell in your VM instance alt-text#center](images/gcp-shell.png "Terminal shell in your VM instance") + +Next, let's install tensorflow! \ No newline at end of file