From 15275d9aa0e3c80fc2ca6fcc75749e3345e3b32f Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 22 Oct 2021 13:03:48 -0400 Subject: [PATCH] Update start-dev-env.sh, OpenMVS --- SuperBuild/cmake/External-OpenMVS.cmake | 2 +- gpu.Dockerfile | 5 +++-- opendm/gpu.py | 1 + start-dev-env.sh | 22 +++++++++++++++++++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/SuperBuild/cmake/External-OpenMVS.cmake b/SuperBuild/cmake/External-OpenMVS.cmake index 28655903..be60a22b 100644 --- a/SuperBuild/cmake/External-OpenMVS.cmake +++ b/SuperBuild/cmake/External-OpenMVS.cmake @@ -25,7 +25,7 @@ ExternalProject_Add(${_proj_name} #--Download step-------------- DOWNLOAD_DIR ${SB_DOWNLOAD_DIR} GIT_REPOSITORY https://github.com/OpenDroneMap/openMVS - GIT_TAG 256 + GIT_TAG 266 #--Update/Patch step---------- UPDATE_COMMAND "" #--Configure step------------- diff --git a/gpu.Dockerfile b/gpu.Dockerfile index 57ef312f..b96f4c94 100644 --- a/gpu.Dockerfile +++ b/gpu.Dockerfile @@ -1,4 +1,4 @@ -FROM nvidia/cuda:11.2.0-runtime-ubuntu20.04 AS builder +FROM nvidia/cuda:11.2.0-devel-ubuntu20.04 AS builder # Env variables ENV DEBIAN_FRONTEND=noninteractive \ @@ -21,7 +21,8 @@ RUN bash configure.sh clean ### Use a second image for the final asset to reduce the number and # size of the layers. -FROM nvidia/cuda:11.2.0-runtime-ubuntu20.04 +#FROM nvidia/cuda:11.2.0-runtime-ubuntu20.04 +FROM nvidia/cuda:11.2.0-devel-ubuntu20.04 # Env variables ENV DEBIAN_FRONTEND=noninteractive \ diff --git a/opendm/gpu.py b/opendm/gpu.py index ae3bb59d..439f46a4 100644 --- a/opendm/gpu.py +++ b/opendm/gpu.py @@ -21,3 +21,4 @@ def has_gpus(): return len(platforms) > 0 except Exception as e: return False + diff --git a/start-dev-env.sh b/start-dev-env.sh index 2b310818..75c7ccbf 100755 --- a/start-dev-env.sh +++ b/start-dev-env.sh @@ -23,6 +23,7 @@ if [ "$1" = "--setup" ]; then echo "Adding $2 to /etc/shadow" echo "$2:x:14871::::::" >> /etc/shadow echo "$2 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + echo "odm ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers echo "echo '' && echo '' && echo '' && echo '###################################' && echo 'ODM Dev Environment Ready. Hack on!' && echo '###################################' && echo '' && cd /code" > $HOME/.bashrc # Install qt creator @@ -81,12 +82,20 @@ fi if hash docker 2>/dev/null; then has_docker="YES" fi +if hash nvidia-smi 2>/dev/null; then + has_nvidia_smi="YES" +fi + if [ "$has_docker" != "YES" ]; then echo "You need to install docker before running this script." exit 1 fi +IMAGE_SET=NO +if [[ ! -z $IMAGE ]]; then + IMAGE_SET=YES +fi export PORT="${PORT:=3000}" export QTC="${QTC:=NO}" export IMAGE="${IMAGE:=opendronemap/nodeodm}" @@ -119,11 +128,18 @@ fi USER_ID=$(id -u) GROUP_ID=$(id -g) USER=$(id -un) -GPU_FLAG="" +GPU_FLAGS="" if [[ "$GPU" != "NO" ]]; then - GPU_FLAG="--gpus all" + if [[ "$IMAGE_SET" = "NO" ]]; then + IMAGE="$IMAGE:gpu" + fi + + GPU_FLAGS="--gpus all" + if [[ "$has_nvidia_smi" = "YES" ]]; then + GPU_FLAGS="$GPU_FLAGS --device /dev/nvidia0 --device /dev/nvidia-uvm --device /dev/nvidia-uvm-tools --device /dev/nvidia-modeset --device /dev/nvidiactl" + fi fi xhost + || true -docker run -ti --entrypoint bash --name odmdev -v $(pwd):/code -v "$DATA":/datasets -p $PORT:3000 $GPU_FLAG --privileged -e DISPLAY -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" -v="$HOME/.odm-dev-home:/home/$USER" $IMAGE -c "/code/start-dev-env.sh --setup $USER $USER_ID $GROUP_ID $QTC" +docker run -ti --entrypoint bash --name odmdev --user root -v $(pwd):/code -v "$DATA":/datasets -p $PORT:3000 $GPU_FLAGS --privileged -e DISPLAY -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" -v="$HOME/.odm-dev-home:/home/$USER" $IMAGE -c "/code/start-dev-env.sh --setup $USER $USER_ID $GROUP_ID $QTC" exit 0