Skip to main content

Environment variables

This page documents all environment variables you can use to configure MAX behavior. These variables control server settings, logging, telemetry, performance, and integrations.

How to set environment variables

You can set environment variables in several ways:

# Export in your shell
export MAX_SERVE_HOST="0.0.0.0"

# Pass to Docker container
docker run --env "MAX_SERVE_HOST=0.0.0.0" modular/max-nvidia-full:latest ...

# Use a .env file in your working directory
echo "MAX_SERVE_HOST=0.0.0.0" >> .env

Configuration precedence

When the same setting is configured in multiple places, the following precedence applies (highest to lowest):

  1. CLI flags or direct Python initialization: For example, --port 8080 or Settings(MAX_SERVE_PORT=8080). CLI flags are passed directly to the Settings constructor, so they have the same precedence as direct Python initialization.
  2. Environment variables: export MAX_SERVE_HOST="0.0.0.0"
  3. .env file values: Values defined in a .env file in your working directory

Serving

These variables configure the MAX model serving behavior.

For more information on serving a model with MAX, explore the text to text and image to text guides.

VariableDescriptionValuesDefault
MAX_SERVE_HOSTHostname for the MAX serverString0.0.0.0
MAX_SERVE_PORTPort for serving MAXInteger8000
MAX_SERVE_METRICS_ENDPOINT_PORTPort for the Prometheus metrics endpointInteger8001
MAX_SERVE_ALLOWED_IMAGE_ROOTSAllowed root directories for file:// URI accessComma-separated pathsEmpty
MAX_SERVE_MAX_LOCAL_IMAGE_BYTESMaximum size in bytes for local image filesInteger20971520 (20 MiB)

Logging

These variables control logging behavior and verbosity.

You can read more about logs when using the MAX container.

VariableDescriptionValuesDefault
MAX_SERVE_LOGS_CONSOLE_LEVELConsole log verbosity levelCRITICAL, ERROR, WARNING, INFO, DEBUGINFO
MODULAR_STRUCTURED_LOGGINGEnable JSON-formatted structured logging for deployed services0, 11
MAX_SERVE_LOGS_FILE_PATHPath to write log filesFile pathNone
MAX_SERVE_LOG_PREFIXPrefix to prepend to all log messagesStringNone

Telemetry and metrics

These variables control telemetry collection and metrics reporting.

For more information, read about MAX container telemetry.

VariableDescriptionValuesDefault
MAX_SERVE_DISABLE_TELEMETRYDisable remote telemetry collection0, 10
MODULAR_USER_IDUser identifier for telemetry (e.g., your company name)StringNone
MAX_SERVE_DEPLOYMENT_IDDeployment identifier for telemetry (e.g., your application name)StringNone
MAX_SERVE_METRIC_LEVELLevel of detail in metrics emittedNONE, BASIC, DETAILEDBASIC

Debugging and profiling

These variables enable debugging and profiling features.

For more information about profiling, see GPU profiling with Nsight Systems.

VariableDescriptionValuesDefault
MODULAR_MAX_DEBUGEnable stack traces for MAX graph compilation errorsTrue, FalseFalse
MODULAR_ENABLE_PROFILINGEnable runtime profiling and tracingoff, on, detailedoff

Performance and caching

The following variables configure caching and memory behavior.

VariableDescriptionValuesDefault
MODULAR_MAX_CACHE_DIRDirectory to save MAX model cache for reusePathSee note below
MODULAR_CACHE_DIRConfigure cache directory for all Modular filesystemsPathSee note below
MODULAR_MAX_SHM_WATERMARKPercentage of /dev/shm to allocate for shared memory. Set to 0.0 to disable shared memory.Float (0.0–1.0)0.9

Hugging Face

Configure your Hugging Face integration with the following environment variable:

VariableDescriptionValuesDefault
HF_TOKENHugging Face authentication token for accessing gated modelsStringNone