Spaces:
Paused
Paused
Commit
•
c0bb512
1
Parent(s):
67b7e1c
quick test
Browse files- Dockerfile +5 -45
- README.md +25 -0
- src/config.mts +2 -1
- src/index.mts +9 -6
- src/initFolders.mts +5 -6
- tmp.txt +144 -0
Dockerfile
CHANGED
@@ -16,6 +16,8 @@ RUN apt update
|
|
16 |
# base stuff
|
17 |
RUN apt --yes install build-essential wget curl rpl
|
18 |
|
|
|
|
|
19 |
# NodeJS - LEGACY/DEPRECATED WAY
|
20 |
#RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
21 |
#RUN apt --yes install nodejs
|
@@ -24,7 +26,7 @@ RUN apt --yes install build-essential wget curl rpl
|
|
24 |
RUN apt --yes install -y ca-certificates gnupg
|
25 |
RUN mkdir -p /etc/apt/keyrings
|
26 |
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
27 |
-
ENV NODE_MAJOR=
|
28 |
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
29 |
RUN apt update
|
30 |
RUN apt --yes install nodejs
|
@@ -68,7 +70,6 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1
|
|
68 |
#RUN wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip \
|
69 |
# && unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/
|
70 |
|
71 |
-
|
72 |
# Set up a new user named "user" with user ID 1000
|
73 |
RUN useradd -o -u 1000 user
|
74 |
|
@@ -77,7 +78,6 @@ USER user
|
|
77 |
|
78 |
ENV PYTHON_BIN /usr/bin/python3
|
79 |
|
80 |
-
|
81 |
#ENV PATH /usr/local/cuda-12.2/bin:$PATH
|
82 |
#ENV LD_LIBRARY_PATH /usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH
|
83 |
# Let's try to downgrade
|
@@ -106,51 +106,11 @@ RUN git clone --recursive https://github.com/MrNeRF/gaussian-splatting-cuda
|
|
106 |
|
107 |
WORKDIR $HOME/app/gaussian-splatting-cuda
|
108 |
|
109 |
-
|
110 |
-
RUN unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/
|
111 |
-
RUN rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip
|
112 |
-
|
113 |
-
# Build (on CPU, this will add compute_35 as build target, which we do not want)
|
114 |
-
# There seems to be a work around, see this thread:
|
115 |
-
# https://github.com/MrNeRF/gaussian-splatting-cuda/issues/14
|
116 |
-
# here is the hack:
|
117 |
-
|
118 |
-
# Replace "native" by "all"
|
119 |
-
# inspired by https://github.com/ztxz16/fastllm/pull/309/files
|
120 |
-
#
|
121 |
-
|
122 |
-
# CUDA architectures are defined as codes
|
123 |
-
# by default CMake detected:
|
124 |
-
# 3.5;5.0;8.0;8.6;8.9;9.0
|
125 |
-
# To see the mapping: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
|
126 |
-
# A10G and A100 -> Ampere -> sm_80, sm_86, sm_87 -> 8.0;8.6;8.7
|
127 |
-
# Nvidia T4 -> Turing -> sm_75 -> 7.5
|
128 |
-
# ? -> Lovelace -> sm_89 -> 8.6
|
129 |
-
# ? -> Hopper -> sm_90 -> 9.0
|
130 |
-
|
131 |
-
# this doesn't something, but then it still try to build for arch 3.5 / 35
|
132 |
-
# RUN find . -name CMakeLists.txt -exec sed -i 's/CUDA_ARCHITECTURES native/CUDA_ARCHITECTURES "80;86;89;90"/' {} +
|
133 |
-
|
134 |
-
RUN find . -name CMakeLists.txt -exec sed -i 's/CUDA_ARCHITECTURES native/CUDA_ARCHITECTURES all/' {} +
|
135 |
-
|
136 |
-
#RUN cmake -B build -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.2/ -D CUDA_VERSION=12.2
|
137 |
-
# Let's try to downgrade the version
|
138 |
-
RUN cmake -B build -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.8/ -D CUDA_VERSION=11.8
|
139 |
-
|
140 |
-
RUN ls -la build/
|
141 |
-
RUN ls -la build/external/
|
142 |
-
RUN ls -la build/CMakeFiles
|
143 |
-
|
144 |
-
# we actually cannot generate for "all" architectures: compute_35 is not supported anymore
|
145 |
-
# RUN find . -name CMakeLists.txt -exec sed -i 's/-gencode arch=compute_35,code=sm_35//' {} +
|
146 |
-
|
147 |
-
RUN cmake --build build -- -j8
|
148 |
|
149 |
COPY --chown=user . $HOME/app/gaussian-splatting-cuda
|
150 |
|
151 |
-
|
152 |
-
#WORKDIR /usr/local/cuda-12.2
|
153 |
-
#COPY --chown=user . $HOME/app/cuda-12.2
|
154 |
|
155 |
EXPOSE 7860
|
156 |
|
|
|
16 |
# base stuff
|
17 |
RUN apt --yes install build-essential wget curl rpl
|
18 |
|
19 |
+
RUN echo "Build started at: $(date "+%Y-%m-%d %H:%M")"
|
20 |
+
|
21 |
# NodeJS - LEGACY/DEPRECATED WAY
|
22 |
#RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
23 |
#RUN apt --yes install nodejs
|
|
|
26 |
RUN apt --yes install -y ca-certificates gnupg
|
27 |
RUN mkdir -p /etc/apt/keyrings
|
28 |
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
29 |
+
ENV NODE_MAJOR=18
|
30 |
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
31 |
RUN apt update
|
32 |
RUN apt --yes install nodejs
|
|
|
70 |
#RUN wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip \
|
71 |
# && unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/
|
72 |
|
|
|
73 |
# Set up a new user named "user" with user ID 1000
|
74 |
RUN useradd -o -u 1000 user
|
75 |
|
|
|
78 |
|
79 |
ENV PYTHON_BIN /usr/bin/python3
|
80 |
|
|
|
81 |
#ENV PATH /usr/local/cuda-12.2/bin:$PATH
|
82 |
#ENV LD_LIBRARY_PATH /usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH
|
83 |
# Let's try to downgrade
|
|
|
106 |
|
107 |
WORKDIR $HOME/app/gaussian-splatting-cuda
|
108 |
|
109 |
+
# for quick testing we disabled the rest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
COPY --chown=user . $HOME/app/gaussian-splatting-cuda
|
112 |
|
113 |
+
RUN echo "Build ended at: $(date "+%Y-%m-%d %H:%M")"
|
|
|
|
|
114 |
|
115 |
EXPOSE 7860
|
116 |
|
README.md
CHANGED
@@ -7,3 +7,28 @@ sdk: docker
|
|
7 |
pinned: true
|
8 |
app_port: 3000
|
9 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
pinned: true
|
8 |
app_port: 3000
|
9 |
---
|
10 |
+
|
11 |
+
## Presentation
|
12 |
+
|
13 |
+
### What is this project?
|
14 |
+
|
15 |
+
Gaussian Splatting API is a REST API to generate 3D Gaussian Splatting scenes from a set of images.
|
16 |
+
|
17 |
+
### What is the licence?
|
18 |
+
|
19 |
+
## Running on your machine
|
20 |
+
|
21 |
+
### Prerequisites
|
22 |
+
|
23 |
+
You need a machine with CUDA, a GPU etc
|
24 |
+
|
25 |
+
### Environment variables
|
26 |
+
|
27 |
+
- `STORAGE_PATH`: on HF use `/data`, on a local you can use `.sandbox/`
|
28 |
+
|
29 |
+
### Deployment to Hugging Face
|
30 |
+
|
31 |
+
This can take some time.
|
32 |
+
|
33 |
+
note: this is a long build (~30 min)
|
34 |
+
|
src/config.mts
CHANGED
@@ -2,7 +2,8 @@ import path from "node:path"
|
|
2 |
|
3 |
export const storagePath = `${process.env.STORAGE_PATH || './sandbox'}`
|
4 |
|
5 |
-
export const
|
|
|
6 |
|
7 |
export const shotFormatVersion = 1
|
8 |
export const sequenceFormatVersion = 1
|
|
|
2 |
|
3 |
export const storagePath = `${process.env.STORAGE_PATH || './sandbox'}`
|
4 |
|
5 |
+
export const inputsDirFilePath = path.join(storagePath, "training_inputs")
|
6 |
+
export const outputsDirFilePath = path.join(storagePath, "training_outputs")
|
7 |
|
8 |
export const shotFormatVersion = 1
|
9 |
export const sequenceFormatVersion = 1
|
src/index.mts
CHANGED
@@ -7,12 +7,15 @@ initFolders()
|
|
7 |
const app = express()
|
8 |
const port = 7860
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
app.use(express.
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
app.get("/", async (req, res) => {
|
18 |
// this is what users will see in the space - but no need to show something scary
|
|
|
7 |
const app = express()
|
8 |
const port = 7860
|
9 |
|
10 |
+
const queue = []
|
11 |
+
const queueLimit = 4
|
12 |
+
|
13 |
+
app.use(express.json({limit: '50mb'}))
|
14 |
+
app.use(express.urlencoded({limit: '50mb', extended: true}))
|
15 |
+
|
16 |
+
app.post("/", async (req, res) => {
|
17 |
+
// TODO
|
18 |
+
})
|
19 |
|
20 |
app.get("/", async (req, res) => {
|
21 |
// this is what users will see in the space - but no need to show something scary
|
src/initFolders.mts
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
import {
|
2 |
-
|
|
|
3 |
} from "./config.mts"
|
4 |
import { createDirIfNeeded } from "./utils/createDirIfNeeded.mts"
|
5 |
|
6 |
export const initFolders = () => {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
// console.log(`initializing folders..`)
|
11 |
-
// createDirIfNeeded(postDirFilePath)
|
12 |
}
|
|
|
1 |
import {
|
2 |
+
inputsDirFilePath,
|
3 |
+
outputsDirFilePath,
|
4 |
} from "./config.mts"
|
5 |
import { createDirIfNeeded } from "./utils/createDirIfNeeded.mts"
|
6 |
|
7 |
export const initFolders = () => {
|
8 |
+
console.log(`initializing folders..`)
|
9 |
+
createDirIfNeeded(inputsDirFilePath)
|
10 |
+
createDirIfNeeded(outputsDirFilePath)
|
|
|
|
|
11 |
}
|
tmp.txt
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#FROM nvidia/cuda:12.2.0-devel-ubuntu20.04
|
2 |
+
# let's try to downgrade the version of CUDA
|
3 |
+
FROM nvidia/cuda:11.8.0-devel-ubuntu20.04
|
4 |
+
|
5 |
+
LABEL maintainer="Hugging Face"
|
6 |
+
|
7 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
8 |
+
|
9 |
+
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
|
10 |
+
SHELL ["sh", "-lc"]
|
11 |
+
|
12 |
+
# WORKDIR /workdir
|
13 |
+
|
14 |
+
RUN apt update
|
15 |
+
|
16 |
+
# base stuff
|
17 |
+
RUN apt --yes install build-essential wget curl rpl
|
18 |
+
|
19 |
+
RUN echo "Build started at: $(date "+%Y-%m-%d %H:%M")"
|
20 |
+
|
21 |
+
# NodeJS - LEGACY/DEPRECATED WAY
|
22 |
+
#RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
23 |
+
#RUN apt --yes install nodejs
|
24 |
+
|
25 |
+
# NodeJS - NEW, MORE ANNOYING WAY
|
26 |
+
RUN apt --yes install -y ca-certificates gnupg
|
27 |
+
RUN mkdir -p /etc/apt/keyrings
|
28 |
+
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
29 |
+
ENV NODE_MAJOR=18
|
30 |
+
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
31 |
+
RUN apt update
|
32 |
+
RUN apt --yes install nodejs
|
33 |
+
|
34 |
+
# git and file management
|
35 |
+
RUN apt --yes install git git-lfs unzip
|
36 |
+
RUN git lfs install
|
37 |
+
|
38 |
+
# Python
|
39 |
+
RUN apt --yes install python3 python3-pip
|
40 |
+
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
41 |
+
|
42 |
+
|
43 |
+
# required for CMake it seems
|
44 |
+
RUN apt --yes install libtbb-dev libeigen3-dev g++ libssl-dev checkinstall
|
45 |
+
|
46 |
+
|
47 |
+
# The app require CMake 3.24+ but this version of Ubuntu only has the 3.16
|
48 |
+
# So we need to install a more recent version
|
49 |
+
#RUN apt-get update \
|
50 |
+
# && rm -rf /var/lib/apt/lists/* \
|
51 |
+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-Linux-x86_64.sh \
|
52 |
+
-q -O /tmp/cmake-install.sh \
|
53 |
+
&& chmod u+x /tmp/cmake-install.sh \
|
54 |
+
&& mkdir /opt/cmake-3.24.1 \
|
55 |
+
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \
|
56 |
+
&& rm /tmp/cmake-install.sh \
|
57 |
+
&& ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin
|
58 |
+
|
59 |
+
# Install cmake 3.24
|
60 |
+
#RUN wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.22.1.tar.gz \
|
61 |
+
# && tar -zvxf cmake-3.24.1.tar.gz \
|
62 |
+
# && cd cmake-3.24.1 \
|
63 |
+
# && ./bootstrap \
|
64 |
+
# && make -j8 \
|
65 |
+
# && checkinstall --pkgname=cmake --pkgversion="3.20-custom" --default
|
66 |
+
# Copy contents from 2 levels up
|
67 |
+
#COPY . ./
|
68 |
+
|
69 |
+
# Download and extract libtorch
|
70 |
+
#RUN wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip \
|
71 |
+
# && unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/
|
72 |
+
|
73 |
+
# Set up a new user named "user" with user ID 1000
|
74 |
+
RUN useradd -o -u 1000 user
|
75 |
+
|
76 |
+
# Switch to the "user" user
|
77 |
+
USER user
|
78 |
+
|
79 |
+
ENV PYTHON_BIN /usr/bin/python3
|
80 |
+
|
81 |
+
#ENV PATH /usr/local/cuda-12.2/bin:$PATH
|
82 |
+
#ENV LD_LIBRARY_PATH /usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH
|
83 |
+
# Let's try to downgrade
|
84 |
+
ENV PATH /usr/local/cuda-11.8/bin:$PATH
|
85 |
+
ENV LD_LIBRARY_PATH /usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
|
86 |
+
|
87 |
+
|
88 |
+
# Set home to the user's home directory
|
89 |
+
ENV HOME=/home/user \
|
90 |
+
PATH=/home/user/.local/bin:$PATH
|
91 |
+
|
92 |
+
# Set the working directory to the user's home directory
|
93 |
+
WORKDIR $HOME/app
|
94 |
+
|
95 |
+
# Install app dependencies
|
96 |
+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
97 |
+
# where available (npm@5+)
|
98 |
+
COPY --chown=user package*.json $HOME/app
|
99 |
+
|
100 |
+
RUN npm install
|
101 |
+
|
102 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
103 |
+
COPY --chown=user . $HOME/app
|
104 |
+
|
105 |
+
RUN git clone --recursive https://github.com/MrNeRF/gaussian-splatting-cuda
|
106 |
+
|
107 |
+
WORKDIR $HOME/app/gaussian-splatting-cuda
|
108 |
+
|
109 |
+
RUN wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip
|
110 |
+
RUN unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/
|
111 |
+
RUN rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip
|
112 |
+
|
113 |
+
# Build (on CPU, this will add compute_35 as build target, which we do not want)
|
114 |
+
# There seems to be a work around, see this thread:
|
115 |
+
# https://github.com/MrNeRF/gaussian-splatting-cuda/issues/14
|
116 |
+
# here is the hack:
|
117 |
+
#
|
118 |
+
# Replace "native" by "all"
|
119 |
+
# inspired by https://github.com/ztxz16/fastllm/pull/309/files
|
120 |
+
#
|
121 |
+
# CUDA architectures are defined as codes
|
122 |
+
# by default CMake detected:
|
123 |
+
# 3.5;5.0;8.0;8.6;8.9;9.0
|
124 |
+
# To see the mapping: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
|
125 |
+
# A10G and A100 -> Ampere -> sm_80, sm_86, sm_87 -> 8.0;8.6;8.7
|
126 |
+
# Nvidia T4 -> Turing -> sm_75 -> 7.5
|
127 |
+
# ? -> Lovelace -> sm_89 -> 8.6
|
128 |
+
# ? -> Hopper -> sm_90 -> 9.0
|
129 |
+
RUN find . -name CMakeLists.txt -exec sed -i 's/CUDA_ARCHITECTURES native/CUDA_ARCHITECTURES all/' {} +
|
130 |
+
|
131 |
+
#RUN cmake -B build -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.2/ -D CUDA_VERSION=12.2
|
132 |
+
# Let's try to downgrade the version
|
133 |
+
RUN cmake -B build -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.8/ -D CUDA_VERSION=11.8
|
134 |
+
RUN cmake --build build -- -j8
|
135 |
+
|
136 |
+
COPY --chown=user . $HOME/app/gaussian-splatting-cuda
|
137 |
+
|
138 |
+
RUN echo "Build ended at: $(date "+%Y-%m-%d %H:%M")"
|
139 |
+
|
140 |
+
EXPOSE 7860
|
141 |
+
|
142 |
+
# we can't use this (it time out)
|
143 |
+
# CMD [ "xvfb-run", "-s", "-ac -screen 0 1920x1080x24", "npm", "run", "start" ]
|
144 |
+
CMD [ "npm", "run", "start" ]
|