Skip to main content

Overview

This template provides a production‑ready TensorFlow instance as a Monk runnable. You can:
  • Run it directly to get a managed TensorFlow environment for ML/DL development
  • Inherit it in your own ML applications to add training and inference capabilities
TensorFlow is an end-to-end open-source platform for machine learning. It has a comprehensive ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML-powered applications.

What this template manages

  • TensorFlow container (tensorflow/tensorflow image)
  • Jupyter notebook server (optional)
  • GPU acceleration support (with tensorflow-gpu)
  • Python environment with TensorFlow libraries
  • Model serving with TensorFlow Serving

Quick start (run directly)

  1. Load templates
monk load MANIFEST
  1. Run TensorFlow with defaults
monk run tensorflow/tensorflow
  1. Access Jupyter notebook (if enabled)
Navigate to http://localhost:8888 and use the token from logs.
  1. Customize configuration (recommended via inheritance)
Running directly uses the defaults defined in this template’s variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
  • Preferred: inherit and replace variables with secret("...") as shown below.
  • Alternative: fork/clone and edit the variables in tensorflow/tensorflow.yml, then monk load MANIFEST and run.

Configuration

Key variables you can customize in this template:
variables:
  tensorflow-image-tag: "latest"      # container image tag
  jupyter-enabled: "true"             # enable Jupyter notebook
  jupyter-port: "8888"                # Jupyter port
  gpu-support: "false"                # use tensorflow-gpu image
  python-version: "3.9"               # Python version
Data is persisted under ${monk-volume-path}/tensorflow on the host. Custom configuration can be mounted to the container as needed. Inherit the TensorFlow runnable in your application and declare a connection. Example:
namespace: myapp
ml-trainer:
  defines: runnable
  inherits: tensorflow/tensorflow
  variables:
    gpu-support: "true"
    tensorflow-image-tag: "latest-gpu"
  files:
    training-script:
      container: tensorflow
      path: /workspace/train.py
      contents: |
        import tensorflow as tf
        # Your training code here
api:
  defines: runnable
  containers:
    api:
      image: myorg/api
  connections:
    ml-service:
      runnable: ml-trainer
      service: tensorflow
  variables:
    ml-host:
      value: <- connection-hostname("ml-service")
Then run your app group:
monk run myapp/api

Ports and connectivity

  • Service: tensorflow (configurable ports)
  • Jupyter: TCP port 8888 (if enabled)
  • TensorFlow Serving: TCP port 8501 (REST API)
  • gRPC: TCP port 8500 (for serving)
  • From other runnables in the same process group, use connection-hostname("\<connection-name>") to resolve the TensorFlow host.

Persistence and configuration

  • Notebooks path: ${monk-volume-path}/tensorflow/notebooks
  • Models path: ${monk-volume-path}/tensorflow/models
  • Data path: ${monk-volume-path}/tensorflow/data
  • You can mount additional configuration files and datasets to the container as needed.

Features

  • Complete ML/DL framework
  • Keras high-level API
  • Eager execution for intuitive development
  • GPU and TPU acceleration
  • TensorFlow Serving for production inference
  • TensorFlow Lite for mobile and embedded
  • TensorFlow.js for browser-based ML
  • Distributed training support
  • Model optimization and quantization

Use cases

TensorFlow excels at:
  • Image classification and object detection
  • Natural language processing
  • Time series forecasting
  • Recommendation systems
  • Reinforcement learning
  • Generative models (GANs, VAEs)
  • Any deep learning task

GPU Support

For GPU acceleration:
variables:
  tensorflow-image-tag: "latest-gpu"
  gpu-support: "true"
Requirements:
  • NVIDIA GPU with CUDA support
  • NVIDIA drivers installed
  • Docker GPU runtime configured

Model Serving

TensorFlow Serving provides production-ready model inference:
  • REST and gRPC APIs
  • Model versioning
  • Batching for efficiency
  • Hot-reloading of models
  • See other ML/AI templates in this repository for complementary services.
  • Combine with monitoring tools for observability of training jobs and model serving.

Troubleshooting

  • For GPU support, verify CUDA compatibility with TensorFlow version and ensure NVIDIA drivers are properly installed.
  • Ensure sufficient RAM/VRAM for your models. Monitor GPU memory usage to avoid OOM errors.
  • Ensure host volumes are writable by the container user.
  • Check logs:
monk logs -l 500 -f tensorflow/tensorflow
  • Check Jupyter logs for token:
monk logs -l 100 tensorflow/tensorflow | grep token
  • Verify TensorFlow installation inside the container:
import tensorflow as tf
print(tf.__version__)
print(tf.config.list_physical_devices('GPU'))