Skip to content

Instantly share code, notes, and snippets.

@airborne-commando
Last active March 30, 2023 17:58
Show Gist options
  • Select an option

  • Save airborne-commando/9bac59b2aec801976f584c816305ca37 to your computer and use it in GitHub Desktop.

Select an option

Save airborne-commando/9bac59b2aec801976f584c816305ca37 to your computer and use it in GitHub Desktop.
My webUI script for AMD and NVIDIA gpu's
#!/bin/bash
echo -n "This script will configure your venv for AUTOMATIC1111 webui, first the venv has to be removed"
echo " and reinstalled or existing venv for AMD can be used (or NVIDIA)."
read -p "Continue configuration for AMD or NVIDIA? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
echo "Ok continuing the install of either AMD or Nvidia venv, will take a few moments."
else
exit 0
fi
# Creates an empty dir for venv incase it's missing for some odd reason.
if [ ! -d venv/ ]; then
# create the venv directory
mkdir venv
fi
# Checks to see if the directory is found for NVIDIA, if so will ask the user if it would like it removed
if [ -d venv/ ]; then
read -p "Do you want to delete the venv and install NVIDIA venv? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
rm -r venv/
source ./webui.sh &&
exit 0
fi
fi
# Will ask you if you'd want to use NVIDIA instead of AMD
if [ -d venv/ ]; then
read -p "Do you want to use your existing Nvidia ENV instead? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
source ./webui.sh &&
exit 0
fi
fi
# Checks to see if the directory is found for AMD, if so will ask the user if it would like it removed
if [ -d venv/ ]; then
read -p "Do you want to delete the venv and install AMD venv? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
rm -r venv/
python -m venv venv &&
source ./venv/bin/activate
python -m pip install --upgrade pip wheel &&
export HSA_OVERRIDE_GFX_VERSION=10.3.0 &&
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' python launch.py --precision full --no-half --skip-torch-cuda-test
exit 0
fi
fi
# Checks to see if the directory is found for AMD, if so will ask the user if they'd want it excuted with AMD args.
# NOTE: Doesn't work well with existing NVIDIA venv
if [ -d venv/ ]; then
read -p "You you like to use your existing AMD venv? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
source ./venv/bin/activate
export HSA_OVERRIDE_GFX_VERSION=10.3.0 &&
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' python launch.py --precision full --no-half --skip-torch-cuda-test
exit 0
fi
fi
@airborne-commando
Copy link
Author

airborne-commando commented Dec 28, 2022

	if [ -d venv/ ]; then
	  read -p "Do you want to delete the you venv and install AMD venv? [y/n] " answer
	if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
		rm -r venv/
		python -m venv venv &&
		source ./venv/bin/activate
		python -m pip install --upgrade pip wheel &&
		export HSA_OVERRIDE_GFX_VERSION=10.3.0 &&
		TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' python launch.py --precision full --no-half --skip-torch-cuda-test 
		exit 0
	  fi
	fi

	if [ -d venv/ ]; then
	  read -p "You you like to use your existing AMD venv? [y/n] " answer
	if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
		python -m venv venv &&
		source ./venv/bin/activate
		export HSA_OVERRIDE_GFX_VERSION=10.3.0 &&
		TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' python launch.py --precision full --no-half --skip-torch-cuda-test 
		exit 0
	  fi
	fi

Quick fix.

@airborne-commando
Copy link
Author

Added another fix, script will not execute if the dir is not found; will create a blank dir.

if [ ! -d venv/ ]; then
# create the venv directory
mkdir venv
fi

@airborne-commando
Copy link
Author

Added to where it will ask the user to use an existing NVIDIA env instead of AMD.

if [ -d venv/ ]; then
  read -p "Do you want to use your existing Nvidia ENV instead? [y/n] " answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
    source ./webui.sh &&
    exit 0
  fi
fi

@airborne-commando
Copy link
Author

This is old, I would recommend using the wiki on the official repo for AMD if you are using ARCH (or any distro for that matter).

arch based systems

install-on-amd-and-arch-linux

for general usage

Automatic Installation

Letting people know if anyone stumbles upon this and comes upon errors like I did.

@airborne-commando
Copy link
Author

Addtionally I would recommend exporting HSA_OVERRIDE_GFX_VERSION=10.3.0 like so in terminal (or a GFX_VERSION that matches your AMD GPU)
export HSA_OVERRIDE_GFX_VERSION=10.3.0
or you may place it inside /etc/environment to make it more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment