From 3f612e5a5942d9c7a12eb30e1d17ea3770669a54 Mon Sep 17 00:00:00 2001 From: Maksym Ostapenko Date: Tue, 25 Mar 2025 18:44:35 +0100 Subject: [PATCH] Added dockerfile and description how to use it. --- Dockerfile | 31 +++++++++++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..065377e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 + +# Set the timezone +ENV TZ Europe/Berlin +ARG DEBIAN_FRONTEND noninteractive + +# Update the system timezone +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Set the working directory inside the container +ENV APP_WORKDIR /home/depth_estimation +WORKDIR $APP_WORKDIR + +RUN apt update -y && apt upgrade -y +RUN apt-get install libopenblas-dev liblapack-dev -y + +# needed for cv2 +RUN apt-get install ffmpeg libsm6 libxext6 -y + +# install pip +RUN apt install python3-pip -y +RUN python3 -m pip install --upgrade setuptools pip wheel + +COPY ./requirements.txt $APP_WORKDIR/requirements.txt + +# Install UniDepth and dependencies +RUN pip3 install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118 + +EXPOSE 80 + +CMD ["/bin/bash"] diff --git a/README.md b/README.md index 3114098..63e2b94 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ Requirements are not in principle hard requirements, but there might be some dif - Python 3.10+ - CUDA 11.8+ + +### Local installation Install the environment needed to run UniDepth with: ```shell export VENV_DIR= @@ -102,6 +104,32 @@ If everything runs correctly, `demo.py` should print: `ARel: 7.45%`. If you encounter `Segmentation Fault` after running the demo, you may need to uninstall torch via pip (`pip uninstall torch`) and install the torch version present in [requirements](requirements.txt) with `conda`. + +### Installation with Docker + +Make sure that you have installed [Docker]() and [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). + +First, build the image: +```shell +docker build -t unidepth_image . +``` + +Second, run the container: +```shell +docker run -it --gpus all \ + --name unidepth_container_1 \ + -v "$(pwd):/home/depth_estimation" \ + unidepth_image +``` + +Run the example inside of the containner: +```shell +# move the target file to the project root +mv ./scripts/demo.py . +# run the demo +python3 demo.py +``` + ## Get Started After installing the dependencies, you can load the pre-trained models easily from [Hugging Face](https://huggingface.co/models?other=UniDepth) as follows: