Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions install/_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,59 @@ try_install() {
}
}

prepare_cxx_runtime_libs() {
local runtime_dir="$CONDA_PREFIX/lib/embodiedgen-runtime"
local runtime_lib

mkdir -p "$runtime_dir"
for runtime_lib in libstdc++.so.6 libgcc_s.so.1; do
if [[ ! -e "$CONDA_PREFIX/lib/$runtime_lib" ]]; then
log_error "Missing required C++ runtime library: $CONDA_PREFIX/lib/$runtime_lib"
return 1
fi
ln -sfn "../$runtime_lib" "$runtime_dir/$runtime_lib"
done
}

write_cuda_deactivation_hook() {
local cuda_variant="$1"
local deactivate_dir="$CONDA_PREFIX/etc/conda/deactivate.d"
local deactivate_hook="$deactivate_dir/cuda${cuda_variant#cu}.sh"

mkdir -p "$deactivate_dir"
rm -f "$deactivate_dir/cuda126.sh" "$deactivate_dir/cuda128.sh"
cat > "$deactivate_hook" <<'HOOK'
_embodiedgen_remove_path() {
local variable_name="$1"
local path_to_remove="$2"
local current_value

if [[ -v "$variable_name" ]]; then
current_value=":${!variable_name}:"
else
current_value=":"
fi
current_value="${current_value//:$path_to_remove:/:}"
current_value="${current_value#:}"
current_value="${current_value%:}"
if [[ -n "$current_value" ]]; then
export "$variable_name=$current_value"
else
unset "$variable_name"
fi
}

_embodiedgen_remove_path LD_LIBRARY_PATH "$CONDA_PREFIX/lib/embodiedgen-runtime"
_embodiedgen_remove_path LD_LIBRARY_PATH "$CONDA_PREFIX/targets/x86_64-linux/lib"
_embodiedgen_remove_path LIBRARY_PATH "$CONDA_PREFIX/targets/x86_64-linux/lib"
_embodiedgen_remove_path CPATH "$CONDA_PREFIX/targets/x86_64-linux/include"
unset -f _embodiedgen_remove_path
unset EMBODIEDGEN_CUDA_VARIANT EMBODIEDGEN_RUNTIME_LIB
unset CUDA_HOME CUDA_PATH CUDA_TARGET_LIB
unset TORCH_CUDA_ARCH_LIST TCNN_CUDA_ARCHITECTURES
HOOK
}

detect_cuda_variant() {
local cuda_variant="cu126"

Expand Down
29 changes: 17 additions & 12 deletions install/install_cu126.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,43 @@ fi

log_info "Installing CUDA 12.6 toolkit into conda environment: $CONDA_PREFIX"
log_info "Using conda executable: $CONDA_CMD"
CONDA_CHANNEL_ARGS=()
if [[ -n "${EMBODIEDGEN_CUDA_CHANNEL:-}" ]]; then
CONDA_CHANNEL_ARGS=(
--override-channels
-c "$EMBODIEDGEN_CUDA_CHANNEL"
)
log_info "Using CUDA conda channel: $EMBODIEDGEN_CUDA_CHANNEL"
fi

"$CONDA_CMD" install \
-p "$CONDA_PREFIX" \
--override-channels \
-c nvidia \
-c conda-forge \
"${CONDA_CHANNEL_ARGS[@]}" \
cuda-toolkit=12.6 \
cuda-nvcc=12.6 \
-y

log_info "Writing CUDA 12.6 activation hook into the conda environment..."
prepare_cxx_runtime_libs
mkdir -p "$CONDA_PREFIX/etc/conda/activate.d"
rm -f "$CONDA_PREFIX/etc/conda/activate.d/cuda128.sh"
cat > "$CONDA_PREFIX/etc/conda/activate.d/cuda126.sh" <<'HOOK'
export EMBODIEDGEN_CUDA_VARIANT="cu126"
export CUDA_HOME="$CONDA_PREFIX"
export CUDA_PATH="$CONDA_PREFIX"
export CUDA_TARGET_LIB="$CONDA_PREFIX/targets/x86_64-linux/lib"
_cuda_conda_bin="$CONDA_PREFIX/bin"
export EMBODIEDGEN_RUNTIME_LIB="$CONDA_PREFIX/lib/embodiedgen-runtime"
_cuda_conda_lib="$CONDA_PREFIX/lib"
_cuda_conda_lib64="$CONDA_PREFIX/lib64"
_cuda_target_include="$CONDA_PREFIX/targets/x86_64-linux/include"
_cuda_path=":${PATH:-}:"
_cuda_path="${_cuda_path//:$_cuda_conda_bin:/:}"
_cuda_path="${_cuda_path#:}"
_cuda_path="${_cuda_path%:}"
export PATH="$_cuda_conda_bin${_cuda_path:+:$_cuda_path}"
_cuda_ld_path=":${LD_LIBRARY_PATH:-}:"
_cuda_ld_path="${_cuda_ld_path//:$EMBODIEDGEN_RUNTIME_LIB:/:}"
_cuda_ld_path="${_cuda_ld_path//:$CUDA_TARGET_LIB:/:}"
_cuda_ld_path="${_cuda_ld_path//:$_cuda_conda_lib:/:}"
_cuda_ld_path="${_cuda_ld_path//:$_cuda_conda_lib64:/:}"
_cuda_ld_path="${_cuda_ld_path#:}"
_cuda_ld_path="${_cuda_ld_path%:}"
export LD_LIBRARY_PATH="$CUDA_TARGET_LIB${_cuda_ld_path:+:$_cuda_ld_path}"
export LD_LIBRARY_PATH="$EMBODIEDGEN_RUNTIME_LIB:$CUDA_TARGET_LIB${_cuda_ld_path:+:$_cuda_ld_path}"
_cuda_library_path=":${LIBRARY_PATH:-}:"
_cuda_library_path="${_cuda_library_path//:$CUDA_TARGET_LIB:/:}"
_cuda_library_path="${_cuda_library_path#:}"
Expand All @@ -68,10 +72,11 @@ _cuda_cpath="${_cuda_cpath//:$_cuda_target_include:/:}"
_cuda_cpath="${_cuda_cpath#:}"
_cuda_cpath="${_cuda_cpath%:}"
export CPATH="$_cuda_target_include${_cuda_cpath:+:$_cuda_cpath}"
unset _cuda_conda_bin _cuda_conda_lib _cuda_conda_lib64 _cuda_target_include
unset _cuda_path _cuda_ld_path _cuda_library_path _cuda_cpath
unset _cuda_conda_lib _cuda_conda_lib64 _cuda_target_include
unset _cuda_ld_path _cuda_library_path _cuda_cpath
export TORCH_CUDA_ARCH_LIST="${EMBODIEDGEN_TORCH_CUDA_ARCH_LIST:-8.9}"
HOOK
write_cuda_deactivation_hook "cu126"

log_info "Verifying CUDA 12.6 compiler from the active conda environment..."
source "$CONDA_PREFIX/etc/conda/activate.d/cuda126.sh"
Expand Down
16 changes: 7 additions & 9 deletions install/install_cu128.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,26 @@ fi
-y

log_info "Writing CUDA 12.8 activation hook into the conda environment..."
prepare_cxx_runtime_libs
mkdir -p "$CONDA_PREFIX/etc/conda/activate.d"
rm -f "$CONDA_PREFIX/etc/conda/activate.d/cuda126.sh"
cat > "$CONDA_PREFIX/etc/conda/activate.d/cuda128.sh" <<'HOOK'
export EMBODIEDGEN_CUDA_VARIANT="cu128"
export CUDA_HOME="$CONDA_PREFIX"
export CUDA_PATH="$CONDA_PREFIX"
export CUDA_TARGET_LIB="$CONDA_PREFIX/targets/x86_64-linux/lib"
_cuda_conda_bin="$CONDA_PREFIX/bin"
export EMBODIEDGEN_RUNTIME_LIB="$CONDA_PREFIX/lib/embodiedgen-runtime"
_cuda_conda_lib="$CONDA_PREFIX/lib"
_cuda_conda_lib64="$CONDA_PREFIX/lib64"
_cuda_target_include="$CONDA_PREFIX/targets/x86_64-linux/include"
_cuda_path=":${PATH:-}:"
_cuda_path="${_cuda_path//:$_cuda_conda_bin:/:}"
_cuda_path="${_cuda_path#:}"
_cuda_path="${_cuda_path%:}"
export PATH="$_cuda_conda_bin${_cuda_path:+:$_cuda_path}"
_cuda_ld_path=":${LD_LIBRARY_PATH:-}:"
_cuda_ld_path="${_cuda_ld_path//:$EMBODIEDGEN_RUNTIME_LIB:/:}"
_cuda_ld_path="${_cuda_ld_path//:$CUDA_TARGET_LIB:/:}"
_cuda_ld_path="${_cuda_ld_path//:$_cuda_conda_lib:/:}"
_cuda_ld_path="${_cuda_ld_path//:$_cuda_conda_lib64:/:}"
_cuda_ld_path="${_cuda_ld_path#:}"
_cuda_ld_path="${_cuda_ld_path%:}"
export LD_LIBRARY_PATH="$CUDA_TARGET_LIB${_cuda_ld_path:+:$_cuda_ld_path}"
export LD_LIBRARY_PATH="$EMBODIEDGEN_RUNTIME_LIB:$CUDA_TARGET_LIB${_cuda_ld_path:+:$_cuda_ld_path}"
_cuda_library_path=":${LIBRARY_PATH:-}:"
_cuda_library_path="${_cuda_library_path//:$CUDA_TARGET_LIB:/:}"
_cuda_library_path="${_cuda_library_path#:}"
Expand All @@ -75,11 +72,12 @@ _cuda_cpath="${_cuda_cpath//:$_cuda_target_include:/:}"
_cuda_cpath="${_cuda_cpath#:}"
_cuda_cpath="${_cuda_cpath%:}"
export CPATH="$_cuda_target_include${_cuda_cpath:+:$_cuda_cpath}"
unset _cuda_conda_bin _cuda_conda_lib _cuda_conda_lib64 _cuda_target_include
unset _cuda_path _cuda_ld_path _cuda_library_path _cuda_cpath
unset _cuda_conda_lib _cuda_conda_lib64 _cuda_target_include
unset _cuda_ld_path _cuda_library_path _cuda_cpath
export TORCH_CUDA_ARCH_LIST="${EMBODIEDGEN_TORCH_CUDA_ARCH_LIST:-12.0}"
export TCNN_CUDA_ARCHITECTURES="${EMBODIEDGEN_TCNN_CUDA_ARCHITECTURES:-120}"
HOOK
write_cuda_deactivation_hook "cu128"

log_info "Verifying CUDA 12.8 compiler from the active conda environment..."
source "$CONDA_PREFIX/etc/conda/activate.d/cuda128.sh"
Expand Down
Loading