-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Dockerfile #30
Open
bitplane
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
bitplane:docker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−1
Open
add Dockerfile #30
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git | ||
.env | ||
*.pyc | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-devel AS builder | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y ffmpeg build-essential git rdfind | ||
|
||
WORKDIR /app | ||
ADD setup.sh /app/setup.sh | ||
|
||
# Setup conda | ||
RUN conda config --set always_yes true && \ | ||
conda init && \ | ||
conda config --add channels defaults | ||
|
||
# Use bash shell so we can source activate | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
|
||
RUN conda install torchvision=0.19.0 \ | ||
onnx==1.17.0 \ | ||
pytorch=2.4.0 \ | ||
pytorch-cuda=12.4 \ | ||
--force-reinstall \ | ||
-c pytorch \ | ||
-c nvidia | ||
|
||
# Create a g++ wrapper for JIT, since the include dirs are passed with -i rather than -I for some reason | ||
RUN printf '#!/usr/bin/env bash\nexec /usr/bin/g++ -I/usr/local/cuda/include -I/usr/local/cuda/include/crt "$@"\n' > /usr/local/bin/gxx-wrapper && \ | ||
chmod +x /usr/local/bin/gxx-wrapper | ||
ENV CXX=/usr/local/bin/gxx-wrapper | ||
|
||
|
||
# Run setup.sh - this won't install all the things due to missing GPU in the builder | ||
RUN conda run -n base ./setup.sh --basic --xformers --flash-attn --diffoctreerast --vox2seq --spconv --mipgaussian --kaolin --nvdiffrast --demo | ||
|
||
# Now install additional Python packages | ||
# These ones work inside the builder | ||
RUN conda run -n base pip install diso | ||
RUN conda run -n base pip install plyfile utils3d flash_attn spconv-cu120 xformers onnxscript | ||
RUN conda run -n base pip install kaolin -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.4.0_cu121.html | ||
RUN conda run -n base pip install git+https://github.com/NVlabs/nvdiffrast.git | ||
|
||
# Remove downloaded packages from conda and pip | ||
RUN conda clean --all -f -y | ||
RUN pip cache purge | ||
|
||
# Deduplicate with rdfind | ||
# This reduces the size of the image by a few hundred megs. | ||
RUN rdfind -makesymlinks true /opt/conda | ||
|
||
# Final stage | ||
FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-devel AS final | ||
|
||
WORKDIR /app | ||
COPY --from=builder /usr/local/bin/gxx-wrapper /usr/local/bin/gxx-wrapper | ||
COPY --from=builder /opt/conda /opt/conda | ||
COPY --from=builder /root /root | ||
COPY --from=builder /app /app | ||
|
||
# Reinstall any runtime tools needed | ||
# git and build-essential are needed for post_install.sh script. | ||
# vim and strace are useful for debugging, remove those if you want to. | ||
RUN apt update && \ | ||
apt upgrade && \ | ||
apt install -y build-essential \ | ||
git \ | ||
strace \ | ||
vim && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# install these last, so we can experiment without excessive build times. | ||
COPY trellis /app/trellis | ||
COPY app.py /app/app.py | ||
COPY example.py /app/example.py | ||
COPY extensions /app/extensions | ||
COPY assets /app/assets | ||
COPY onstart.sh /app/onstart.sh | ||
COPY post_install.sh /app/post_install.sh | ||
|
||
ENV PATH=/opt/conda/bin:$PATH | ||
|
||
# This script runs the post_install steps | ||
|
||
# If you're pushing to a container registry, let this run once, run some | ||
# tests, then do `docker commit` to save the models along with the image. | ||
# This will ensure that it won't fail at runtime due to models being | ||
# unavailable, or network restrictions. | ||
CMD ["bash", "/app/onstart.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
cd /app | ||
|
||
echo "Doing post install steps" | ||
./post_install.sh | ||
|
||
export CXX=/usr/local/bin/gxx-wrapper | ||
|
||
echo "Launching app" | ||
python3 app.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Check if post-install steps have already been run | ||
if [ -f /app/.post_install_done ]; then | ||
echo "Post-install steps already completed." | ||
exit 0 | ||
fi | ||
|
||
cd /app | ||
|
||
echo "Install stuff that couldn't be installed without GPU" | ||
# Run the demo setup | ||
conda run -n base ./setup.sh --mipgaussian --diffoctreerast | ||
|
||
echo "Proving it actually works..." | ||
|
||
export CXX=/usr/local/bin/gxx-wrapper | ||
python example.py | ||
|
||
# Mark completion | ||
touch /app/.post_install_done | ||
|
||
echo "Post-install steps completed successfully." | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe missing a
-y
option here inapt upgrade
? Otherwise docker will fail:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof! Yes I added this without testing it. You wouldn't believe how many times I've rebuilt this image! Thanks :)