diff --git a/Dockerfile b/Dockerfile index 6cd4e058f0..6e46f74d1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 @@ -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"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000000..b5563cbc4b --- /dev/null +++ b/compose.yaml @@ -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] diff --git a/docs/quickstart/installation.md b/docs/quickstart/installation.md index de79064213..70b1626840 100644 --- a/docs/quickstart/installation.md +++ b/docs/quickstart/installation.md @@ -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.