From 0324deec60224f4f5956df5397c97158923f837a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 17 Mar 2023 13:20:37 +0530 Subject: [PATCH] Use CUDA-specific torch only on Linux, not mac --- scripts/on_sd_start.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index bc96baaa..4b1b7ab5 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -56,6 +56,13 @@ if [ -e "GFPGANv1.3.pth" ]; then mv GFPGANv1.3.pth ../models/gfpgan/; fi if [ -e "RealESRGAN_x4plus.pth" ]; then mv RealESRGAN_x4plus.pth ../models/realesrgan/; fi if [ -e "RealESRGAN_x4plus_anime_6B.pth" ]; then mv RealESRGAN_x4plus_anime_6B.pth ../models/realesrgan/; fi +OS_NAME=$(uname -s) +case "${OS_NAME}" in + Linux*) OS_NAME="linux";; + Darwin*) OS_NAME="macos";; + *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit +esac + # install torch and torchvision if python ../scripts/check_modules.py torch torchvision; then echo "torch and torchvision have already been installed." @@ -65,10 +72,18 @@ else export PYTHONNOUSERSITE=1 export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages" - if python -m pip install --upgrade torch==1.13.1+cu116 torchvision==0.14.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116 ; then - echo "Installed." - else - fail "torch install failed" + if [ "$OS_NAME" == "linux" ]; then + if python -m pip install --upgrade torch==1.13.1+cu116 torchvision==0.14.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116 ; then + echo "Installed." + else + fail "torch install failed" + fi + elif [ "$OS_NAME" == "macos" ]; then + if python -m pip install --upgrade torch==1.13.1 torchvision==0.14.1 ; then + echo "Installed." + else + fail "torch install failed" + fi fi fi