From aed9f937da05eb8db670cee48a3b563f37359e44 Mon Sep 17 00:00:00 2001 From: JSTayco Date: Sat, 1 Apr 2023 08:52:45 -0700 Subject: [PATCH] Removed -v test as older versions of bash don't support that option Made script compatible with very old version of bash, added some guards for library linking, and removed redundant library linking. --- setup.sh | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/setup.sh b/setup.sh index bc98d6e..7155f68 100755 --- a/setup.sh +++ b/setup.sh @@ -33,10 +33,10 @@ EOF # Checks to see if variable is set and non-empty. # This is defined first, so we can use the function for some default variable values env_var_exists() { - if [[ ! -v "$1" ]] || [[ -z "$1" ]]; then - return 1 - else + if [[ -n "${!1}" ]]; then return 0 + else + return 1 fi } @@ -416,17 +416,6 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then } check_storage_space - - # This is the pre-install work for a kohya installation on a runpod - if [ "$RUNPOD" = true ]; then - if [ -d "$VENV_DIR" ]; then - echo "Pre-existing installation on a runpod detected." - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$VENV_DIR"/lib/python3.10/site-packages/tensorrt/ - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$VENV_DIR"/lib/python3.10/site-packages/nvidia/cuda_runtime/lib/ - cd "$DIR" || exit 1 - fi - fi - update_kohya_ss distro=get_distro_name @@ -506,8 +495,17 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then create_symlinks "$libnvinfer_symlink" "$libnvinfer_target" create_symlinks "$libcudart_symlink" "$libcudart_target" - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VENV_DIR/lib/python3.10/site-packages/tensorrt/" - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VENV_DIR/lib/python3.10/site-packages/nvidia/cuda_runtime/lib/" + if [ -d "${VENV_DIR}/lib/python3.10/site-packages/tensorrt/" ]; then + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${VENV_DIR}/lib/python3.10/site-packages/tensorrt/" + else + echo "${VENV_DIR}/lib/python3.10/site-packages/tensorrt/ not found; not linking library." + fi + + if [ -d "${VENV_DIR}/lib/python3.10/site-packages/tensorrt/" ]; then + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${VENV_DIR}/lib/python3.10/site-packages/nvidia/cuda_runtime/lib/" + else + echo "${VENV_DIR}/lib/python3.10/site-packages/nvidia/cuda_runtime/lib/ not found; not linking library." + fi configure_accelerate