Running Headless Houdini in Docker
July 5, 2025 · 7 min read

These are some notes I put together when revisiting an old side-project I threw together a few years ago: containerizing and wrapping Houdini as a web-app.
The goal was to allow users to upload their .hip files, make quick edits to the node graph in the browser, and preview their scene in three.js (or in BabylonJS) from anywhere.
The stack looked roughly like:
- Flask: The web server, running under Gunicorn.
- Celery: Background workers that handled the actual exporting and rendering of Houdini geometry.
- Redis: Handles jobs and progress updates between Flask/Celery.
Since both Flask and Celery import hou directly, their Docker containers both needed a headless install of Houdini. I've attempted to document the trickier bits of that process below.
Building the Houdini Base Image
You'll need a SideFX client ID and secret for the download, generated here. The same credentials get reused for licensing later on.
The Dockerfile is split into three stages:
- Download: Download the target Houdini build via SideFX API.
- Houdini offers a python API for handling downloading builds
- Install: Installs the system packages not bundled with Houdini, then runs the installer.
- (Headless) Houdini requires: libgl1 + libatomic1 (more on this later.)
- Run the
houdini.installscript with the license server option disabled.
- Final: Copies the installed filesystem into a fresh image, leaving the installer behind.
- Adds Houdini's bundled tools to
PATH - Also adds its
python3.Xlibsfolder (home of thehou) toPYTHONPATH.
- Adds Houdini's bundled tools to
# FIRST STAGE: Download Houdini
FROM python:${PYTHON_VER}-slim-trixie AS houdini-downloader
...
# SECOND STAGE: Install and initialize Houdini
FROM python:${PYTHON_VER}-slim-trixie AS houdini-install
...
# THIRD STAGE: Copy the installed files into a fresh image
FROM python:${PYTHON_VER}-slim-trixie
ARG PYTHON_VER
COPY / /
...
That produces a base image, houdini-base.
The web server (Dockerfile.flask) and
the Celery workers (Dockerfile.celery) each have a small Dockerfile of their own,
which starts FROM houdini-base (which already includes the app's Python dependencies) and sets the command that
launches the process.
compose.yaml builds the base image first, then the other two on top of it.
System Packages
Houdini ships nearly everything it needs in its own dsolib folder ($HFS/dsolib).
That's around 400 shared libraries in Houdini 22, so the list of supplemental system packages is short. The install stage adds them with apt-get:
RUN apt-get update && \
apt-get install -y --no-install-recommends \
... libgl1 libatomic1 && \
rm -rf /var/lib/apt/lists/*
- libatomic1: Small GCC runtime library that provides atomic operations when the compiler can't generate the necessary CPU instructions directly.
- Houdini 22 bundles
libnng(a lightweight messaging library), which links againstlibatomic.so.1. - Slim Debian images don't include
libatomic1, soimport houfails right away:ImportError: libatomic.so.1: cannot open shared object file
- Houdini 22 bundles
- libgl1: Provides
libGL.so.1, the OpenGL library.- Even when running headless,
hourequires this library because its native libraries link against it.
- Even when running headless,
Note: KineFX needs a few more packages
Some plugins, like KineFX, load those UI libraries even when running headless. Without the rest of what the UI libraries need, KineFX's nodes quietly go missing.
On Debian Trixie, that's
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libopengl0 libegl1 libxcomposite1 libxdamage1 \
libxfixes3 libxi6 libxrandr2 libxrender1 libxtst6 \
libasound2t64 libdbus-1-3 libfontconfig1 libnspr4 \
libnss3 libpci3 libxkbcommon0 libxkbfile1 && \
rm -rf /var/lib/apt/lists/*
Licensing
Houdini supports API key licensing, which lets hserver (Houdini's licensing daemon) use a SideFX client ID and secret instead of a login.
Setting it up takes two steps:
- Add the credentials to an
hserver.inifile:- This is a file specifying
hserveroptions. APIKey=www.sidefx.com <client-id> <client-secret>
- This is a file specifying
- Point
hserverat SideFX's license server.hserversends client ID + secret to this server to checkout a license.- SideFX's license server is: https://www.sidefx.com/license/sesinetd
From the setup script that handles this, setup_hserver.sh:
# Houdini 22 reads `hserver.ini` from `~/.local/share/sidefx`
# Older versions from `~/houdiniX.Y`.
for hserver_dir in /root/houdini$HFS_TARGET \
/root/.local/share/sidefx; do
mkdir -p "$hserver_dir"
echo "APIKey=www.sidefx.com $SIDEFX_CLIENT $SIDEFX_SECRET" \
> "$hserver_dir/hserver.ini"
done
echo "Configuring license server..."
# Specifies the server by name to hserver.
hserver -S https://www.sidefx.com/license/sesinetd
Preparing Houdini licenses for the celery workers:
CMD ["/bin/bash", "-c", "source /root/setup_hserver.sh && \
celery --app make_celery worker --loglevel=info \
--logfile=logs/celery.log -E -c 2"]
Sharing licenses across containers
Each hserver checks out its own license, so two containers would use two.
To share one, the Celery container joins the Flask container's network and process namespaces in compose.yaml, and talks to its hserver instead:
network_mode: 'service:hou_flask_app'
pid: 'service:hou_flask_app'
- network_mode: Instead of getting its own network, the Celery container uses the Flask container's. They share
an IP address and
localhost, so Houdini in either container reaches the samehserveron its local port. - pid: The containers share one process list, so each can see (and signal) the other's processes, including the
hserveralready running in the Flask container.
The license also stays checked out if hserver is just killed, so the Flask container quits it (hserver -Q) when it's told to stop, returning the license right away.
Importing hou
This project started out attempting to use hwebserver, Houdini's built-in web server module.
Unfortunately, hwebserver.registerWSGIApp doesn't fully support multipart form requests, which is exactly how the browser would upload .hip files, making it far from ideal for my purposes.
So instead, the Flask and Celery processes run in a standard Python interpreter, and import hou directly. The image puts Houdini's bundled python3.Xlibs folder on the PYTHONPATH, so Python can find hou.
But again, getting it to actually load took more tinkering:
Mirroring hython's Environment
hython sets up a couple of things before Python even starts, which a standard interpreter doesn't get for free:
# Houdini 22 ships tcmalloc, older versions shipped jemalloc.
for allocator in \
/opt/houdini/build/dsolib/libtcmalloc_minimal.so.4 \
/opt/houdini/build/dsolib/libjemalloc.so; do
if [ -f "$allocator" ]; then
export LD_PRELOAD="$allocator"
break
fi
done
Memory allocator
- The allocator is the code behind
mallocandfree, which hands out memory to a program and takes it back when it's done. By default, that's glibc's. - Houdini ships its own instead (jemalloc, or tcmalloc as of Houdini 22), both built for heavily multithreaded programs that make lots of small allocations.
- SideFX's docs recommend this.
# Python's own modules (e.g. ssl) load before `hou`,
# and must resolve to Houdini's libraries.
export LD_LIBRARY_PATH="/opt/houdini/build/dsolib\
${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Shared libraries
- If Python's own modules, like
sslandlzma, get imported beforehou, they load the system's copies oflibsslandliblzma. - Putting Houdini's
dsolibfolder first onLD_LIBRARY_PATH(before Python starts) makes those first loads pick up Houdini's copies instead.
# Set by hython, and required by SideFX Labs' pythonrc.py.
export HOUDINI_USER_PREF_DIR="/root/houdini$HFS_TARGET"
HOUDINI_USER_PREF_DIR: hython sets this, and SideFX Labs' pythonrc.py relies on it.
Enabling hou module
With that now in place, importing hou takes one more trick. enable_hou_module() (in
hou_api.py) follows SideFX's snippet for
accessing hou from a regular Python shell:
def enable_hou_module():
import os
import sys
if hasattr(sys, "setdlopenflags"):
old_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(old_dlopen_flags | os.RTLD_GLOBAL)
try:
import hou
except ImportError:
# If the hou module could not be imported, then add
# $HFS/houdini/pythonX.Ylibs to sys.path so Python can
# locate the hou module.
sys.path.append(os.environ['HHP'])
import hou
finally:
# Reset dlopen flags back to their original value.
if hasattr(sys, "setdlopenflags"):
sys.setdlopenflags(old_dlopen_flags)
enable_hou_module()
import hou
Importing hou doesn't just load a Python module. It loads Houdini's libraries and initializes Houdini, which includes loading any HDK extensions (plugins written in C++). Those extensions link against Houdini's libraries, so they need to be able to see its symbols.
dlopen is the Linux function that loads a shared library (.so) into a running process, and Python calls it whenever it imports a compiled module like Houdini's _hou.so.
The flags passed along with it control how the library gets loaded:
- RTLD_NOW / RTLD_LAZY: Whether the library's function references get resolved as soon as it loads, or only when each function is first called.
- RTLD_LOCAL / RTLD_GLOBAL: Whether the library's symbols stay private to it, or are also made available to every library loaded after it.
Python's flags default to RTLD_NOW | RTLD_LOCAL.
So Houdini's symbols aren't made globally available, and any extension won't be able to find them.
GPU Support
GPU support is optional, and targets NVIDIA GPUs on Linux. With the
NVIDIA Container Toolkit installed, the Celery service can request a GPU by uncommenting its deploy block in compose.yaml:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
Compose treats GPUs as device reservations: resources the container needs before it can start.
driver: nvidiahands the request to the NVIDIA Container Toolkitcount: 1asks for a single GPU (alltakes every GPU, anddevice_idspicks specific ones)capabilities: [gpu]is required: without it, Compose won't match the request to a GPU.
Under the hood, this is the same request as docker run --gpus 1. Docker hands it to the NVIDIA Container Toolkit, which mounts the GPU's device files and the host's driver libraries into the container before it starts.
Inside the image, OpenCL needs to be pointed at NVIDIA's driver, and Karma XPU needs a few more libraries. The end of
Dockerfile.houdini handles that:
# Install the required libs for OpenCL, then point OpenCL
# to the correct implementation.
# Karma XPU's GPU module links Qt, which needs the GL, EGL,
# xkbcommon and D-Bus libs to load.
# It also loads `libcuda.so`, while the NVIDIA Container
# Toolkit only provides `libcuda.so.1`.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ocl-icd-libopencl1 \
libopengl0 libegl1 libxkbcommon0 libdbus-1-3 && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" \
> /etc/OpenCL/vendors/nvidia.icd && \
ln -s libcuda.so.1 /usr/lib/x86_64-linux-gnu/libcuda.so
# Expose all available GPU devices to the docker container.
# Karma XPU's OptiX libraries are only mounted with the
# "graphics" capability.
ENV NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics
# Use the GPU for OpenCL. Without one, Houdini falls back to
# its built-in CPU OpenCL driver.
ENV HOUDINI_OCL_DEVICETYPE=GPU
- ocl-icd-libopencl1: Lets programs find the installed OpenCL drivers.
nvidia.icdtells it to use NVIDIA's, pointing it atlibnvidia-opencl.so.1, NVIDIA's OpenCL driver.
- NVIDIA_DRIVER_CAPABILITIES: Driver ships libraries for different jobs, this determines which groups are mounted.
compute: Mounts CUDA + OpenCL for GPU computing.utility: Providesnvidia-smi.graphics: MountsOpenGL,Vulkan, and OptiX (used by Karma XPU!)
- HOUDINI_OCL_DEVICETYPE: Tells Houdini to run its OpenCL work on the GPU.
- Without a GPU, Houdini falls back to the CPU OpenCL driver it ships with, so the image still works on machines without one
If you want to dig through the code yourself, it's all on GitHub.