Skip to content
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

Added docker & docker-compose to the project #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ datasets/t2*
split_files/

# Outputs.
results_*/
results_*/

images/
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM pytorch/pytorch:2.5.1-cuda11.8-cudnn9-devel

WORKDIR /workspace

RUN apt-get update && \
apt-get install wget -y && \
apt-get install git -y

# Install Miniconda
RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you maybe be able to consider using a free conda implementation? E.g. Miniforge from conda-forge?

It's hard to predict what will happen to the permissiveness of Anaconda products: https://www.theregister.com/2024/08/08/anaconda_puts_the_squeeze_on/

If not, please add an echo or some sort of warning for users to check Anaconda's licensing terms.
Thanks!


RUN git clone https://github.com/nianticlabs/acezero --recursive

RUN conda install ipykernel

#Create ace0 env
RUN cd acezero && \
conda env create -f environment.yml

RUN echo "source activate ace0" > ~/.bashrc && \
conda run -n ace0 pip install ipykernel && \
conda install -n ace0 -c conda-forge libstdcxx-ng && \
/opt/conda/envs/ace0/bin/python -m ipykernel install --user --name=ace0

RUN cd acezero/dsacstar && \
conda run -n ace0 python setup.py install

#Install ace0 deps
RUN apt-get install -y libnvidia-egl-wayland1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Could you please combine as many apt-get calls as possible to a single RUN layer? See also https://docs.docker.com/build/building/best-practices/#apt-get

In general, it's good to have fewer RUN lines, and group instructions with && \ at the end. This allows the layer to not contain changes that would be undone in a consecutive command, and will result in smaller Docker images that are easier to carry around.

RUN apt-get install -y xvfb mesa-utils
RUN apt-get install -y libgl1-mesa-glx libgl1-mesa-dri
ENV DISPLAY=:99
RUN Xvfb :99 -screen 0 1024x768x24 & export DISPLAY=:99

# Install nerfstudio
RUN conda create --name nerfstudio -y python=3.8

RUN conda run -n nerfstudio pip install --upgrade pip

RUN conda run -n nerfstudio pip install torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118

RUN conda run -n nerfstudio conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit

ENV TCNN_CUDA_ARCHITECTURES="50;52;60;61;70;75;80;86"

RUN conda run -n nerfstudio pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

RUN conda run -n nerfstudio pip install nerfstudio

RUN apt-get install -y libglib2.0-0

RUN conda run -n nerfstudio ns-install-cli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these RUNs up to L40 could be combined (or if not, very few splits would be needed). See advice from the Docker blog:

At a high level, it works by analyzing the layers of a Docker image. With every layer you add, more space will be taken up by the image. Or you can say each line in the Dockerfile (like a separate RUN instruction) adds a new layer to your image.
(source: https://www.docker.com/blog/reduce-your-image-size-with-the-dive-in-docker-extension/)

RUN apt-get install -y libglib2.0-0  # TODO: merge with earlier ones

ENV TCNN_CUDA_ARCHITECTURES="50;52;60;61;70;75;80;86" # consider making an export if it's not needed for the final image

RUN && \
  conda create --name nerfstudio -y python=3.8 && \
  conda run -n nerfstudio pip install --upgrade pip && \
  conda run -n nerfstudio pip install "torch==2.1.2+cu118" "torchvision==0.16.2+cu118" --extra-index-url https://download.pytorch.org/whl/cu118 && \
  conda run -n nerfstudio conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit && \
  conda run -n nerfstudio pip install ninja "git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch" && \
  conda run -n nerfstudio pip install nerfstudio && \
  conda run -n nerfstudio ns-install-cli


WORKDIR /workspace/acezero
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ See [this link](https://github.com/isl-org/ZoeDepth) for its license and details
ACE0 uses that model to estimate the depth for the seed images.
It can be replaced, please see the [FAQ](#frequently-asked-questions) section below for details.

## Docker

If you would prefer to run Ace0 in a docker container, you can start it with:

```shell
docker-compose up -d
```

You can then shell into the container with the following command:

```shell
docker exec -it acezero /bin/bash
```

From there you can follow the Gaussian Splatting tutorial described at the bottom of the README [here.](#frequently-asked-questions) Make sure to add your images to the volume defined in ```docker-compose.yml```

## Usage

We explain how to run ACE0 to reconstruct images from scratch, with and without knowledge about the image intrinsics.
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.8"

services:
acezero:
restart: always
container_name: acezero
build:
context: .
dockerfile: Dockerfile
tty: true
stdin_open: true
ports:
- "7771:7007"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: make this the default "7007:7007" or closer to it, e.g. "7008:7007"

volumes:
- ./images:/workspace/images
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: remove this, it's not needed for the final container (unless I'm mistaken)

deploy:
resources:
reservations:
devices:
- driver: 'nvidia'
count: all
capabilities: [gpu]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually use docker run --gpus='all,"capabilities=compute,utility,graphics"' ..., now that might not be the most up to date way, but I think capabilities=all would be nice to have, see also here: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#driver-capabilities

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the docker-compose docs recommend using capabilities: [gpu] for docker-compose files

https://docs.docker.com/compose/how-tos/gpu-support/

extra_hosts:
- "host.docker.internal:host-gateway"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: put a comment above explaining what this does and why it's needed.