From 960d35c4926a3cf2c776e751b202e1a35c050fbe Mon Sep 17 00:00:00 2001 From: caiobarrosvfs Date: Sun, 6 Oct 2024 22:30:49 -0300 Subject: [PATCH] Add docker to the repository --- .vscode/settings.json | 7 +++ README.md | 13 ++++++ docker/Dockerfile | 70 +++++++++++++++++++++++++++++ docker/build_gaussian_pro_docker.sh | 1 + docker/entrypoint.sh | 18 ++++++++ docker/environment.yml | 16 +++++++ docker/run_gaussian_pro_docker.sh | 4 ++ 7 files changed, 129 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 docker/Dockerfile create mode 100644 docker/build_gaussian_pro_docker.sh create mode 100755 docker/entrypoint.sh create mode 100644 docker/environment.yml create mode 100644 docker/run_gaussian_pro_docker.sh diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6d56bc3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#22312D", + "titleBar.activeBackground": "#30443F", + "titleBar.activeForeground": "#F8FAF9" + } +} \ No newline at end of file diff --git a/README.md b/README.md index 23fa6b4..591a079 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,19 @@ pip install ./submodules/Propagation ``` +#### Docker install + +To build the GaussianPro using docker, execute the following commands: +```bash +sh docker/build_gaussian_pro_docker.sh +``` + +To execute the container, run: +```bash +# Please remember to substitute the dataset path to your desired path +sh docker/run_gaussian_pro_docker.sh +``` + #### Download the demo Waymo scene: Segment-102751 ``` wget https://drive.google.com/file/d/1DXQRBcUIrnIC33WNq8pVLKZ_W1VwON3k/view?usp=sharing diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f75dd93 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,70 @@ +# Use an official CUDA runtime as the base image +FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04 + +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive \ + CONDA_DIR=/opt/conda \ + CUDA_HOME=/usr/local/cuda \ + TORCH_CUDA_ARCH_LIST="7.5" + +# Add Conda to PATH +ENV PATH=$CONDA_DIR/bin:$PATH + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + wget \ + build-essential \ + libgl1-mesa-glx \ + libglib2.0-0 \ + python3-dev \ + python3-pip \ + && rm -rf /var/lib/apt/lists/* + +# Install Miniconda +RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \ + bash /tmp/miniconda.sh -b -p $CONDA_DIR && \ + rm /tmp/miniconda.sh && \ + $CONDA_DIR/bin/conda clean -afy + +# Initialize Conda +RUN $CONDA_DIR/bin/conda init bash + +# Clone the GaussianPro repository +RUN git clone https://github.com/kcheng1021/GaussianPro.git --recursive + +# Set the working directory +WORKDIR /GaussianPro + +# Copy environment.yml into the Docker image +COPY environment.yml . + +# Create the Conda environment and install additional packages +# RUN /opt/conda/bin/conda env create -f environment.yml + +# Activate the environment +RUN echo "source /opt/conda/etc/profile.d/conda.sh" >> /root/.bashrc && \ + echo "conda activate gaussianpro" >> /root/.bashrc + +# Create the Conda environment, install packages, and clean up in one RUN command +RUN /bin/bash -c "source $CONDA_DIR/etc/profile.d/conda.sh && \ + conda env create -f environment.yml && \ + conda activate gaussianpro && \ + conda install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.6 -c pytorch -c conda-forge && \ + pip install --upgrade pip && \ + pip install ./submodules/Propagation && \ + pip install ./submodules/diff-gaussian-rasterization && \ + pip install ./submodules/simple-knn && \ + conda clean -afy" + +# Copy the entrypoint script into the Docker image +COPY entrypoint.sh /entrypoint.sh + +# Make the entrypoint script executable +RUN chmod +x /entrypoint.sh + +# Set the entrypoint to the script that activates the Conda environment +ENTRYPOINT ["/entrypoint.sh"] + +# Set the default command to bash to keep the container running +CMD ["/bin/bash"] diff --git a/docker/build_gaussian_pro_docker.sh b/docker/build_gaussian_pro_docker.sh new file mode 100644 index 0000000..f584623 --- /dev/null +++ b/docker/build_gaussian_pro_docker.sh @@ -0,0 +1 @@ +docker build --no-cache -t gaussian-pro . \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..5fbfe79 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +echo "Initializing Conda..." +source /opt/conda/etc/profile.d/conda.sh + +echo "Activating Conda environment 'gaussianpro'..." +conda activate gaussianpro + +echo "Conda environment activated: $(conda info --envs | grep '*' )" + +if [ "$#" -gt 0 ]; then + echo "Executing command: $@" + exec "$@" +else + echo "Starting interactive bash shell..." + exec bash +fi diff --git a/docker/environment.yml b/docker/environment.yml new file mode 100644 index 0000000..3e4f225 --- /dev/null +++ b/docker/environment.yml @@ -0,0 +1,16 @@ +name: gaussianpro +channels: + - pytorch + - conda-forge + - defaults +dependencies: + - cudatoolkit=11.7 + - plyfile=0.8.1 + - python=3.7.13 + - pip=22.3.1 + - tqdm + - ninja + - opencv-python=4.10.0.84 + - matplotlib=3.5.3 + - open3d=0.17.0 + - imageio=2.31.2 diff --git a/docker/run_gaussian_pro_docker.sh b/docker/run_gaussian_pro_docker.sh new file mode 100644 index 0000000..0e84c9c --- /dev/null +++ b/docker/run_gaussian_pro_docker.sh @@ -0,0 +1,4 @@ +docker run --rm --gpus all -it \ + --entrypoint /bin/bash \ + -v your_dataset_path:/GaussianPro/datasets \ + gaussian-pro