Georg commited on
Commit
c05ac4f
·
1 Parent(s): 9550d40

Add FoundationPose dependencies, build nvdiffrast on HuggingFace with GPU

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -27
  2. Dockerfile.base +37 -4
Dockerfile CHANGED
@@ -6,41 +6,19 @@ FROM gpue/foundationpose-base:latest
6
  ENV FOUNDATIONPOSE_MODEL_REPO=gpue/foundationpose-weights
7
  ENV USE_REAL_MODEL=true
8
 
9
- # Downgrade NumPy to 1.x for CUDA extension compatibility
10
  RUN pip install --no-cache-dir "numpy<2"
11
 
12
- # Install build tools temporarily (CUDA compiler already in devel base)
13
- RUN apt-get update && apt-get install -y --no-install-recommends \
14
- cmake \
15
- build-essential \
16
- ninja-build \
17
- libeigen3-dev \
18
- python3.10-dev \
19
- libboost-system-dev \
20
- libboost-program-options-dev \
21
- pybind11-dev \
22
- && rm -rf /var/lib/apt/lists/*
23
 
24
- # Build FoundationPose C++ extensions (requires GPU)
25
  # MAX_JOBS=1 to reduce memory usage during compilation
26
  WORKDIR /app/FoundationPose
27
  ENV MAX_JOBS=1
28
  RUN cd bundlesdf/mycuda && pip install . --no-build-isolation
29
- RUN cd mycpp && mkdir -p build && cd build && cmake .. && make
30
 
31
- # Remove build tools to save space (keep CUDA compiler)
32
- RUN apt-get purge -y cmake ninja-build libeigen3-dev python3.10-dev \
33
- libboost-system-dev libboost-program-options-dev pybind11-dev && \
34
- apt-get autoremove -y && \
35
- apt-get clean && \
36
- rm -rf /var/lib/apt/lists/*
37
-
38
- # Download model weights
39
  WORKDIR /app
40
- RUN python3 -c "from huggingface_hub import snapshot_download; \
41
- snapshot_download(repo_id='gpue/foundationpose-weights', local_dir='weights', repo_type='model')"
42
-
43
- # Clean pip cache
44
- RUN pip cache purge
45
 
46
  CMD ["python3", "app.py"]
 
6
  ENV FOUNDATIONPOSE_MODEL_REPO=gpue/foundationpose-weights
7
  ENV USE_REAL_MODEL=true
8
 
9
+ # Ensure NumPy 1.x for CUDA extension compatibility
10
  RUN pip install --no-cache-dir "numpy<2"
11
 
12
+ # Install nvdiffrast (CUDA rasterizer) - needs GPU, build here
13
+ RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/NVlabs/nvdiffrast.git
 
 
 
 
 
 
 
 
 
14
 
15
+ # Build CUDA extensions (requires GPU - only part that needs HuggingFace GPU)
16
  # MAX_JOBS=1 to reduce memory usage during compilation
17
  WORKDIR /app/FoundationPose
18
  ENV MAX_JOBS=1
19
  RUN cd bundlesdf/mycuda && pip install . --no-build-isolation
 
20
 
21
+ # Note: mycpp build, weights download, and build deps are already in base image
 
 
 
 
 
 
 
22
  WORKDIR /app
 
 
 
 
 
23
 
24
  CMD ["python3", "app.py"]
Dockerfile.base CHANGED
@@ -47,15 +47,48 @@ RUN pip install --no-cache-dir \
47
  huggingface-hub>=0.20.0 \
48
  && pip cache purge
49
 
50
- # Clone FoundationPose (but don't build yet - that's done in final stage)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  RUN git clone --depth 1 https://github.com/NVlabs/FoundationPose.git /app/FoundationPose && \
52
  cd /app/FoundationPose/bundlesdf/mycuda && \
53
  sed -i 's/-std=c++14/-std=c++17/g' setup.py
54
 
 
 
 
 
 
 
 
 
 
55
  # Copy application files
56
  COPY app.py client.py estimator.py ./
57
 
58
- # Create weights directory
59
- RUN mkdir -p weights
60
-
61
  EXPOSE 7860
 
47
  huggingface-hub>=0.20.0 \
48
  && pip cache purge
49
 
50
+ # Install build dependencies (keep them for faster HuggingFace builds)
51
+ # Install BEFORE nvdiffrast because it needs python3.10-dev
52
+ RUN apt-get update && apt-get install -y --no-install-recommends \
53
+ cmake \
54
+ build-essential \
55
+ ninja-build \
56
+ libeigen3-dev \
57
+ python3.10-dev \
58
+ libboost-system-dev \
59
+ libboost-program-options-dev \
60
+ pybind11-dev \
61
+ && rm -rf /var/lib/apt/lists/*
62
+
63
+ # Install FoundationPose dependencies
64
+ RUN pip install --no-cache-dir \
65
+ trimesh==4.2.2 \
66
+ scipy==1.12.0 \
67
+ scikit-image==0.22.0 \
68
+ kornia==0.7.2 \
69
+ einops==0.7.0 \
70
+ timm==0.9.16 \
71
+ transformations==2024.6.1 \
72
+ pyyaml==6.0.1 \
73
+ && pip cache purge
74
+
75
+ # Note: nvdiffrast will be built in final Dockerfile on HuggingFace (needs GPU)
76
+
77
+ # Clone FoundationPose
78
  RUN git clone --depth 1 https://github.com/NVlabs/FoundationPose.git /app/FoundationPose && \
79
  cd /app/FoundationPose/bundlesdf/mycuda && \
80
  sed -i 's/-std=c++14/-std=c++17/g' setup.py
81
 
82
+ # Build mycpp (non-GPU C++ code - can be built without GPU)
83
+ WORKDIR /app/FoundationPose
84
+ RUN cd mycpp && mkdir -p build && cd build && cmake .. && make
85
+
86
+ # Download model weights (246MB)
87
+ WORKDIR /app
88
+ RUN python3 -c "from huggingface_hub import snapshot_download; \
89
+ snapshot_download(repo_id='gpue/foundationpose-weights', local_dir='weights', repo_type='model')"
90
+
91
  # Copy application files
92
  COPY app.py client.py estimator.py ./
93
 
 
 
 
94
  EXPOSE 7860