Skip to content

add compose.yaml for docker compose #3657

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ ARG CUDA_ARCHITECTURES="90;89;86;80;75;70;61"
ARG NERFSTUDIO_VERSION=""

# Pull source either provided or from git.
FROM scratch as source_copy
FROM scratch AS source_copy
ONBUILD COPY . /tmp/nerfstudio
FROM alpine/git as source_no_copy
FROM alpine/git AS source_no_copy
ARG NERFSTUDIO_VERSION
ONBUILD RUN git clone --branch ${NERFSTUDIO_VERSION} --recursive https://github.com/nerfstudio-project/nerfstudio.git /tmp/nerfstudio
ARG NERFSTUDIO_VERSION
FROM source_${NERFSTUDIO_VERSION:+no_}copy as source
FROM source_${NERFSTUDIO_VERSION:+no_}copy AS source

FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} as builder
FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} AS builder
ARG CUDA_ARCHITECTURES
ARG NVIDIA_CUDA_VERSION
ARG UBUNTU_VERSION
Expand Down Expand Up @@ -109,15 +109,15 @@ RUN chmod -R go=u /usr/local/lib/python3.10 && \
#
# Docker runtime stage.
#
FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} as runtime
FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS runtime
ARG CUDA_ARCHITECTURES
ARG NVIDIA_CUDA_VERSION
ARG UBUNTU_VERSION

LABEL org.opencontainers.image.source = "https://github.com/nerfstudio-project/nerfstudio"
LABEL org.opencontainers.image.licenses = "Apache License 2.0"
LABEL org.opencontainers.image.source="https://github.com/nerfstudio-project/nerfstudio"
LABEL org.opencontainers.image.licenses="Apache License 2.0"
LABEL org.opencontainers.image.base.name="docker.io/library/nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}"
LABEL org.opencontainers.image.documentation = "https://docs.nerf.studio/"
LABEL org.opencontainers.image.documentation="https://docs.nerf.studio/"

# Minimal dependencies to run COLMAP binary compiled in the builder stage.
# Note: this reduces the size of the final image considerably, since all the
Expand Down Expand Up @@ -152,4 +152,4 @@ COPY --from=builder /usr/local/bin/ns* /usr/local/bin/
RUN /bin/bash -c 'ns-install-cli --mode install'

# Bash as default entrypoint.
CMD /bin/bash -l
CMD ["/bin/bash", "-l"]
22 changes: 22 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
nerfstudio:
#image: ghcr.io/nerfstudio-project/nerfstudio:latest
# If you want to build from the source code, please delete image: directive and use the build: directive following
build:
context: .
dockerfile: Dockerfile
hostname: nerfstudio
shm_size: 12gb
ports:
- 7007:7007
volumes:
- ./workspace:/workspace/
- ./cache:/home/user/.cache/
stdin_open: true
tty: true
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [gpu]
10 changes: 10 additions & 0 deletions docs/quickstart/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ docker run --gpus all \ # Give the conta
nerfstudio # Docker image tag if you built the image from the Dockerfile by yourself using the command from above.
```

You can also start an interactive terminal with [docker compose](https://docs.docker.com/compose/) by taking the following steps.

```
docker compose up -d # Start the server
docker compose exec nerfstudio bash # Start the shell
docker compose down # Stop the server
```

Docker compose fetches the latest image from the Internet by default. If you want to build it from the source code or apply custom settings, please edit compose.yaml and restart the server.

### Call nerfstudio commands directly

Besides, the container can also directly be used by adding the nerfstudio command to the end.
Expand Down