Skip to content
All notes

Notes · 2026-10-30 · 24 min

Training 4D Gaussians, step by step

Every command and click needed to turn 20 camera videos into a trained 4D Gaussian Splatting model, including the five compile errors that will stop you.

4DGSGaussian SplattingRunPodDynamic 3D

This is the complete path from a folder of camera videos to a trained 4D Gaussian Splatting model, including every command, every click and every error we actually hit. It is written so that future-me can repeat it without remembering anything.

The example is the cut_roasted_beef capture: 20 synchronised cameras filming a chef for 10 seconds. The same steps work for any fixed-rig dynamic capture.

What you end up with

•

A trained 4DGS model: a static gaussian cloud plus a deformation network that turns it into a moving scene.

•

A 10 second video rendered from a novel camera path.

•

Optionally, 100 per-frame gaussian files (time_00000.ply … time_00099.ply) that hold the whole animation as data.

•

Cost: about US$1.5–2 of rented GPU time, and roughly 2 hours wall clock, most of it waiting.

What the capture looks like on disk

cut_roasted_beef/
├── cam00.mp4 … cam20.mp4    20 videos, 2704x2028, 30 fps, 10 s each
└── poses_bounds.npy         20 x 17 float64: camera poses + near/far

poses_bounds.npy is the important one. Each row is one camera: 15 numbers forming a 3x5 matrix (3x4 rotation and translation, then height, width, focal length), plus two numbers for the near and far depth bounds. Because the rig gives us exact camera positions, we never need COLMAP to estimate them.

Print the pose of camera 0 to sanity check it:

python3 - <<'PY'
import numpy as np
a = np.load("poses_bounds.npy")
poses = a[:, :-2].reshape(-1, 3, 5)
H, W, f = poses[0][:, 4]
print("cameras:", len(poses), "image:", int(H), "x", int(W), "focal:", round(float(f), 1))
print("near/far:", a[0, -2:])
PY

Part 1 — Prepare the capture on your Mac

1

Downscale the videos. 4K x 300 frames x 20 cameras is 6000 images at 5.5 megapixels; that will not fit in 24 GB of VRAM. 1280 wide at 10 fps is the sweet spot.

mkdir -p 4dgs/videos
for f in cam*.mp4; do
  ffmpeg -v error -y -i "$f" -vf "scale=1280:-2,fps=10" \
    -c:v libx264 -crf 18 -preset veryfast "4dgs/videos/$f"
done
du -sh 4dgs/videos      # expected: about 66 MB
2

Build a real initial point cloud. 4DGS starts from a few thousand 3D points. COLMAP gives you real surface points; random points make training slower and produce floating debris. Because the cameras do not move, run COLMAP on one frame per camera only.

pip install -q pycolmap plyfile
python3 scripts/colmap-init-4dgs.py 3D/cut_roasted_beef

That script extracts the first frame of every video, runs SfM, and reports something like 20 images · 3362 points · 0.62 px reprojection error. A reprojection error under 1 px proves the poses and the video agree.

3

Align COLMAP to the pose file. COLMAP works in its own arbitrary frame and scale. The poses in poses_bounds.npy are a different frame, so the points must be transformed or the model trains against mismatched geometry.

python3 scripts/align-colmap-to-poses.py 3D/cut_roasted_beef

It fits a similarity transform between the 20 COLMAP camera centres and the 20 pose-file centres, then writes points3D_downsample2.ply in the pose frame. Expected output: a scale near 1.0 and a mean residual under a few centimetres. Ours was scale 1.0248, mean residual 8 mm.

4

Check that the PLY has normals. 4DGS reads nx, ny, nz from the file and crashes without them. This bit us: the first PLY only had position and colour, and training died with ValueError: no field of name nx.

python3 - <<'PY'
from plyfile import PlyData
v = PlyData.read("points3D_downsample2.ply")["vertex"]
print(v.data.dtype.names)   # must include nx, ny, nz
PY

If they are missing, rewrite the file with zeroed normals:

python3 - <<'PY'
import numpy as np
from plyfile import PlyData, PlyElement
p = "points3D_downsample2.ply"
v = PlyData.read(p)["vertex"]; n = len(v)
dt = np.dtype([("x","f4"),("y","f4"),("z","f4"),("nx","f4"),("ny","f4"),("nz","f4"),
               ("red","u1"),("green","u1"),("blue","u1")])
a = np.zeros(n, dtype=dt)
a["x"], a["y"], a["z"] = v["x"], v["y"], v["z"]
a["red"], a["green"], a["blue"] = v["red"], v["green"], v["blue"]
a["nz"] = 1.0
PlyData([PlyElement.describe(a, "vertex")]).write(p)
print("rewrote", n, "points with normals")
PY

Part 2 — Rent the GPU

1

Go to runpod.io, sign in, open Billing, add US$10.

2

Click Deploy.

3

GPU: RTX 4090 (24 GB) at about $0.89/hr. An A100 40 GB is safer if you keep the videos at higher resolution, at about $1.89/hr.

4

Template: RunPod PyTorch 2.4 or PyTorch 2.8 / CUDA 12.8. It must be an official RunPod PyTorch image, because those ship nvcc.

5

Container disk: 60 GB. Volume and ports: leave empty.

6

Click Deploy On-Demand, wait for Running, then Connect → Connect to Jupyter Lab.

Verify the machine before installing anything:

nvidia-smi
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
nvcc --version | tail -2

You need to see the GPU name, True, and a CUDA compiler version. If nvcc is missing you picked the wrong template: terminate and redeploy with a RunPod PyTorch image.

Part 3 — Upload the data

1

In Jupyter's file browser, open /workspace.

2

Drag cut_roasted_beef_4dgs.tar.gz (58 MB) into it.

3

In a terminal:

cd /workspace
tar -xzf cut_roasted_beef_4dgs.tar.gz
ls cut_roasted_beef | wc -l     # 22 items: 20 videos + poses_bounds.npy + the ply

Part 4 — Install 4DGaussians

1

Clone without submodules first. A recursive clone of this repo fails often on flaky links.

cd /workspace
git config --global http.postBuffer 524288000
git clone --depth 1 https://github.com/hustvl/4DGaussians.git
cd 4DGaussians
2

Fetch the two submodules individually. The names matter: the rasteriser folder is depth-diff-gaussian-rasterization, but the Python module it installs is diff_gaussian_rasterization.

git submodule update --init --depth 1 submodules/simple-knn
git submodule update --init --depth 1 submodules/depth-diff-gaussian-rasterization
3

Do not install requirements.txt. It pins torch==1.13.1 and mmcv==1.6.0, both from 2023. Installing it downgrades torch and breaks every compiled module. Install only what the code actually imports.

pip install -q easydict tqdm plyfile imageio imageio-ffmpeg opencv-python-headless \
  matplotlib scipy scikit-learn open3d lpips pytorch_msssim pillow

TORCH=$(python -c "import torch;print(torch.__version__.split('+')[0])")
CU=$(python -c "import torch;print(torch.version.cuda.replace('.',''))")
pip install -q torch-scatter torch-cluster \
  -f https://data.pyg.org/whl/torch-${TORCH}+cu${CU}.html

If open3d fails with Cannot uninstall blinker ... no RECORD file, that is a Debian package fighting pip. Use pip install --ignore-installed blinker open3d. open3d also needs system libraries: apt-get install -y libegl1 libgl1 libglib2.0-0 libgomp1.

Part 5 — The five fixes you will probably need

1

FLT_MAX undefined when compiling simple_knn.cu. Newer CUDA no longer pulls in <cfloat> transitively.

cd /workspace/4DGaussians/submodules/simple-knn
python - <<'PY'
p = "simple_knn.cu"
s = open(p).read()
if "#include <cfloat>" not in s:
    open(p, "w").write("#include <cfloat>\n" + s)
    print("patched")
PY
2

glm/glm.hpp: No such file. The submodule does not include GLM. Clone it into third_party, and pin an older tag: the current GLM (1.0) does not compile cleanly with CUDA 12.8.

cd /workspace/4DGaussians/submodules/depth-diff-gaussian-rasterization
git clone --depth 1 https://github.com/g-truc/glm.git third_party/glm
cd third_party/glm
git fetch --depth 1 origin refs/tags/0.9.9.8:refs/tags/0.9.9.8
git checkout -q 0.9.9.8
3

namespace std has no member uintptr_t / uint32_t is undefined. Same class of problem: missing <cstdint>.

cd /workspace/4DGaussians/submodules/depth-diff-gaussian-rasterization
python - <<'PY'
import pathlib
for p in list(pathlib.Path("cuda_rasterizer").glob("*.h")) + list(pathlib.Path("cuda_rasterizer").glob("*.cu")):
    s = p.read_text(errors="ignore")
    if ("uint32_t" in s or "uintptr_t" in s) and "#include <cstdint>" not in s:
        p.write_text("#include <cstdint>\n" + s)
        print("patched", p.name)
PY
4

Build both modules without pip's sandbox. pip's isolated build environment cannot see torch, so you get ModuleNotFoundError: No module named 'torch'. Build in place instead.

export TORCH_CUDA_ARCH_LIST="8.9"     # 4090 = 8.9, A100 = 8.0

cd /workspace/4DGaussians/submodules/simple-knn
python setup.py build_ext --inplace

cd /workspace/4DGaussians/submodules/depth-diff-gaussian-rasterization
python setup.py build_ext --inplace

export PYTHONPATH=/workspace/4DGaussians/submodules/simple-knn:/workspace/4DGaussians/submodules/depth-diff-gaussian-rasterization:$PYTHONPATH
5

from tkinter import W crashes training, and import mmcv fails. The tkinter line is an accident in scene/deformation.py; mmcv is only used to read a config file. Delete the import and drop in a tiny stand-in.

cd /workspace/4DGaussians
python - <<'PY'
p = "scene/deformation.py"
s = open(p).read()
s = s.replace("from tkinter import W\n", "")
open(p, "w").write(s)
print("removed tkinter import")
PY

cat > mmcv.py <<'EOF'
class Config(dict):
    @staticmethod
    def fromfile(path):
        ns = {}
        with open(path) as f:
            exec(compile(f.read(), path, "exec"), ns)
        ns.pop("__builtins__", None)
        return Config(ns)
EOF

Verify everything before training:

python -c "import torch, open3d, simple_knn, diff_gaussian_rasterization; print('OK', torch.__version__)"
# expected: OK 2.8.0+cu128

Part 6 — Train

Run inside tmux so a browser disconnect does not kill the job:

tmux new -s train
export PYTHONPATH=/workspace/4DGaussians/submodules/simple-knn:/workspace/4DGaussians/submodules/depth-diff-gaussian-rasterization:$PYTHONPATH
cd /workspace/4DGaussians
python train.py -s /workspace/cut_roasted_beef \
  --expname roasted --configs arguments/dynerf/default.py

The first run extracts frames from the videos into camXX/images/, about 40 seconds per camera, so 12 minutes before training starts. Later runs reuse them.

What healthy progress looks like:

Training progress:  16%| 470/3000 [00:46, 10.5it/s, Loss=0.089, psnr=18.2, point=1060]
Training progress:  47%|1420/3000 [02:15, 11.6it/s, Loss=0.060, psnr=21.0, point=6617]
Training progress: 100%|3000/3000 [04:53,  9.7it/s, Loss=0.025, psnr=26.2, point=25507]
Training progress:   3%| 470/14000 [01:06, 7.2it/s, Loss=0.019, psnr=28.6, point=26667]

Coarse stage is 3000 iterations, then 14000 fine iterations. On a 4090 at this resolution it took 37 minutes. The point count grows from 1,060 to about 60,000 as gaussians densify. Final numbers for this capture: train PSNR 34.57, test PSNR about 33.

Press Ctrl+B then D to detach, tmux attach -t train to come back.

Part 7 — Render a video

cd /workspace/4DGaussians
python render.py --model_path output/roasted \
  --configs arguments/dynerf/default.py --skip_train

Output: output/roasted/video/ours_14000/video_rgb.mp4, 1360x1024, 30 fps, 10 s, about 3 MB. Keep the camera path inside the captured arc: this rig has two rows of cameras with empty space at the sides, so a full turntable will show stretching at 90 degrees.

Part 8 — Export the 4D model as per-frame splats

python export_perframe_3DGS.py --model_path output/roasted \
  --configs arguments/dynerf/default.py --iteration 14000

This writes output/roasted/gaussian_pertimestamp/time_00000.ply … time_00099.ply. Each frame is about 15 MB because it stores position, scale, rotation, opacity and 45 spherical-harmonic colour coefficients for every gaussian. Total: 1.5 GB for 100 frames.

The canonical static model lives in output/roasted/point_cloud/iteration_14000/ together with deformation.pth (9.4 MB), deformation_table.pth and deformation_accum.pth. Those three files are what make it 4D: keep them.

Part 9 — Download and shut down

cd /workspace
zip -q -r 4dgs_full.zip \
  4DGaussians/output/roasted/gaussian_pertimestamp \
  4DGaussians/output/roasted/point_cloud/iteration_14000 \
  4DGaussians/output/roasted/cfg_args
ls -lh 4dgs_full.zip

For a 1.3 GB zip, download it from Jupyter's file browser in one go if your connection is stable, otherwise split it: split -b 400M 4dgs_full.zip 4dgs_part_ and download the parts.

Then Terminate the pod from the RunPod console. Closing the browser tab does not stop billing.

Part 10 — Looking at the result

Fastest check: open https://superspl.at/editor and drag in time_00050.ply. That confirms the export is valid before you build anything around it.

Static interactive model: point_cloud.ply alone loads in any 3DGS viewer, including the one on this site.

4D playback in the browser is the hard part, and worth writing down honestly. The PlayCanvas viewer used by this site creates its own orbit camera with a fixed distance, ignores settings.cameras, and overwrites the camera every frame. What worked was subscribing to the engine update loop and re-applying a fixed pose after the viewer's own controller runs:

handle.app.on("update", () => {
  const cam = handle.app.root.findComponents("camera")[0].entity;
  cam.setPosition(3.5, 15.5, -24);
  cam.lookAt(3.5, 15.0, -14);
});

The trade-off: a forced pose means drag-to-orbit stops working. A proper player needs its own camera controller rather than the viewer's.

What it costs

GPU installation + frame extraction    ~40 min   $0.60
Training 14,000 iterations             ~37 min   $0.55
Render + per-frame export              ~10 min   $0.15
------------------------------------------------------
Total                                  ~1.5 h    ~$1.30

Troubleshooting

•

RPC failed; curl 56 while cloning: retry with --depth 1, or download the zip from codeload.github.com and unpack it.

•

No module named 'diff_gaussian_rasterization' after a successful build: the module name has no depth- prefix, and you must export PYTHONPATH to the submodule folder.

•

Cannot add splat scene while another load is in progress: never call removeSplatScene and addSplatScene concurrently; await the removal, or rebuild the viewer.

•

ValueError: no field of name nx: the PLY has no normals, see Part 1 step 4.

•

Everything renders as a tiny dot: the viewer's default orbit distance is enormous relative to your scene; force the camera explicitly.

•

Training loss stays above 0.2: the poses and the video disagree. Check the COLMAP reprojection error first; it should be under 1 px.