# Environment for running gradio in an air-gapped RHEL 9.6 environment. # source /path/to/gradio-template/gradio-offline.env # # Without these, gradio and huggingface_hub attempt outbound calls on startup # (analytics, version check, hub metadata). On an isolated host those calls do # not fail fast -- they hang until the socket times out, so every launch and # several component calls stall for seconds. # -- gradio telemetry / version check ---------------------------------------- export GRADIO_ANALYTICS_ENABLED=False export DO_NOT_TRACK=1 # -- huggingface_hub: never touch the network -------------------------------- export HF_HUB_OFFLINE=1 export HF_HUB_DISABLE_TELEMETRY=1 export HF_HUB_DISABLE_IMPLICIT_TOKEN=1 # Keep the hub cache on a local, writable path (default is ~/.cache/huggingface). export HF_HOME="${HF_HOME:-$HOME/.cache/huggingface}" # -- never try to open a public share tunnel --------------------------------- # share=True downloads a frcp binary from gradio's CDN; it cannot work offline. export GRADIO_SHARE=False # -- bind address / port ----------------------------------------------------- # 127.0.0.1 is the safe default. Set 0.0.0.0 only when the app must be reached # from other hosts, and open the port first: # firewall-cmd --add-port=7860/tcp --permanent && firewall-cmd --reload export GRADIO_SERVER_NAME=127.0.0.1 export GRADIO_SERVER_PORT=7860 # -- matplotlib: headless, and a writable config dir ------------------------- # Needed for gr.Plot on a server with no display, and for service accounts # whose HOME is not writable. export MPLBACKEND=Agg export MPLCONFIGDIR="${MPLCONFIGDIR:-${TMPDIR:-/tmp}/matplotlib-$(id -u)}" # -- gradio scratch space ---------------------------------------------------- # Uploads and generated files land here. Put it on a volume with room and, if # SELinux confines the app, a context the process may write. export GRADIO_TEMP_DIR="${GRADIO_TEMP_DIR:-${TMPDIR:-/tmp}/gradio-$(id -u)}" mkdir -p "$MPLCONFIGDIR" "$GRADIO_TEMP_DIR" 2>/dev/null || true