Direct3D-S2: Can't install

    ~/Software/Direct3D-S2    main  pyenv local 3.12.3                                                                                                                                                                                                                        ✔ 
    ~/Software/Direct3D-S2    main ?1  pip install -r requirements.txt                                                                                                                                                                                             ✔  3.12.3  

Collecting git+https://github.com/mit-han-lab/torchsparse.git (from -r requirements.txt (line 17))
  Cloning https://github.com/mit-han-lab/torchsparse.git to /tmp/pip-req-build-u3izwgfu
  Running command git clone --filter=blob:none --quiet https://github.com/mit-han-lab/torchsparse.git /tmp/pip-req-build-u3izwgfu
  Resolved https://github.com/mit-han-lab/torchsparse.git to commit 385f5ce8718fcae93540511b7f5832f4e71fd835
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/home/y4my4m/.pyenv/versions/3.12.3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/y4my4m/.pyenv/versions/3.12.3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/y4my4m/.pyenv/versions/3.12.3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-7mbw3cu7/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-7mbw3cu7/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-7mbw3cu7/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 512, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-7mbw3cu7/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 4, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 24.0 -> 25.1.1
[notice] To update, run: pip install --upgrade pip

Installing torch manually DOES NOT solve the issue…

About this issue

Most upvoted comments

https://github.com/Deathdadev/torchsparse My modified version. Please let others know to test this version to see if it works

@loktar00 No need to but I do have https://ko-fi.com/y4my4my4m 😃

@loktar00 i’ve downloaded torchsparse https://github.com/mit-han-lab/torchsparse and put it directly in third_party

I removed it from the requirements.txt:

torch>=2.1.0
scikit-image
trimesh
omegaconf
tqdm
huggingface_hub
einops
numpy
transformers==4.40.2
diffusers
triton==3.1.0
# flash-attn
pymeshfix
utils3d
pyvista
igraph
# git+https://github.com/mit-han-lab/torchsparse.git  <- commented out
# third_party/voxelize/ <- commented out

I put dinov2_vitl14_reg4_pretrain.pth in the root folder (source )

My final docker-compose.yml:

services: direct3d: build: context: . dockerfile: Dockerfile # image: direct3d:latest runtime: nvidia deploy: resources: reservations: devices: - capabilities: [gpu] environment: - GRADIO_SERVER_PORT=7860 - GRADIO_SERVER_NAME=0.0.0.0 - PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True ports: - “7860:7860” volumes: - .:/workspace/app - ~/.cache/huggingface:/root/.cache/huggingface - ./dinov2_vitl14_reg4_pretrain.pth:/root/.cache/torch/hub/checkpoints/dinov2_vitl14_reg4_pretrain.pth:ro

entrypoint: ["gradio", "/workspace/app/app.py", "--demo-name=demo"]

Dockerfile:

FROM nvidia/cuda:12.4.1-devel-ubuntu22.04

Set timezone to avoid interactive prompt

RUN ln -snf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && echo “Asia/Tokyo” > /etc/timezone

Install Python 3.10 and system dependencies

RUN apt update && apt install -y
python3 python3-pip
git
sudo
wget
build-essential
cmake
ninja-build
libgl1-mesa-glx
libglib2.0-0
libsparsehash-dev &&
rm -rf /var/lib/apt/lists/*

Use python3.10 as default

RUN ln -sf /usr/bin/python3.10 /usr/bin/python &&
ln -sf /usr/bin/pip3 /usr/bin/pip

Upgrade pip and install PyTorch 2.5.1 for CUDA 12.4

RUN pip install --upgrade pip &&
pip install torch==2.5.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

Set architecture for compiling CUDA extensions (e.g. RTX 4090)

ENV TORCH_CUDA_ARCH_LIST=“8.9” ENV FORCE_CUDA=1

Copy all project files into container

COPY . /workspace/app

Set working directory

WORKDIR /workspace/app

Ensure local modules are visible (e.g. direct3d_s2/)

ENV PYTHONPATH=“/workspace/app:$PYTHONPATH”

Install Python dependencies (excluding local C++/CUDA extensions)

RUN pip install --no-cache-dir -r requirements.txt

✅ Install local C++/CUDA extensions the right way

RUN pip install --no-cache-dir “filelock>=3.16.1” RUN cd third_party/torchsparse && python setup.py install RUN pip install --no-cache-dir ./third_party/voxelize

Install FlashAttention (PyTorch 2.5.1 + CUDA 12.4 + Python 3.10 build)

RUN wget ‘https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl’ &&
pip install --no-cache-dir flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl &&
rm flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

Optional tools

RUN pip install --no-cache-dir gradio kornia timm trimesh

Entry point to run Gradio app

ENTRYPOINT [“gradio”, “/workspace/app/app.py”, “–demo-name=demo”]

i run it using docker compose up -d --build (to build it the first time), then docker compose stop when im done, docker compose up -d next time i need to run it.

Good luck.

I got it working!! If you have a donation link or something just to throw some money at you to buy you a coffee feel free to share, I seriously have gone round and round with this project off and on for 2 weeks and your help did the trick! Super appreciated, and I’m dead serious about the buying you a coffee or beer. Thanks again!

@loktar00 i’ve downloaded torchsparse https://github.com/mit-han-lab/torchsparse and put it directly in third_party

I removed it from the requirements.txt:

torch>=2.1.0
scikit-image
trimesh
omegaconf
tqdm
huggingface_hub
einops
numpy
transformers==4.40.2
diffusers
triton==3.1.0
# flash-attn
pymeshfix
utils3d
pyvista
igraph
# git+https://github.com/mit-han-lab/torchsparse.git  <- commented out
# third_party/voxelize/ <- commented out

I put dinov2_vitl14_reg4_pretrain.pth in the root folder (source )

My final docker-compose.yml:

services:
  direct3d:
    build:
      context: .
      dockerfile: Dockerfile
    # image: direct3d:latest
    runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
    environment:
      - GRADIO_SERVER_PORT=7860
      - GRADIO_SERVER_NAME=0.0.0.0
      - PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
    ports:
      - "7860:7860"
    volumes:
      - .:/workspace/app
      - ~/.cache/huggingface:/root/.cache/huggingface
      - ./dinov2_vitl14_reg4_pretrain.pth:/root/.cache/torch/hub/checkpoints/dinov2_vitl14_reg4_pretrain.pth:ro

    entrypoint: ["gradio", "/workspace/app/app.py", "--demo-name=demo"]

Dockerfile:

FROM nvidia/cuda:12.4.1-devel-ubuntu22.04

# Set timezone to avoid interactive prompt
RUN ln -snf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && echo "Asia/Tokyo" > /etc/timezone

# Install Python 3.10 and system dependencies
RUN apt update && apt install -y \
    python3 python3-pip \
    git \
    sudo \
    wget \
    build-essential \
    cmake \
    ninja-build \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libsparsehash-dev && \
    rm -rf /var/lib/apt/lists/*

# Use python3.10 as default
RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
    ln -sf /usr/bin/pip3 /usr/bin/pip

# Upgrade pip and install PyTorch 2.5.1 for CUDA 12.4
RUN pip install --upgrade pip && \
    pip install torch==2.5.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

# Set architecture for compiling CUDA extensions (e.g. RTX 4090)
ENV TORCH_CUDA_ARCH_LIST="8.9"
ENV FORCE_CUDA=1

# Copy all project files into container
COPY . /workspace/app

# Set working directory
WORKDIR /workspace/app

# Ensure local modules are visible (e.g. direct3d_s2/)
ENV PYTHONPATH="/workspace/app:$PYTHONPATH"

# Install Python dependencies (excluding local C++/CUDA extensions)
RUN pip install --no-cache-dir -r requirements.txt

# ✅ Install local C++/CUDA extensions the right way
RUN pip install --no-cache-dir "filelock>=3.16.1"
RUN cd third_party/torchsparse && python setup.py install
RUN pip install --no-cache-dir ./third_party/voxelize

# Install FlashAttention (PyTorch 2.5.1 + CUDA 12.4 + Python 3.10 build)
RUN wget 'https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl' && \
    pip install --no-cache-dir flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl && \
    rm flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl



# Optional tools
RUN pip install --no-cache-dir gradio kornia timm trimesh

# Entry point to run Gradio app
# ENTRYPOINT ["gradio", "/workspace/app/app.py", "--demo-name=demo"]

i run it using docker compose up -d --build (to build it the first time), then docker compose stop when im done, docker compose up -d next time i need to run it.

Good luck.

@y4my4my4m how did you fix

AttributeError: module 'torchsparse.backend' has no attribute 'build_kernel_map_subm_hashmap'

?

I’m getting this on a native ubuntu 24.04 build

Here’s a Dockerfile that works for me (albeit OOM during runtime)

FROM docker.io/pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel

RUN apt update --assume-yes && \
    apt install --assume-yes \
        git \
        sudo \
        python3 python3-pip \
        libgl1-mesa-glx \
        libglib2.0-0 && \
    rm -rf /var/lib/apt/lists/*

RUN apt update --assume-yes && \
    apt install --assume-yes \
        wget \
        libsparsehash-dev && \
    rm -rf /var/lib/apt/lists/*

RUN <<EOF
wget 'https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl' \
    -O flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
pip install --no-cache-dir flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
rm ./flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
EOF

COPY ./. /direct3d
RUN <<EOF
cd /direct3d
pip install --no-cache-dir --requirement ./requirements.txt
EOF

RUN <<EOF
pip install --no-cache-dir gradio kornia timm trimesh

wget 'https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl' \
    -O xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl
pip install --no-cache-dir xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl
rm ./xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl
EOF

RUN mkdir -p /workspace/app
WORKDIR /workspace

# ENTRYPOINT ["python", "/app/app.py"]
ENTRYPOINT ["gradio", "/workspace/app/app.py", "--demo-name=demo"]

# podman build --rm --device nvidia.com/gpu=all --tag direct3d:latest -f Dockerfile 

# podman run \
#     --rm -it \
#     --device nvidia.com/gpu=all \
#     --volume ~/.cache/huggingface/hub/models--wushuang98--Direct3D-S2:/root/.cache/huggingface/hub/models--wushuang98--Direct3D-S2:ro \
#     -v "$(pwd)":/workspace/app \
#     -e GRADIO_SERVER_PORT=7860 -e GRADIO_SERVER_NAME=0.0.0.0 \
#     -p 7860:7860 \
#     direct3d:latest

I don’t think there’s anything related to being specifically linux or windows in what they’ve presented so far.

sure because you don’t use windows , the problems here is 3 thing:

triton not for windows flash-attn same thing udf_ext error

the whole install method should be rebuilt for windows users and test it on windows too, and not trying to figure it out how to make it works while using linux

flash-attn: https://huggingface.co/lldacing/flash-attention-windows-wheel/tree/main triton: https://pypi.org/project/triton-windows/ udf_ext: I resolved this issue in my pull request https://github.com/DreamTechAI/Direct3D-S2/pull/10

Please add --no-build-isolation to the end of your command!

For example:

pip install -r requirements.txt --no-build-isolation