diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 4823dd721..9e6d21a87 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -10,6 +10,14 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +# find_package(CUDA REQUIRED) +# if (CUDA_FOUND) +# message(STATUS "CUDA found at: ${CUDA_PATH}") +# else() +# message(FATAL_ERROR "CUDA not found. Please install CUDA and set the CUDA_PATH environment variable.") +# endif() + + if (APPLE) find_program(HOMEBREW_EXECUTABLE brew) mark_as_advanced(FORCE HOMEBREW_EXECUTABLE) @@ -108,9 +116,9 @@ if (WIN32) file(GLOB COPY_DLLS "${VCPKG_ROOT}/installed/x64-windows/bin/*.dll") file(COPY ${COPY_DLLS} DESTINATION "${SB_INSTALL_DIR}/bin") - message("Copying CUDA DLLs...") - file(GLOB CUDA_DLLS "$ENV{CUDA_PATH}/bin/cudart64*.dll") - file(COPY ${CUDA_DLLS} DESTINATION "${SB_INSTALL_DIR}/bin") +# message("Copying CUDA DLLs...") +# file(GLOB CUDA_DLLS "$ENV{CUDA_PATH}/bin/cudart64*.dll") +# file(COPY ${CUDA_DLLS} DESTINATION "${SB_INSTALL_DIR}/bin") set(WIN32_GDAL_ARGS -DGDAL_FOUND=TRUE -DGDAL_LIBRARY=${GDAL_LIBRARY} -DGDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR}) elseif(APPLE) @@ -209,6 +217,11 @@ else() set(POISSON_BUILD_CMD COMPILER=${CMAKE_CXX_COMPILER} make -j${nproc} -f Makefile.macos poissonrecon) endif() endif() + +add_custom_target(build_poissonrecon ALL + DEPENDS poissonrecon +) + externalproject_add(poissonrecon GIT_REPOSITORY https://github.com/OpenDroneMap/PoissonRecon.git GIT_TAG 290 diff --git a/SuperBuild/cmake/External-OpenMVS.cmake b/SuperBuild/cmake/External-OpenMVS.cmake index cad212f9d..210da4732 100644 --- a/SuperBuild/cmake/External-OpenMVS.cmake +++ b/SuperBuild/cmake/External-OpenMVS.cmake @@ -31,8 +31,8 @@ endif() SET(GPU_CMAKE_ARGS "") if(UNIX) - if (EXISTS "/usr/local/cuda/lib64/stubs") - SET(GPU_CMAKE_ARGS -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs) + if (EXISTS "/usr/local/cuda/lib64") + SET(GPU_CMAKE_ARGS -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64) endif() endif() diff --git a/SuperBuild/cmake/External-PyPopsift.cmake b/SuperBuild/cmake/External-PyPopsift.cmake index 224ccc63f..ab81dbfee 100644 --- a/SuperBuild/cmake/External-PyPopsift.cmake +++ b/SuperBuild/cmake/External-PyPopsift.cmake @@ -1,36 +1,42 @@ set(_SB_BINARY_DIR "${SB_BINARY_DIR}/pypopsift") +set(YOUR_GPU_COMPUTE_CAPABILITY 86) # Pypopsift -find_package(CUDA 7.0) +find_package(CUDA) -if(CUDA_FOUND) - ExternalProject_Add(pypopsift - DEPENDS opensfm - PREFIX ${_SB_BINARY_DIR} - TMP_DIR ${_SB_BINARY_DIR}/tmp - STAMP_DIR ${_SB_BINARY_DIR}/stamp - #--Download step-------------- - DOWNLOAD_DIR ${SB_DOWNLOAD_DIR} - GIT_REPOSITORY https://github.com/OpenDroneMap/pypopsift - GIT_TAG 288 - #--Update/Patch step---------- - UPDATE_COMMAND "" - #--Configure step------------- - SOURCE_DIR ${SB_SOURCE_DIR}/pypopsift - CMAKE_ARGS - -DOUTPUT_DIR=${SB_INSTALL_DIR}/bin/opensfm/opensfm - -DCMAKE_INSTALL_PREFIX=${SB_INSTALL_DIR} - ${WIN32_CMAKE_ARGS} - ${ARM64_CMAKE_ARGS} - #--Build step----------------- - BINARY_DIR ${_SB_BINARY_DIR} - #--Install step--------------- - INSTALL_DIR ${SB_INSTALL_DIR} - #--Output logging------------- - LOG_DOWNLOAD OFF - LOG_CONFIGURE OFF - LOG_BUILD OFF - ) -else() - message(WARNING "Could not find CUDA >= 7.0") -endif() \ No newline at end of file +if (CUDA_VERSION VERSION_LESS 7.0) + message(FATAL_ERROR "CUDA version ${CUDA_VERSION} is too old. Requires CUDA 7.0 or later.") +endif() + +# if(CUDA_FOUND) +# ExternalProject_Add(pypopsift +# DEPENDS opensfm +# PREFIX ${_SB_BINARY_DIR} +# TMP_DIR ${_SB_BINARY_DIR}/tmp +# STAMP_DIR ${_SB_BINARY_DIR}/stamp +# #--Download step-------------- +# DOWNLOAD_DIR ${SB_DOWNLOAD_DIR} +# GIT_REPOSITORY https://github.com/OpenDroneMap/pypopsift +# GIT_TAG 288 +# #--Update/Patch step---------- +# UPDATE_COMMAND "" +# #--Configure step------------- +# SOURCE_DIR ${SB_SOURCE_DIR}/pypopsift +# CMAKE_ARGS +# -DCUDA_NVCC_FLAGS="-gencode arch=compute_${YOUR_GPU_COMPUTE_CAPABILITY}, code=sm_${YOUR_GPU_COMPUTE_CAPABILITY}" # Add this line +# -DOUTPUT_DIR=${SB_INSTALL_DIR}/bin/opensfm/opensfm +# -DCMAKE_INSTALL_PREFIX=${SB_INSTALL_DIR} +# ${WIN32_CMAKE_ARGS} +# ${ARM64_CMAKE_ARGS} +# #--Build step----------------- +# BINARY_DIR ${_SB_BINARY_DIR} +# #--Install step--------------- +# INSTALL_DIR ${SB_INSTALL_DIR} +# #--Output logging------------- +# LOG_DOWNLOAD OFF +# LOG_CONFIGURE OFF +# LOG_BUILD OFF +# ) +# else() +# message(WARNING "Could not find CUDA >= 7.0") +# endif() \ No newline at end of file diff --git a/configure.sh b/configure.sh index 68e079029..72ad549b5 100755 --- a/configure.sh +++ b/configure.sh @@ -3,50 +3,56 @@ # Ensure the DEBIAN_FRONTEND environment variable is set for apt-get calls APT_GET="env DEBIAN_FRONTEND=noninteractive $(command -v apt-get)" -check_version(){ - UBUNTU_VERSION=$(lsb_release -r) - case "$UBUNTU_VERSION" in - *"20.04"*|*"21.04"*) - echo "Ubuntu: $UBUNTU_VERSION, good!" - ;; - *"18.04"*|*"16.04"*) - echo "ODM 2.1 has upgraded to Ubuntu 21.04, but you're on $UBUNTU_VERSION" - echo "* The last version of ODM that supports Ubuntu 16.04 is v1.0.2." - echo "* The last version of ODM that supports Ubuntu 18.04 is v2.0.0." - echo "We recommend you to upgrade, or better yet, use docker." - exit 1 - ;; +check_version() { + UBUNTU_VERSION=$(lsb_release -r) + case "$UBUNTU_VERSION" in + *"20.04"* | *"21.04"*) + echo "Ubuntu: $UBUNTU_VERSION, good!" + ;; + *"18.04"* | *"16.04"*) + echo "ODM 2.1 has upgraded to Ubuntu 21.04, but you're on $UBUNTU_VERSION" + echo "* The last version of ODM that supports Ubuntu 16.04 is v1.0.2." + echo "* The last version of ODM that supports Ubuntu 18.04 is v2.0.0." + echo "We recommend you to upgrade, or better yet, use docker." + exit 1 + ;; *) - echo "You are not on Ubuntu 21.04 (detected: $UBUNTU_VERSION)" - echo "It might be possible to run ODM on a newer version of Ubuntu, however, you cannot rely on this script." - exit 1 - ;; - esac + echo "You are not on Ubuntu 21.04 (detected: $UBUNTU_VERSION)" + echo "It might be possible to run ODM on a newer version of Ubuntu, however, you cannot rely on this script." + exit 1 + ;; + esac } -if [[ $2 =~ ^[0-9]+$ ]] ; then +if [[ $2 =~ ^[0-9]+$ ]]; then processes=$2 else processes=$(nproc) fi ensure_prereqs() { + set -e export DEBIAN_FRONTEND=noninteractive - if ! command -v sudo &> /dev/null; then + if ! command -v sudo &>/dev/null; then + # apt-key del "7fa2af80" && + # export this_distro="$(cat /etc/os-release | grep '^ID=' | awk -F'=' '{print $2}')" && + # export this_version="$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F'=' '{print $2}' | sed 's/[^0-9]*//g')" && + # apt-key adv --fetch-keys "https://developer.download.nvidia.com/compute/cuda/repos/${this_distro}${this_version}/x86_64/3bf863cc.pub" + echo "Installing sudo" $APT_GET update $APT_GET install -y -qq --no-install-recommends sudo else - sudo $APT_GET update + sudo "$APT_GET" update fi - if ! command -v lsb_release &> /dev/null; then + if ! command -v lsb_release &>/dev/null; then echo "Installing lsb_release" sudo $APT_GET install -y -qq --no-install-recommends lsb-release fi - if ! command -v pkg-config &> /dev/null; then + if ! command -v pkg-config &>/dev/null; then echo "Installing pkg-config" sudo $APT_GET install -y -qq --no-install-recommends pkg-config fi @@ -55,7 +61,7 @@ ensure_prereqs() { sudo $APT_GET install -y -qq tzdata echo "Installing exiftool" - sudo $APT_GET install -y -qq libimage-exiftool-perl + sudo $APT_GET install -y -qq libimage-exiftool-perl UBUNTU_VERSION=$(lsb_release -r) if [[ "$UBUNTU_VERSION" == *"20.04"* ]]; then @@ -65,6 +71,33 @@ ensure_prereqs() { sudo $APT_GET update fi + echo "Install wget" + sudo apt update # Update the package list + sudo apt install -y -qq wget # Install wget + + # echo "Remove the old key" + # sudo rm /etc/apt/trusted.gpg.d/kitware.gpg + + # echo "Add the Kitware repository on Ubuntu 20.04 is to install the kitware-archive-keyring package" + # sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" + # sudo apt update + # sudo apt install kitware-archive-keyring + + echo "Updating cmake" + sudo apt remove --purge --auto-remove cmake + sudo apt update && sudo apt install -y -qq software-properties-common lsb-release && sudo apt clean all + # wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null + # # Add Repository to Sources List + # echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/kitware.list + + # sudo apt-key adv --fetch-keys https://apt.kitware.com/keys/kitware-archive-latest.asc + # sudo apt-key list | grep 1A127079A92F09ED + + # sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" + sudo apt update + sudo apt install -y -qq cmake + apt-get install -y -qq python3-opencv + echo "Installing Python PIP" sudo $APT_GET install -y -qq --no-install-recommends \ python3-pip \ @@ -78,9 +111,9 @@ ensure_prereqs() { installdepsfromsnapcraft() { section="$2" case "$1" in - build) key=build-packages; ;; - runtime) key=stage-packages; ;; - *) key=build-packages; ;; # shouldn't be needed, but it's here just in case + build) key=build-packages ;; + runtime) key=stage-packages ;; + *) key=build-packages ;; # shouldn't be needed, but it's here just in case esac UBUNTU_VERSION=$(lsb_release -r) @@ -89,8 +122,8 @@ installdepsfromsnapcraft() { SNAPCRAFT_FILE="snapcraft21.yaml" fi - cat snap/$SNAPCRAFT_FILE | \ - shyaml get-values-0 parts.$section.$key | \ + cat snap/$SNAPCRAFT_FILE | + shyaml get-values-0 parts."$section".$key | xargs -0 sudo $APT_GET install -y -qq --no-install-recommends } @@ -111,15 +144,15 @@ installruntimedepsonly() { installreqs() { cd /code - + ## Set up library paths export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RUNPATH/SuperBuild/install/lib - ## Before installing + ## Before installing echo "Updating the system" ensure_prereqs check_version - + echo "Installing Required Requisites" installdepsfromsnapcraft build prereqs echo "Installing OpenCV Dependencies" @@ -128,7 +161,7 @@ installreqs() { installdepsfromsnapcraft build opensfm echo "Installing OpenMVS Dependencies" installdepsfromsnapcraft build openmvs - + set -e # edt requires numpy to build @@ -137,45 +170,89 @@ installreqs() { #if [ ! -z "$GPU_INSTALL" ]; then #fi set +e + + installNodeODM + apt-get install -y -qq python3-opencv } - + +installNodeODM() { + #!/bin/bash + set -e + # Install dependencies + sudo apt-get update + apt-get install -y curl gpg-agent ca-certificates + curl --silent --location https://deb.nodesource.com/setup_14.x | bash - + apt-get install -y nodejs + npm --version + apt install -y unzip p7zip-full + sudo apt-get install -y git python3-gdal unzip libvips + # sudo apt install -y -qq npm + npm install -g nodemon + ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && + ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && + ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal + + # Create installation directory + sudo mkdir -p /var/www/NodeODM + sudo chown -R "$USER":"$USER" /var/www/NodeODM + cd /var/www/NodeODM + + # Clone NodeODM repository + git clone https://github.com/OpenDroneMap/NodeODM.git + + # Install Node.js dependencies + cd NodeODM + npm install --production && mkdir -p tmp + + # Create symbolic link for easier access (optional) + # sudo ln -s /var/www/NodeODM/webodm /var/www/html/webodm + + # Configure NodeODM (if needed) + # Edit the settings.yaml file in /var/www/NodeODM/config + + # Start NodeODM + # npm start + # node index.js +} + install() { installreqs - if [ ! -z "$PORTABLE_INSTALL" ]; then - echo "Replacing g++ and gcc with our scripts for portability..." - if [ ! -e /usr/bin/gcc_real ]; then - sudo mv -v /usr/bin/gcc /usr/bin/gcc_real - sudo cp -v ./docker/gcc /usr/bin/gcc - fi - if [ ! -e /usr/bin/g++_real ]; then - sudo mv -v /usr/bin/g++ /usr/bin/g++_real - sudo cp -v ./docker/g++ /usr/bin/g++ - fi - fi + # if [ ! -z "$PORTABLE_INSTALL" ]; then + # echo "Replacing g++ and gcc with our scripts for portability..." + # if [ ! -e /usr/bin/gcc_real ]; then + # sudo mv -v /usr/bin/gcc /usr/bin/gcc_real + # sudo cp -v ./docker/gcc /usr/bin/gcc + # fi + # if [ ! -e /usr/bin/g++_real ]; then + # sudo mv -v /usr/bin/g++ /usr/bin/g++_real + # sudo cp -v ./docker/g++ /usr/bin/g++ + # fi + # fi set -eo pipefail - + echo "Compiling SuperBuild" - cd ${RUNPATH}/SuperBuild + cd "${RUNPATH}"/SuperBuild mkdir -p build && cd build - cmake .. && make -j$processes + cmake .. && make -j"$processes" echo "Configuration Finished" } uninstall() { - check_version + # check_version echo "Removing SuperBuild and build directories" - cd ${RUNPATH}/SuperBuild - rm -rfv build src download install - cd ../ - rm -rfv build + mkdir -p "${RUNPATH}/SuperBuild/build/uninstalled" + # cd "${RUNPATH}"/SuperBuild + # rm -rfv build src download install + # cd ../ + # rm -rfv build } reinstall() { - check_version + # check_version echo "Reinstalling ODM modules" uninstall @@ -184,12 +261,12 @@ reinstall() { clean() { rm -rf \ - ${RUNPATH}/SuperBuild/build \ - ${RUNPATH}/SuperBuild/download \ - ${RUNPATH}/SuperBuild/src + "${RUNPATH}"/SuperBuild/build \ + "${RUNPATH}"/SuperBuild/download \ + "${RUNPATH}"/SuperBuild/src # find in /code and delete static libraries and intermediate object files - find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete + find "${RUNPATH}" -type f -name "*.a" -delete -or -type f -name "*.o" -delete } usage() { @@ -214,7 +291,7 @@ usage() { } if [[ $1 =~ ^(install|installruntimedepsonly|reinstall|uninstall|installreqs|clean)$ ]]; then - RUNPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + RUNPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" "$1" else echo "Invalid instructions." >&2 diff --git a/gpu.Dockerfile b/gpu.Dockerfile index 1c0a8db6c..8169d1ffd 100644 --- a/gpu.Dockerfile +++ b/gpu.Dockerfile @@ -1,9 +1,9 @@ -FROM nvidia/cuda:11.2.2-devel-ubuntu20.04 AS builder +FROM nvidia/cuda:12.2.0-devel-ubuntu20.04 AS builder # Env variables ENV DEBIAN_FRONTEND=noninteractive \ - PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python3.9/dist-packages:/code/SuperBuild/install/lib/python3.8/dist-packages:/code/SuperBuild/install/bin/opensfm" \ - LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib" + PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python3.9/dist-packages:/code/SuperBuild/install/lib/python3.8/dist-packages:/code/SuperBuild/install/bin/opensfm" \ + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib" # Prepare directories WORKDIR /code @@ -15,20 +15,20 @@ COPY . ./ RUN PORTABLE_INSTALL=YES GPU_INSTALL=YES bash configure.sh install # Clean Superbuild -RUN bash configure.sh clean +# RUN bash configure.sh clean ### END Builder ### Use a second image for the final asset to reduce the number and # size of the layers. -FROM nvidia/cuda:11.2.2-runtime-ubuntu20.04 +FROM nvidia/cuda:12.2.0-runtime-ubuntu20.04 #FROM nvidia/cuda:11.2.0-devel-ubuntu20.04 # Env variables ENV DEBIAN_FRONTEND=noninteractive \ - PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python3.9/dist-packages:/code/SuperBuild/install/lib/python3.8/dist-packages:/code/SuperBuild/install/bin/opensfm" \ - LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib" \ - PDAL_DRIVER_PATH="/code/SuperBuild/install/bin" + PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python3.9/dist-packages:/code/SuperBuild/install/lib/python3.8/dist-packages:/code/SuperBuild/install/bin/opensfm" \ + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib" \ + PDAL_DRIVER_PATH="/code/SuperBuild/install/bin" WORKDIR /code @@ -47,4 +47,5 @@ RUN bash configure.sh installruntimedepsonly \ && bash run.sh --help \ && bash -c "eval $(python3 /code/opendm/context.py) && python3 -c 'from opensfm import io, pymap'" # Entry point -ENTRYPOINT ["python3", "/code/run.py"] +# ENTRYPOINT ["python3", "/code/run.py"] +ENTRYPOINT [ "node", "/var/www/NodeODM/NodeODM/index.js" ] diff --git a/stages/stain_segmentation.py b/stages/stain_segmentation.py index 479250184..779a20cc6 100644 --- a/stages/stain_segmentation.py +++ b/stages/stain_segmentation.py @@ -112,7 +112,7 @@ def find_mask(photo_path, masks): # Load stain detection model model = ai.get_model( - "staindetection", "http://localhost:44289/config.json", "v1.0.0" + "staindetection", "http://192.168.13.108:44289/config.json", "v1.0.0" ) if model is None: log.ODM_WARNING( diff --git a/start-dev-env-stain.sh b/start-dev-env-stain.sh index 675c8ea67..af3b7b6e7 100755 --- a/start-dev-env-stain.sh +++ b/start-dev-env-stain.sh @@ -1,6 +1,9 @@ #!/bin/bash set -eo pipefail -__dirname=$(cd $(dirname "$0"); pwd -P) +__dirname=$( + cd $(dirname "$0") + pwd -P +) cd "${__dirname}" if [ "$1" = "--setup" ]; then @@ -9,29 +12,29 @@ if [ "$1" = "--setup" ]; then if [ ! -f .setupdevenv ]; then echo "Recompiling environment... this might take a while." bash configure.sh reinstall - + touch .setupdevenv apt update && apt install -y vim git chown -R $3:$4 /code - chown -R $3:$4 /var/www + mkdir -p /var/www && chown -R $3:$4 /var/www fi echo "Adding $2 to /etc/passwd" - echo "$2:x:$3:$4::/home/$2:/bin/bash" >> /etc/passwd + echo "$2:x:$3:$4::/home/$2:/bin/bash" >>/etc/passwd echo "Adding $2 to /etc/group" - echo "$2:x:$4:" >> /etc/group + echo "$2:x:$4:" >>/etc/group 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 + 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 if hash qtcreator 2>/dev/null; then has_qtcreator="YES" fi - if [ "$has_qtcreator" != "YES" ] && [ "$5" == "YES" ]; then + if [ "$has_qtcreator" != "YES" ] && [ "$5" == "YES" ]; then apt install -y libxrender1 gdb qtcreator fi @@ -39,25 +42,24 @@ if [ "$1" = "--setup" ]; then if [ ! -e "$HOME/liquidprompt" ]; then git clone https://github.com/nojhan/liquidprompt.git --depth 1 $HOME/liquidprompt fi - + if [ -e "$HOME/liquidprompt" ]; then - echo "source $HOME/liquidprompt/liquidprompt" >> $HOME/.bashrc - echo "export LP_PS1_PREFIX='(odmdev)'" >> $HOME/.bashrc + echo "source $HOME/liquidprompt/liquidprompt" >>$HOME/.bashrc + echo "export LP_PS1_PREFIX='(odmdev)'" >>$HOME/.bashrc fi # Colors - echo "alias ls='ls --color=auto'" >> $HOME/.bashrc + echo "alias ls='ls --color=auto'" >>$HOME/.bashrc # Python paths - echo $(python3 /code/opendm/context.py) >> $HOME/.bashrc - - # Vim - printf "syntax on\nset showmatch\nset ts=4\nset sts=4\nset sw=4\nset autoindent\nset smartindent\nset smarttab\nset expandtab" > $HOME/.vimrc + echo $(python3 /code/opendm/context.py) >>$HOME/.bashrc + + # Vim + printf "syntax on\nset showmatch\nset ts=4\nset sts=4\nset sw=4\nset autoindent\nset smartindent\nset smarttab\nset expandtab" >$HOME/.vimrc # Misc aliases - echo "alias pdal=/code/SuperBuild/install/bin/pdal" >> $HOME/.bashrc - echo "alias opensfm=/code/SuperBuild/install/bin/opensfm/bin/opensfm" >> $HOME/.bashrc - + echo "alias pdal=/code/SuperBuild/install/bin/pdal" >>$HOME/.bashrc + echo "alias opensfm=/code/SuperBuild/install/bin/opensfm/bin/opensfm" >>$HOME/.bashrc su -c bash $2 exit 0 @@ -66,16 +68,16 @@ fi platform="Linux" # Assumed uname=$(uname) case $uname in - "Darwin") - platform="MacOS" - ;; - MINGW*) - platform="Windows" - ;; +"Darwin") + platform="MacOS" + ;; +MINGW*) + platform="Windows" + ;; esac if [[ $platform != "Linux" && $platform != "MacOS" ]]; then - echo "This script only works on Linux and MacOS." + echo "This script only works on Linux and MacOS." exit 1 fi @@ -86,7 +88,6 @@ 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 @@ -96,9 +97,9 @@ IMAGE_SET=NO if [[ ! -z $IMAGE ]]; then IMAGE_SET=YES fi -export PORT="${PORT:=3003}" +export PORT="${PORT:=3008}" export QTC="${QTC:=NO}" -export IMAGE="${IMAGE:=opendronemap/nodeodm}" +export IMAGE="${IMAGE:=nvidia/cuda:12.2.0-devel-ubuntu20.04}" export GPU="${GPU:=YES}" if [ -z "$DATA" ]; then @@ -113,7 +114,6 @@ if [ -z "$DATA" ]; then exit 1 fi - echo "Starting development environment..." echo "Datasets path: $DATA" echo "Expose port: $PORT" @@ -131,7 +131,8 @@ USER=$(id -un) GPU_FLAGS="" if [[ "$GPU" != "NO" ]]; then if [[ "$IMAGE_SET" = "NO" ]]; then - IMAGE="$IMAGE:gpu" + # IMAGE="$IMAGE:gpu" + IMAGE="$IMAGE" fi GPU_FLAGS="--gpus all" @@ -141,5 +142,5 @@ if [[ "$GPU" != "NO" ]]; then fi xhost + || true -docker run -ti --entrypoint bash --name odmdevstain_gpu --hostname odmdevstain_gpu --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" +docker run -ti --entrypoint bash --name odmdevstain_gpu_8 --hostname odmdevstain_gpu_8 --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-stain.sh --setup $USER $USER_ID $GROUP_ID $QTC" exit 0 diff --git a/tests/gpu.py b/tests/gpu.py new file mode 100644 index 000000000..5ffc74ec6 --- /dev/null +++ b/tests/gpu.py @@ -0,0 +1,39 @@ +import ctypes +import os + +def test_cuda_init(): + """ + This function attempts to initialize CUDA and returns True if successful, False otherwise. + """ + cuda_lib = "libcuda.so" + if os.name == 'nt': # Windows + cuda_lib = os.path.join(os.environ.get('SYSTEMROOT'), 'system32', 'nvcuda.dll') + if not os.path.isfile(cuda_lib): + cuda_lib = "nvcuda.dll" + + try: + nvcuda = ctypes.cdll.LoadLibrary(cuda_lib) + + nvcuda.cuInit.argtypes = (ctypes.c_uint32,) + nvcuda.cuInit.restypes = (ctypes.c_int32) + + result = nvcuda.cuInit(0) + + if result != 0: + print("CUDA initialization failed with error code:", result) + if nvcuda.cuInit(0) == 0: + print("CUDA initialized successfully!") + return True + else: + print("Error initializing CUDA.") + print(nvcuda.cuInit(0)) + return False + except Exception as e: + print(f"Error: {e}") + return False + +if __name__ == "__main__": + if test_cuda_init(): + print("CUDA environment seems to be working.") + else: + print("CUDA environment is not working. Please check your CUDA installation.")