TensorFlow CPU (AWS ARM64 optimized)

2.15.1 · active · verified Thu Apr 16

TensorFlow is an open-source machine learning framework. The `tensorflow-cpu-aws` package is a distribution of TensorFlow specifically optimized for CPU (ARM64/Aarch64) architectures, built and maintained by AWS. It is typically installed automatically as a dependency when the generic `tensorflow` package is installed on an ARM-based system. The current version is 2.15.1, and its release cadence generally aligns with the main TensorFlow releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import TensorFlow, verify its version and device availability (which should show only CPU devices for this package), and perform a basic tensor operation. It also includes a simple Keras model definition and a forward pass, illustrating typical usage for a CPU-only environment.

import tensorflow as tf

# Verify TensorFlow installation and basic operation
print("TensorFlow version:", tf.__version__)
print("Is GPU available:", tf.config.list_physical_devices('GPU'))

# Create a simple constant tensor
hello = tf.constant('Hello from TensorFlow-CPU-AWS!')
print(hello.numpy().decode('utf-8'))

# Perform a basic operation
a = tf.constant(10)
b = tf.constant(32)
print("a + b =", tf.add(a, b).numpy())

# Example with Keras (MNIST dataset)
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10)
])

predictions = model(x_train[:1]).numpy()
print("Sample predictions shape:", predictions.shape)

view raw JSON →