/
DirectorySecurity AdvisoriesPricing
Sign in
Directory
tensorflow logo

tensorflow

Last changed

Request a free trial

Contact our team to test out this image for free. Please also indicate any other images you would like to evaluate.

Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for tensorflow

An Open Source Machine Learning Framework for Everyone

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/tensorflow:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

Compatibility Notes

Chainguard's TensorFlow CPU image is comparable to the CPU accelerated TensorFlow image with Jupyter (tensorflow/tensorflow:latest-jupyter) while the GPU image is comparable to the tensorflow/tensorflow:latest-gpu-jupyter image.

Chainguard's TensorFlow CPU images have tags ending with -cpu-jupyter and the GPU images have tags ending with -gpu-jupyter. Note that the latest and latest-dev tags for Chainguard's TensorFlow image point to the GPU variant.

Getting Started

CPU

In order to use Chainguard's TensorFlow CPU variant image, run the following command in your project's directory:

docker run --rm --name=tensorflow-cpu -p 8888:8888 -v $(pwd):/tf cgr.dev/ORGANIZATION/tensorflow:2.18.0-cpu

You will need to retrieve the token from the logs of the container to access the Jupyter UI. The logs will look like this:

docker logs tensorflow-cpu
# truncated
[I 2025-01-24 16:20:06.742 ServerApp] Jupyter Server 2.15.0 is running at:
[I 2025-01-24 16:20:06.742 ServerApp] http://b7834ef33453:8888/tree?token=403a50321893cf6c986b0a1f7fd5862ef4f25bb9989d5b87
[I 2025-01-24 16:20:06.742 ServerApp]     http://127.0.0.1:8888/tree?token=403a50321893cf6c986b0a1f7fd5862ef4f25bb9989d5b87
[I 2025-01-24 16:20:06.742 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

You can then access the Jupyter UI by visiting the given URL. For example: http://127.0.0.1:8888/tree?token=403a50321893cf6c986b0a1f7fd5862ef4f25bb9989d5b87.

To visit the JupyterLab UI, we can click on View followed by Open JupyterLab to access the JupyterLab UI.

GPU

In order to use Chainguard's TensorFlow CPU variant image, run the following command:

docker run --pull always --entrypoint bash -it --rm --gpus all  cgr.dev/ORGANIZATION/tensorflow:latest bash

Then, within the container, run the following commands:

nvidia-smi
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

You can also try running Python scripts. To illustrate, create a file named test.py and add the following content to it:

import tensorflow as tf
from tensorflow.keras import layers, models, datasets
import numpy as np

# Load a smaller subset of CIFAR-10
(x_train, y_train), (x_test, y_test) = datasets.cifar10.load_data()
x_train, y_train = x_train[:500], y_train[:500]
x_test, y_test = x_test[:100], y_test[:100]

# Normalize pixel values
x_train, x_test = x_train / 255.0, x_test / 255.0

# Convert to NumPy arrays and ensure correct dtype
x_train = np.array(x_train, dtype=np.float32)
x_test = np.array(x_test, dtype=np.float32)
y_train = np.array(y_train, dtype=np.int64).reshape(-1)
y_test = np.array(y_test, dtype=np.int64).reshape(-1)

# Build a very simple model
model = models.Sequential([
    layers.Flatten(input_shape=(32, 32, 3)),
    layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

# Train with a smaller batch size
print("Training the model on GPU...")
with tf.device('/GPU:0'):
    history = model.fit(x_train, y_train, epochs=1, batch_size=16)

# Evaluate
print("\nEvaluating the model on test data...")
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
print(f"\nTest accuracy: {test_acc * 100:.2f}%")

Then run the following command to execute the Python script:

python test.py

Documentation and Resources

What are Chainguard Containers?

Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.

All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.

The main features of Chainguard Containers include:

For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.

In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.

Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.

Need additional packages?

To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.

To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Libraries — contact us for access.

Trademarks

This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.

Licenses

Chainguard container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • Apache-2.0

  • BSD-2-Clause

  • BSD-3-Clause

  • CC-BY-4.0

  • GCC-exception-3.1

  • GPL-2.0

  • GPL-2.0-only

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Category
AI

Safe Source for Open Sourceâ„¢
Contact us
© 2025 Chainguard. All Rights Reserved.
Private PolicyTerms of Use

Product

Chainguard ContainersChainguard LibrariesChainguard VMsIntegrationsPricing