System Variables
Built-in environment variables available in every Valohai execution, including execution context and agent behavior controls.
Valohai automatically sets environment variables in every execution to provide context about your job and control agent behavior.
Execution Context Variables
These variables give you information about the current execution:
# Execution paths
VH_CONFIG_DIR=/valohai/config # Configuration files
VH_INPUTS_DIR=/valohai/inputs # Downloaded input files
VH_OUTPUTS_DIR=/valohai/outputs # Files to upload
VH_REPOSITORY_DIR=/valohai/repository # Git repository code (working directory)
# Execution identifiers
VH_JOB_ID=exec-016eb6ec-50cb-0031-3f48-d556e47b1c78 # Job UUID
VH_EXECUTION_ID=016eb6ec-50cb-0031-3f48-d556e47b1c78 # Execution ID
VH_PROJECT_ID=04a37c09-dbe1-4c01-b715-0a3223c50188 # Project ID
# Pipeline context (when applicable)
VH_TASK_ID=f9c97759-513e-44a1-9666-97cf198cde80 # Task ID
VH_PIPELINE_ID=f403603b-ad11-4cc4-a90d-3118f51c8dcd # Pipeline ID
VH_PIPELINE_NODE_ID=972834e2-23b5-429a-9f6d-80b8c4a75c8a # Pipeline node ID💡 Use these paths to read inputs and write outputs in your code instead of hardcoding locations.
Agent Behavior Controls
Set these variables to modify how the Valohai agent handles your execution:
Cache Control
VH_NO_DATA_CACHE
Ignore cached input data and re-download from source.
export VH_NO_DATA_CACHE=1 # true values: 1, yes, trueUseful when you've reused URLs but the underlying data has changed.
VH_NO_IMAGE_CACHE
Force Docker image re-pull, ignoring local cache.
export VH_NO_IMAGE_CACHE=trueSystem Cleanup
VH_CLEAN
Remove all Docker images and cached data before and after execution.
export VH_CLEAN=trueThis increases execution time but ensures a clean environment.
Resource Limits
VH_CPU_LIMIT
Limit CPU cores available to the job.
export VH_CPU_LIMIT=2 # Use 2 cores
export VH_CPU_LIMIT=0,2,4 # Use specific core indicesVH_MEMORY_LIMIT
Set memory usage limit.
export VH_MEMORY_LIMIT=500M # 500 megabytes
export VH_MEMORY_LIMIT=2G # 2 gigabytesVH_SHM_SIZE
Increase shared memory directory size.
export VH_SHM_SIZE=16G # 16 gigabytesUseful for applications that need large shared memory (e.g., PyTorch DataLoader).
Storage Behavior
VH_TMPFS
Control whether /tmp writes to memory or disk.
export VH_TMPFS=0 # false values: 0, no, falseBy default, /tmp is a memory filesystem. Setting this to false writes to disk instead, which is slower but avoids out-of-memory errors for large temporary files.
Hardware Acceleration
VH_TPU
Contains TPU endpoint(s) when TPUs are available.
import os
from tensorflow.python.distribute.cluster_resolver import TPUClusterResolver
# Use TPU if available
if "VH_TPU" in os.environ:
resolver = TPUClusterResolver(tpu=os.environ["VH_TPU"].split())
master = resolver.get_master()This variable is only set in private environments with Google Cloud TPU enabled.
Last updated
Was this helpful?
