|
| 1 | +FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-devel AS builder |
| 2 | + |
| 3 | +# Install build dependencies |
| 4 | +RUN apt-get update && \ |
| 5 | + apt-get install -y ffmpeg build-essential git rdfind |
| 6 | + |
| 7 | +WORKDIR /app |
| 8 | +ADD trellis /app/trellis |
| 9 | +ADD setup.sh /app/setup.sh |
| 10 | +ADD app.py /app/app.py |
| 11 | +ADD example.py /app/example.py |
| 12 | +ADD extensions /app/extensions |
| 13 | +ADD assets /app/assets |
| 14 | + |
| 15 | +# Setup conda |
| 16 | +RUN conda config --set always_yes true && \ |
| 17 | + conda init && \ |
| 18 | + conda config --add channels defaults |
| 19 | + |
| 20 | +# Use bash shell so we can source activate |
| 21 | +SHELL ["/bin/bash", "-c"] |
| 22 | + |
| 23 | + |
| 24 | +RUN conda install torchvision=0.19.0 \ |
| 25 | + onnx==1.17.0 \ |
| 26 | + pytorch=2.4.0 \ |
| 27 | + pytorch-cuda=12.4 \ |
| 28 | + --force-reinstall \ |
| 29 | + -c pytorch \ |
| 30 | + -c nvidia |
| 31 | + |
| 32 | +# Create a g++ wrapper for JIT, since the include dirs are passed with -i rather than -I for some reason |
| 33 | +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 && \ |
| 34 | + chmod +x /usr/local/bin/gxx-wrapper |
| 35 | +ENV CXX=/usr/local/bin/gxx-wrapper |
| 36 | + |
| 37 | + |
| 38 | +# Run setup.sh - this won't install all the things due to missing GPU in the builder |
| 39 | +RUN conda run -n base ./setup.sh --basic --xformers --flash-attn --diffoctreerast --vox2seq --spconv --mipgaussian --kaolin --nvdiffrast --demo |
| 40 | + |
| 41 | +# Now install additional Python packages |
| 42 | +# These ones work inside the builder |
| 43 | +RUN conda run -n base pip install diso |
| 44 | +RUN conda run -n base pip install plyfile utils3d flash_attn spconv-cu120 xformers |
| 45 | +RUN conda run -n base pip install kaolin -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.4.0_cu121.html |
| 46 | +RUN conda run -n base pip install git+https://github.com/NVlabs/nvdiffrast.git |
| 47 | + |
| 48 | +# Remove downloaded packages from conda and pip |
| 49 | +RUN conda clean --all -f -y |
| 50 | +RUN pip cache purge |
| 51 | + |
| 52 | +# Deduplicate with rdfind |
| 53 | +# This reduces the size of the image by a few hundred megs. |
| 54 | +RUN rdfind -makesymlinks true /opt/conda |
| 55 | + |
| 56 | +# Final stage |
| 57 | +FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-devel AS final |
| 58 | + |
| 59 | +WORKDIR /app |
| 60 | +COPY --from=builder /usr/local/bin/gxx-wrapper /usr/local/bin/gxx-wrapper |
| 61 | +COPY --from=builder /opt/conda /opt/conda |
| 62 | +COPY --from=builder /root /root |
| 63 | +COPY --from=builder /app /app |
| 64 | + |
| 65 | +# Reinstall any runtime tools needed |
| 66 | +# git and build-essential are needed for post_install.sh script. |
| 67 | +# vim and strace are useful for debugging, remove those if you want to. |
| 68 | +RUN apt-get update && \ |
| 69 | + apt-get install -y build-essential \ |
| 70 | + git \ |
| 71 | + strace \ |
| 72 | + vim && \ |
| 73 | + rm -rf /var/lib/apt/lists/* |
| 74 | + |
| 75 | +# install these last, so we can experiment without excessive build times. |
| 76 | +COPY onstart.sh /app/onstart.sh |
| 77 | +COPY post_install.sh /app/post_install.sh |
| 78 | + |
| 79 | +ENV PATH=/opt/conda/bin:$PATH |
| 80 | + |
| 81 | +# This script runs the post_install steps |
| 82 | + |
| 83 | +# If you're pushing to a container registry, let this run once, run some |
| 84 | +# tests, then do `docker commit` to save the models along with the image. |
| 85 | +# This will ensure that it won't fail at runtime due to models being |
| 86 | +# unavailable, or network restrictions. |
| 87 | +CMD ["/app/onstart.sh"] |
| 88 | + |
0 commit comments