-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Summary
nvdiffrast is used by sdfstudio's sdf-texture-mesh for GPU-accelerated UV rasterization. Currently it's not installed in the Docker image, so texturing falls back to slower CPU rasterization.
Motivation
- GPU rasterization is significantly faster for texture baking
- Enables future integration with nvdiffrec for material refinement (feat(export): PBR-ish texture extraction and BRDF-aware training #11 Stage 3)
Context
In sdfstudio/exporter/texture_utils_v2.py:
- nvdiffrast is optionally imported with
NVDIFFRAST_AVAILABLEflag - Falls back to
rasterize_uv_cpu()when unavailable - GPU path uses
dr.RasterizeCudaContext()for faster rasterization
Proposed Solution: Builder Wheel
Follow the same pattern mini-mesh uses for tiny-cuda-nn.
Important: Use --no-build-isolation when pip installing CUDA extensions to ensure correct PyTorch ABI compatibility (nvdiffrast docs).
# ===== Builder stage =====
# nvdiffrast wheel
RUN cd /workspace/git && git clone https://github.com/NVlabs/nvdiffrast.git && cd nvdiffrast && \
TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}" pip wheel . --no-build-isolation --no-deps -w /workspace && \
cd /workspace/git && rm -rf nvdiffrast
# ===== Runtime stage =====
COPY --from=builder /workspace/nvdiffrast*.whl /tmp/
RUN pip install --no-cache-dir /tmp/nvdiffrast*.whl && rm /tmp/nvdiffrast*.whlAlternatives Considered
- Runtime install:
pip install --no-build-isolation git+https://github.com/NVlabs/nvdiffrast.git— may work if PyTorch's bundled CUDA is sufficient, but untested in Docker runtime - Skip: Keep CPU fallback, accept slower texturing
Tasks
- Add nvdiffrast wheel build to Docker builder stage
- Install wheel in runtime stage
- Test GPU rasterization works in container
- Update Docker build docs
References
- https://github.com/NVlabs/nvdiffrast
- https://nvlabs.github.io/nvdiffrast/ (Docker build notes)
sdfstudio/exporter/texture_utils_v2.py:46-50(import)sdfstudio/exporter/texture_utils_v2.py:482-485(fallback logic)- mini-mesh tiny-cuda-nn pattern:
docker/Dockerfile:109-115, 176-177
Related Issues
- feat(docker): Add gsplat to Docker image to avoid runtime compilation #8 — gsplat (similar Docker build pattern)
- feat(export): PBR-ish texture extraction and BRDF-aware training #11 — PBR texture extraction (Stage 3 depends on nvdiffrast for nvdiffrec)
Reactions are currently unavailable