Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Gretelai Gretel synthetics TensorFlow GPU Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Deep_Learning, NLP
Last Updated 2026-02-14 19:00 GMT

Overview

Ubuntu 18.04+ environment with TensorFlow 2.12.1, CUDA 11.0, Python 3.9+, and optional TensorFlow Privacy 0.7.3 for differential privacy training.

Description

This environment provides the GPU-accelerated context required for the LSTM-based text generation and DataFrame batch synthesis workflows. It is built on TensorFlow 2.12.1 with Keras and includes the CUDA 11.0 toolkit, cuDNN 8.0, and TensorRT 7.1 for GPU acceleration. For differential privacy mode, TensorFlow Privacy 0.7.3 and TensorFlow Probability 0.19.0 are additionally required. The environment uses dynamic GPU memory allocation (allow_growth) rather than pre-allocating all available VRAM.

Usage

Use this environment for any LSTM Text Generation or DataFrame Batch Synthesis workflow. It is the mandatory prerequisite for running the TensorFlowConfig, Build_Model, Train_RNN, and Generate_Text implementations. Differential privacy mode requires TensorFlow >= 2.4.x.

System Requirements

Category Requirement Notes
OS Ubuntu 18.04+ LTS Setup script targets Ubuntu 18.04; Linux/macOS/Windows supported per classifiers
Python >= 3.9 Specified in setup.py `python_requires`
Hardware NVIDIA GPU (recommended) CPU fallback available with warning; GPU check via `tf.test.gpu_device_name()`
CUDA 11.0 Required for GPU acceleration per setup script
cuDNN 8.0.4.30 Must match CUDA 11.0 version
TensorRT 7.1.3 Optional, for inference optimization
NVIDIA Driver 450+ Per GPU setup script

Dependencies

System Packages

  • `cuda-11-0`
  • `libcudnn8` = 8.0.4.30-1+cuda11.0
  • `libnvinfer7` = 7.1.3-1+cuda11.0 (TensorRT)
  • `nvidia-driver-450`

Python Packages

  • `tensorflow` == 2.12.1
  • `tensorflow_estimator` == 2.12.0
  • `tensorflow_privacy` == 0.7.3 (for DP mode)
  • `tensorflow_probability` == 0.19.0 (for DP mode)
  • `protobuf` >= 4, <= 4.24.0
  • `dash` == 2.18.1
  • `ipykernel` == 6.29.5
  • `packaging` < 22.0
  • `sentencepiece` == 0.2.0 (for SentencePiece tokenizer)
  • `numpy` >= 1.18.0, < 1.24
  • `pandas` >= 1.1.0, < 2
  • `smart_open` >= 2.1.0, < 6.0
  • `tqdm` < 5.0

Credentials

No API keys or credentials are required for the TensorFlow LSTM pipeline. All data is loaded from local files.

Quick Install

# Base install
pip install gretel-synthetics

# With TensorFlow extras (includes GPU support, privacy, probability)
pip install gretel-synthetics[tensorflow]

# Or install TensorFlow dependencies individually
pip install tensorflow==2.12.1 tensorflow_estimator==2.12.0 tensorflow_privacy==0.7.3 tensorflow_probability==0.19.0 protobuf>=4,<=4.24.0

# For GPU setup on Ubuntu 18.04, use the provided script:
# bash setup-utils/setup-gretel-synthetics-tensorflow28-with-gpu.sh

Code Evidence

TensorFlow version check for differential privacy from `config.py:282-288`:

if self.dp:
    major, minor, _ = tf.__version__.split(".")
    if (int(major), int(minor)) < (2, 4):
        raise RuntimeError(
            "Running in differential privacy mode requires TensorFlow 2.4.x or greater. "
            "Please see the README for details"
        )

GPU detection and warning from `config.py:327-330`:

def gpu_check(self):
    device_name = tf.test.gpu_device_name()
    if not device_name.startswith("/device:GPU:"):
        logging.warning("***** GPU not found, CPU will be used instead! *****")

GPU memory configuration from `tensorflow/model.py:45-50`:

config = k.get_config()
# Don't pre-allocate memory, allocate as needed
config.gpu_options.allow_growth = True
k.set_session(tf.compat.v1.Session(config=config))

TensorFlow 2.11+ optimizer import path change from `tensorflow/default_model.py:9-12`:

if version.parse(tf.__version__) >= version.parse("2.11"):
    from tensorflow.keras.optimizers.legacy import RMSprop
else:
    from tensorflow.keras.optimizers import RMSprop

Keras LSTM code path patching for DP mode from `tensorflow/dp_model.py:51-65`:

try:
    recurrent_v2 = importlib.import_module("keras.layers.recurrent_v2")
    # NOTE: This patches the LSTMs to use the new Keras 2.4.x code paths
    use_new_code = getattr(recurrent_v2, "_use_new_code", None)
    if use_new_code is not None:
        logging.warning(
            "******* Patching TensorFlow to utilize new Keras code paths, see: %s",
            "https://github.com/tensorflow/tensorflow/issues/44917 *******",
        )
        recurrent_v2._use_new_code = lambda: True
except ModuleNotFoundError:
    pass

Common Errors

Error Message Cause Solution
`RuntimeError: Running in differential privacy mode requires TensorFlow 2.4.x or greater` TensorFlow version too old for DP mode Upgrade TensorFlow: `pip install tensorflow>=2.4`
`GPU not found, CPU will be used instead!` No NVIDIA GPU detected by TensorFlow Install CUDA toolkit and NVIDIA drivers, or accept CPU-only training (slower)
`ModuleNotFoundError: keras.layers.recurrent_v2` Keras internal module moved in newer versions Safe to ignore; the try/except block handles this gracefully
Optimizer import errors with TF 2.11+ RMSprop moved to `tensorflow.keras.optimizers.legacy` The code auto-detects TF version and imports from correct location

Compatibility Notes

  • TensorFlow 2.11+: Optimizers moved to `tensorflow.keras.optimizers.legacy`. The codebase handles this automatically via version detection.
  • Differential Privacy: Requires TensorFlow >= 2.4.x. DP micro-batch size is forced to 1 (only supported value).
  • Keras LSTM Patching: For DP mode, the code patches Keras to use newer code paths (TF issue #44917). This patch is safely skipped if the module is not found.
  • GPU Memory: The TF backend is configured with `allow_growth=True` to avoid pre-allocating all GPU memory.
  • Windows: Supported per setup.py classifiers but GPU setup script targets Ubuntu only.
  • macOS: Supported for CPU-only training.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment