Merge pull request #1782 from easydiffusion/beta

Hotfix to pin setuptools to 0.69 - for #1781
This commit is contained in:
cmdr2 2024-05-27 10:38:41 +05:30 committed by GitHub
commit 9b0a654d32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,6 +21,7 @@ os_name = platform.system()
modules_to_check = { modules_to_check = {
"torch": ("1.11.0", "1.13.1", "2.0.0", "2.0.1"), "torch": ("1.11.0", "1.13.1", "2.0.0", "2.0.1"),
"torchvision": ("0.12.0", "0.14.1", "0.15.1", "0.15.2"), "torchvision": ("0.12.0", "0.14.1", "0.15.1", "0.15.2"),
"setuptools": "69.5.1",
"sdkit": "2.0.15", "sdkit": "2.0.15",
"stable-diffusion-sdkit": "2.1.5", "stable-diffusion-sdkit": "2.1.5",
"rich": "12.6.0", "rich": "12.6.0",
@ -110,8 +111,9 @@ def update_modules():
fail(module_name) fail(module_name)
else: else:
if version(module_name) != latest_version: if version(module_name) != latest_version:
print(f"WARNING! Tried to install {module_name}=={latest_version}, but the version is still {version(module_name)}!") print(
f"WARNING! Tried to install {module_name}=={latest_version}, but the version is still {version(module_name)}!"
)
if module_name in modules_to_log: if module_name in modules_to_log:
print(f"{module_name}: {version(module_name)}") print(f"{module_name}: {version(module_name)}")
@ -177,8 +179,10 @@ Thanks!"""
) )
exit(1) exit(1)
### Launcher ### Launcher
def get_config(): def get_config():
config_directory = os.path.dirname(__file__) # this will be "scripts" config_directory = os.path.dirname(__file__) # this will be "scripts"
config_yaml = os.path.join(config_directory, "..", "config.yaml") config_yaml = os.path.join(config_directory, "..", "config.yaml")
@ -193,15 +197,17 @@ def get_config():
if os.path.isfile(config_yaml): if os.path.isfile(config_yaml):
from ruamel.yaml import YAML from ruamel.yaml import YAML
yaml = YAML(typ='safe')
with open(config_yaml, 'r') as configfile: yaml = YAML(typ="safe")
with open(config_yaml, "r") as configfile:
try: try:
config = yaml.load(configfile) config = yaml.load(configfile)
except Exception as e: except Exception as e:
print(e, file=sys.stderr) print(e, file=sys.stderr)
elif os.path.isfile(config_json): elif os.path.isfile(config_json):
import json import json
with open(config_json, 'r') as configfile:
with open(config_json, "r") as configfile:
try: try:
config = json.load(configfile) config = json.load(configfile)
except Exception as e: except Exception as e:
@ -227,31 +233,31 @@ def setup_amd_environment():
) )
gpus = list(filter(lambda x: ("amdgpu" in x), open("/proc/bus/pci/devices", "r").readlines())) gpus = list(filter(lambda x: ("amdgpu" in x), open("/proc/bus/pci/devices", "r").readlines()))
gpus = [ x.split("\t")[1].upper() for x in gpus ] gpus = [x.split("\t")[1].upper() for x in gpus]
gpus = [ AMD_PCI_IDs[x] for x in gpus if x in AMD_PCI_IDs ] gpus = [AMD_PCI_IDs[x] for x in gpus if x in AMD_PCI_IDs]
i=0 i = 0
supported_gpus=[] supported_gpus = []
for gpu in gpus: for gpu in gpus:
print(f"Found AMD GPU {gpu}.") print(f"Found AMD GPU {gpu}.")
if gpu.startswith("Navi 1"): if gpu.startswith("Navi 1"):
print("--- Applying Navi 1 settings") print("--- Applying Navi 1 settings")
os.environ["HSA_OVERRIDE_GFX_VERSION"]="10.3.0" os.environ["HSA_OVERRIDE_GFX_VERSION"] = "10.3.0"
os.environ["FORCE_FULL_PRECISION"]="yes" os.environ["FORCE_FULL_PRECISION"] = "yes"
os.environ["HIP_VISIBLE_DEVICES"]=str(i) os.environ["HIP_VISIBLE_DEVICES"] = str(i)
supported_gpus.append("Navi 1") supported_gpus.append("Navi 1")
elif gpu.startswith("Navi 2"): elif gpu.startswith("Navi 2"):
print("--- Applying Navi 2 settings") print("--- Applying Navi 2 settings")
os.environ["HSA_OVERRIDE_GFX_VERSION"]="10.3.0" os.environ["HSA_OVERRIDE_GFX_VERSION"] = "10.3.0"
os.environ["HIP_VISIBLE_DEVICES"]=str(i) os.environ["HIP_VISIBLE_DEVICES"] = str(i)
supported_gpus.append("Navi 2") supported_gpus.append("Navi 2")
elif gpu.startswith("Navi 3"): elif gpu.startswith("Navi 3"):
print("--- Applying Navi 3 settings") print("--- Applying Navi 3 settings")
os.environ["HSA_OVERRIDE_GFX_VERSION"]="11.0.0" os.environ["HSA_OVERRIDE_GFX_VERSION"] = "11.0.0"
os.environ["HIP_VISIBLE_DEVICES"]=str(i) os.environ["HIP_VISIBLE_DEVICES"] = str(i)
supported_gpus.append("Navi 3") supported_gpus.append("Navi 3")
else: else:
print("--- This GPU is probably not supported by ROCm\n") print("--- This GPU is probably not supported by ROCm\n")
i+=1 i += 1
return supported_gpus return supported_gpus
@ -260,7 +266,7 @@ def launch_uvicorn():
pprint(config) pprint(config)
with open("scripts/install_status.txt","a") as f: with open("scripts/install_status.txt", "a") as f:
f.write("sd_weights_downloaded\n") f.write("sd_weights_downloaded\n")
f.write("sd_install_complete\n") f.write("sd_install_complete\n")
@ -268,9 +274,9 @@ def launch_uvicorn():
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
if os_name == "Windows": if os_name == "Windows":
os.environ["PYTHONPATH"] = str(Path( os.environ["INSTALL_ENV_DIR"], "lib", "site-packages")) os.environ["PYTHONPATH"] = str(Path(os.environ["INSTALL_ENV_DIR"], "lib", "site-packages"))
else: else:
os.environ["PYTHONPATH"] = str(Path( os.environ["INSTALL_ENV_DIR"], "lib", "python3.8", "site-packages")) os.environ["PYTHONPATH"] = str(Path(os.environ["INSTALL_ENV_DIR"], "lib", "python3.8", "site-packages"))
os.environ["SD_UI_PATH"] = str(Path(Path.cwd(), "ui")) os.environ["SD_UI_PATH"] = str(Path(Path.cwd(), "ui"))
print(f"PYTHONPATH={os.environ['PYTHONPATH']}") print(f"PYTHONPATH={os.environ['PYTHONPATH']}")
@ -297,7 +303,10 @@ def launch_uvicorn():
setup_amd_environment() setup_amd_environment()
print("\nLaunching uvicorn\n") print("\nLaunching uvicorn\n")
os.system(f'python -m uvicorn main:server_api --app-dir "{os.environ["SD_UI_PATH"]}" --port {listen_port} --host {bind_ip} --log-level error') os.system(
f'python -m uvicorn main:server_api --app-dir "{os.environ["SD_UI_PATH"]}" --port {listen_port} --host {bind_ip} --log-level error'
)
### Start ### Start
@ -1102,5 +1111,5 @@ AMD_PCI_IDs = {
update_modules() update_modules()
if len(sys.argv) > 1 and sys.argv[1]=="--launch-uvicorn": if len(sys.argv) > 1 and sys.argv[1] == "--launch-uvicorn":
launch_uvicorn() launch_uvicorn()