Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Shell Script dependencies.sh to Automatically Install Helios Dependencies #47

Closed
wants to merge 12 commits into from
130 changes: 130 additions & 0 deletions CUDA_install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"WSL" : [
"wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin",
"mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600",
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-wsl-ubuntu-12-6-local_12.6.2-1_amd64.deb",
"dpkg -i cuda-repo-wsl-ubuntu-12-6-local_12.6.2-1_amd64.deb",
"cp /var/cuda-repo-wsl-ubuntu-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6"
],
"Ubuntu_24.04_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin",
"mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600",
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-ubuntu2404-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"dpkg -i cuda-repo-ubuntu2404-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"cp /var/cuda-repo-ubuntu2404-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6",
"apt-get install -y nvidia-open"
],
"Ubuntu_22.04_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin",
"mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600",
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"dpkg -i cuda-repo-ubuntu2204-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"cp /var/cuda-repo-ubuntu2204-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6",
"apt-get install -y nvidia-open"
],
"Ubuntu_20.04_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin",
"mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600",
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-ubuntu2004-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"dpkg -i cuda-repo-ubuntu2004-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"cp /var/cuda-repo-ubuntu2004-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6",
"apt-get install -y nvidia-open"
],
"SLES_15_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-sles15-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-sles15-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"zypper refresh",
"zypper install -y cuda-toolkit-12-6",
"zypper install -y nvidia-open"
],
"Rocky_8_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-rhel8-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-rhel8-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"Rocky_9_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"RHEL_8_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-rhel8-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-rhel8-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"RHEL_9_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"OpenSUSE_15_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-opensuse15-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-opensuse15-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"zypper refresh",
"zypper install -y cuda-toolkit-12-6",
"zypper install -y nvidia-open"
],
"KylinOS_10_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-kylin10-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-kylin10-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"Fedora_39_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-fedora39-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-fedora39-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
],
"Debian_11_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-debian11-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"dpkg -i cuda-repo-debian11-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"cp /var/cuda-repo-debian11-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"add-apt-repository contrib",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6",
"apt-get install -y nvidia-open"
],
"Debian_12_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-debian12-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"dpkg -i cuda-repo-debian12-12-6-local_12.6.2-560.35.03-1_amd64.deb",
"cp /var/cuda-repo-debian12-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/",
"add-apt-repository contrib",
"apt-get update",
"apt-get -y install cuda-toolkit-12-6",
"apt-get install -y nvidia-open"
],
"Azure-Linux_2_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-cm2-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-cm2-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"tdnf -y install mariner-repos-extended",
"tdnf clean all",
"tdnf -y install cuda-toolkit-12-6",
"tdnf -y install nvidia-open"
],
"Amazon-Linux_2023_x86_64" : [
"wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-amzn2023-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"rpm -i cuda-repo-amzn2023-12-6-local-12.6.2_560.35.03-1.x86_64.rpm",
"dnf clean all",
"dnf -y install cuda-toolkit-12-6",
"dnf -y module install nvidia-driver:open-dkms"
]
}
233 changes: 233 additions & 0 deletions dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#!/usr/bin/env bash

################################################
## Install package dependencies for Helios. ##
#
## Use one of the following arguments to choose
## which dependencies to install. Default (if
## no argument provided) is "all".
#
# ARGUMENT
# option: Choice of which dependencies to
# install (default is "all").
# See below.
#
# OPTIONS
# BASE: Install GCC, G++, and CMake
# Required to run Helios.
# VIS: Install base dependencies + X11/xorg
# Required for Visualizer plugin.
# CUDA: Install base dependencies + CUDA
# Required for 1. Radiation, 2. Energy
# Balance, 3. LiDAR, 4. Aerial LiDAR,
# and 5. Voxel Intersection plugins.
# ALL: Install dependencies for ALL plugins
#
# EXAMPLE
# source dependencies.sh BASE
#
################################################

DEPENDENCIES_PATH=("gcc" "g++" "cmake" "wget" "jq" "pybind11") # Base PATH dependencies

# Run bash script as root
if command -v nvcc &> /dev/null; then
ROOT="sudo"
else
echo "'sudo' command not found. Please run this script as root."
ROOT=""
fi

# Runs command and clears output from terminal after completion.
run_command_clear_output() {
run_command="$1"
out_file=$(mktemp)
# Install package and store output to temporary file
eval "$run_command" 2>&1 | tee "$out_file"
# Clear output from terminal
num_lines=$(wc -l < "$out_file")
for ((i=0; i<num_lines; i++)); do
tput cuu1
tput el
done
# Remove temporary file
rm "$out_file"
}

# Checks if element is in a list
is_in_list() {
search="$1"
shift
list=("$@")
for element in "${list[@]}"; do
if [[ "$element" == "$search" ]]; then
return 0
fi
done
return 1
}

arg=$(echo "$1" | tr '[:upper:]' '[:lower:]') # case-insensitive command-line argument

ARGS=("base" "vis" "cuda" "all") # valid arguments; default is 'all'

# Determine packages to install (base, vis, cuda, or all)
if [ -z "$1" ]; then
MODE="all"
else
if is_in_list "$arg" "${ARGS[@]}"; then
MODE="$arg"
else
MODE="all"
fi
fi

# Check if the host is Windows, macOS, or Linux
if [[ "$(uname -s)" == *"MINGW"* || "$(uname -s)" == *"CYGWIN"* ]]; then
echo -e "Host is Windows. Dependencies need to be installed manually."
echo -e "Please install Visual Studio: https://visualstudio.microsoft.com/downloads/"
echo -e "Please install CUDA: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64"
exit 0
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "Installing $MODE dependencies for macOS host...\n"
PACKAGE_MANAGER="brew"
if [[ "$MODE" == "all" || "$MODE" == "cuda" || "$MODE" == "vis" ]]; then
DEPENDENCIES_PATH+=("Caskroom" "cask")
fi
if [[ "$MODE" == "all" || "$MODE" == "vis" ]]; then
DEPENDENCIES_PATH+=("xquartz")
fi
if [[ "$MODE" == "all" || "$MODE" == "cuda" ]]; then
# DEPENDENCIES_PATH+=("cuda")
echo "Host is macOS. CUDA cannot be installed."
fi
CHECK_EXISTS="brew list"
FLAG=""
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo -e "Installing $MODE dependencies for Linux host...\n"
if command -v apt &> /dev/null; then
PACKAGE_MANAGER="$ROOT apt-get"
CHECK_EXISTS="dpkg -l | grep -w -m 1"
elif command -v yum &> /dev/null; then
PACKAGE_MANAGER="$ROOT yum"
CHECK_EXISTS="rpm -qa | grep -w -m 1"
elif command -v dnf &> /dev/null; then
PACKAGE_MANAGER="$ROOT dnf"
CHECK_EXISTS="rpm -qa | grep -w -m 1"
elif command -v tdnf &> /dev/null; then
PACKAGE_MANAGER="$ROOT tdnf"
CHECK_EXISTS="rpm -qa | grep -w -m 1"
elif command -v zypper &> /dev/null; then
PACKAGE_MANAGER="$ROOT zypper"
CHECK_EXISTS="zypper se --installed-only | grep -w -m 1"
elif command -v pacman &> /dev/null; then
PACKAGE_MANAGER="$ROOT pacman"
CHECK_EXISTS="pacman -Qs | grep -w -m 1"
else
echo "No package manager detected. Exiting..."
exit 1
fi
if [[ "$MODE" == "all" || "$MODE" == "vis" ]]; then
DEPENDENCIES_PATH+=("libx11-dev" "xorg-dev" "libgl1-mesa-dev" "libglu1-mesa-dev" "libxrandr-dev" "python3-dev")
fi
FLAG="-y"
export DEBIAN_FRONTEND=noninteractive # Avoid timezone prompts
else
echo "Unsupported OS."
exit 1
fi

# Update package list
run_command_clear_output "$PACKAGE_MANAGER update $FLAG"

# Install PATH dependencies
for package in "${DEPENDENCIES_PATH[@]}"; do
if command -v "$package" &> /dev/null; then
echo "$package already installed at: $(command -v $package)"
elif eval "$CHECK_EXISTS \"$package\" &> /dev/null"; then
echo "$package already installed."
else
echo "Installing $package..."
run_command_clear_output "$PACKAGE_MANAGER install $FLAG $package"
if command -v "$package" &> /dev/null; then
echo "$package installed at: $(command -v $package)"
else
echo "$package installed."
fi
fi
done

# If host is macOS or host is Linux and CUDA not needed, dependencies already installed successfully.
if [[ "$OSTYPE" == "darwin"* || "$MODE" == "base" || "$MODE" == "vis" ]]; then
echo "Finished installing dependencies."
exit 0
fi

# Get Linux distribution & version
os_name=$(cat /etc/os-release | grep "^NAME=" | cut -d '"' -f 2 | awk '{print $1}')
version_id=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d '"' -f 2)
architecture=$(uname -m)
distro="${os_name}_${version_id}_${architecture}"
if cat /proc/version | grep -o WSL &> /dev/null; then
if cat /proc/version | grep -o WSL2 &> /dev/null; then
distro="WSL"
else
echo "Install the latest version of WSL2 for running Linux GUI applications!"
exit 1
fi
fi

# If host is Linux, need to install CUDA
if command -v nvcc &> /dev/null; then
echo "CUDA version $( nvcc --version | grep -oP 'V\d+\.\d+\.\d+' | awk -F'V' '{print $2}' ) already installed at $(command -v nvcc)"
else
echo "Installing CUDA for $distro..."
mapfile -t CUDA_COMMANDS < <(jq -r ".\"$distro\"[]" CUDA_install.json)

# Verify that CUDA_COMMANDS were loaded correctly
if [ ${#CUDA_COMMANDS[@]} -eq 0 ]; then
echo "Error: No CUDA installation for $distro found in CUDA_install.json. Exiting..."
exit 1
fi

# Install CUDA
for install_command in "${CUDA_COMMANDS[@]}"; do
run_command_clear_output "$ROOT $install_command"
done
fi

# Add nvcc to path
export PATH=/usr/local/cuda/bin:$PATH

# Fix OptiX drivers for WSL
if [[ "$distro" == "WSL" ]]; then
# Automatically install Linux drivers version 470.256.02
DRIVER_URL="https://us.download.nvidia.com/XFree86/Linux-x86_64/470.256.02/NVIDIA-Linux-x86_64-470.256.02.run"
DRIVER_FILE="NVIDIA-Linux-x86_64-470.256.02.run"
wget -O $DRIVER_FILE $DRIVER_URL

LINUX_DRIVER=$(find . -name "NVIDIA-Linux-x86_64-*.run" -print -quit)
if [[ -n "$LINUX_DRIVER" ]]; then
VERSION=$(echo "$LINUX_DRIVER" | sed -E 's/.*NVIDIA-Linux-x86_64-([0-9.]+)\.run/\1/')
echo "Linux Driver Version $VERSION Found. Installing..."
run_command_clear_output "./$LINUX_DRIVER -x"
LINUX_DRIVER_PATH="${LINUX_DRIVER%.run}"
else
echo "Linux Driver not found. Please place Linux Driver .run file in Helios root directory and rerun this script."
echo -e "Linux drivers can be downloaded \e]8;;https://www.nvidia.com/en-in/drivers/unix/\aHERE\e]8;;\a. Version \e]8;;https://www.nvidia.in/Download/driverResults.aspx/227064/en-in\a470.256.02\e]8;;\a (https://www.nvidia.in/Download/driverResults.aspx/227064/en-in) recommended."
exit 1
fi
LXSS="/mnt/c/Windows/System32/lxss/lib/"
OPTIX_DRIVERS_PATH="$(pwd)/$LINUX_DRIVER_PATH/"
DRIVERS=("libnvoptix.so.1" "libnvidia-ptxjitcompiler.so.1")
if [[ ! -f "$LXSS/libnvidia-ptxjitcompiler.so.1" || ! -f "$LXSS/libnvoptix.so.1" ]]; then
mkdir -p "$LXSS"
ln -s "$OPTIX_DRIVERS_PATH/libnvidia-rtcore.so.$VERSION" "$LXSS/libnvidia-rtcore.so.$VERSION"
ln -s "$OPTIX_DRIVERS_PATH/libnvidia-ptxjitcompiler.so.$VERSION" "$LXSS/libnvidia-ptxjitcompiler.so.1"
ln -s "$OPTIX_DRIVERS_PATH/libnvoptix.so.$VERSION" "$LXSS/libnvoptix.so.1"
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
fi
fi

echo "Finished installing $MODE dependencies."
exit 0
18 changes: 18 additions & 0 deletions doc/UserGuide.dox
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,28 @@ $ git pull
4. Double-click TdrDelay and add 600 for the Value data and make it a Decimal (instead of Hexadecimal). Click OK. If you encounter the same "Display driver stopped responding and has recovered" error in the future, increase the value.
5. Close the registry editor and restart the computer for the changes to take effect.

\subsubsection Automatically Installing Helios Dependencies

Running Helios requires several packages to be installed. To install all required packages for all plugins automatically, simply run the following shell script with the argument "ALL" (or with no arguments): `source dependencies.sh`

There are a few additional options for installing dependencies if it is not necessary to use all plugins.

To install only the dependencies required to run Helios with no plugins (or plugins that require no packages), use the argument "BASE": `source dependencies.sh BASE`

To install only the dependencies required to run Helios with the visualizer plugin, use the argument "VIS": `source dependencies.sh VIS`

To install only the dependencies required to run Helios with CUDA (required for the Radiation, Energy Balance, LiDAR, Aerial LiDAR, and Voxel Intersection plugins), use the argument "CUDA": `source dependencies.sh CUDA`

Note that this script only works for macOS and Linux operating systems. Windows users must install dependencies manually. Also note that CUDA is incompatible with macOS, and Mac users cannot run or install dependencies for the plugins that require CUDA.

\subsubsection OptiXWSL Manually installing OptiX if using Windows Subsystem for Linux (WSL)

OptiX is normally packaged with Helios, such that you do not have to worry about installing it. However, if you are using Windows Subsystem for Linux (WSL), you will need to manually install OptiX since the version included with Helios does not have the required drivers for WSL. You can follow the instructions on this site to perform the installation: <a href="https://forums.developer.nvidia.com/t/problem-running-optix-7-6-in-wsl/239355/7">https://forums.developer.nvidia.com/t/problem-running-optix-7-6-in-wsl/239355/7</a>.

Alternatively, simply run the dependencies script: `source dependencies.sh`

This will automatically install and configure the Linux drivers (version 470.256.02) to run OptiX.

Copy link
Collaborator Author

@smbanx smbanx Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround for us not being able to store the proprietary OptiX driver files in the Helios repo. I changed the bash script so that it automatically installs and configures Linux drivers version 470.256.02 (the version that worked for me).

This way, it is no longer necessary to manually install the drivers and move them to the Helios root directory. WSL users simply need to run source dependencies.sh, and OptiX should work properly with no additional steps.

\section SetupLinux Set-up on Linux

\subsection SetupLinuxCLion Setting up basic build functionality
Expand Down
Loading
Loading