Environment:Facebookresearch Audiocraft FAD TensorFlow Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Evaluation, Audio_Generation |
| Last Updated | 2026-02-13 23:00 GMT |
Overview
Separate TensorFlow 2.12.0 conda environment with CUDA 11.8 required for computing the Frechet Audio Distance (FAD) evaluation metric.
Description
The FAD metric in AudioCraft requires a separate Python environment with TensorFlow, because TensorFlow and PyTorch can conflict when sharing the same CUDA runtime. The FAD implementation calls an external Python process (configured via TF_PYTHON_EXE) that runs TensorFlow-based VGGish model inference to compute audio embeddings, then calculates the Frechet distance between real and generated audio distributions.
This environment requires the google-research repository with modifications for Python 3 and TensorFlow 2.X compatibility. The FAD computation is resource-intensive and runs as a subprocess, so the TensorFlow environment does not need to coexist with PyTorch in the same process.
Usage
Use this environment when running audio generation evaluation with the FAD metric during training validation or model comparison. This is only needed for the FrechetAudioDistanceMetric class; other metrics (KLD, CLAP, SI-SNR, ViSQOL) do not require TensorFlow.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux | TensorFlow GPU support requires Linux |
| Hardware | NVIDIA GPU | Required for VGGish model inference |
| CUDA | 11.8 | Must match TensorFlow 2.12.0 requirements |
| Python | 3.10 (conda) | Separate conda environment recommended |
Dependencies
Python Packages (in separate conda env)
tensorflow== 2.12.0tensorflow-hubapache-beamnumpyscipy
External Repositories
google-research— Clone from https://github.com/google-research/google-research with modifications for Python 3 and TF 2.X
Credentials
No credentials required. The VGGish model is downloaded from TensorFlow Hub automatically.
Quick Install
# Create separate conda environment for TensorFlow
conda create -n audiocraft_tf python=3.10
conda activate audiocraft_tf
# Install TensorFlow with CUDA support
pip install tensorflow==2.12.0 tensorflow-hub apache-beam numpy scipy
# Clone and modify google-research for FAD computation
git clone https://github.com/google-research/google-research.git
# Apply Python 3 / TF 2.X patches as described in audiocraft/metrics/fad.py
# Set environment variables in your AudioCraft runtime
export TF_PYTHON_EXE=/path/to/conda/envs/audiocraft_tf/bin/python
export TF_LIBRARY_PATH=/path/to/cuda-11.8/lib64
export TF_FORCE_GPU_ALLOW_GROWTH=true
Code Evidence
TensorFlow Python path configuration from audiocraft/metrics/fad.py:157-163:
self.python_path = os.environ.get('TF_PYTHON_EXE') or 'python'
logger.info("Python exe for TF is %s", self.python_path)
if 'TF_LIBRARY_PATH' in os.environ:
self.tf_env['LD_LIBRARY_PATH'] = os.environ['TF_LIBRARY_PATH']
if 'TF_FORCE_GPU_ALLOW_GROWTH' in os.environ:
self.tf_env['TF_FORCE_GPU_ALLOW_GROWTH'] = os.environ['TF_FORCE_GPU_ALLOW_GROWTH']
logger.info("Env for TF is %r", self.tf_env)
FAD setup documentation from audiocraft/metrics/fad.py:41-135 (docstring excerpt):
Setting up the FAD metric requires:
1. A separate conda environment with TensorFlow
2. The google-research repository with Python 3 / TF 2.X patches
3. Environment variables TF_PYTHON_EXE, TF_LIBRARY_PATH, TF_FORCE_GPU_ALLOW_GROWTH
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
FileNotFoundError: TF_PYTHON_EXE not found |
TensorFlow Python path not set | export TF_PYTHON_EXE=/path/to/tf/python
|
CUDA library not found |
TF_LIBRARY_PATH not set or wrong CUDA version | export TF_LIBRARY_PATH=/path/to/cuda-11.8/lib64
|
OOM during FAD computation |
TensorFlow allocating all GPU memory | export TF_FORCE_GPU_ALLOW_GROWTH=true
|
ModuleNotFoundError: frechet_audio_distance |
google-research not installed in TF env | Clone and install google-research in the TF conda env |
Compatibility Notes
- Separate process: FAD runs as a subprocess; TensorFlow and PyTorch never share the same process.
- GPU memory: Set
TF_FORCE_GPU_ALLOW_GROWTH=trueto prevent TensorFlow from pre-allocating all GPU memory, leaving room for PyTorch. - CUDA version: TensorFlow 2.12.0 requires CUDA 11.8; this may differ from the CUDA version used by PyTorch 2.1.0.