Skip to content

feat(docker): Add nvdiffrast to Docker image for faster texturing #7

@hummat

Description

@hummat

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

Context

In sdfstudio/exporter/texture_utils_v2.py:

  • nvdiffrast is optionally imported with NVDIFFRAST_AVAILABLE flag
  • 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*.whl

Alternatives Considered

  1. 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
  2. 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

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions