add support for AMD GPU on Linux. Skip the xformers installation if detecting AMD GPU. also add a section in readme. (#397)
Co-authored-by: tio2 <pema@syr.edu>
This commit is contained in:
parent
ceee6dfd73
commit
71e99185cb
21
launch.py
21
launch.py
|
|
@ -1,7 +1,6 @@
|
|||
import os
|
||||
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
|
||||
|
||||
|
||||
import sys
|
||||
import platform
|
||||
import fooocus_version
|
||||
|
|
@ -13,7 +12,6 @@ from modules.path import modelfile_path, lorafile_path, vae_approx_path, fooocus
|
|||
|
||||
REINSTALL_ALL = False
|
||||
|
||||
|
||||
def prepare_environment():
|
||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu118")
|
||||
torch_command = os.environ.get('TORCH_COMMAND',
|
||||
|
|
@ -35,6 +33,23 @@ def prepare_environment():
|
|||
if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"):
|
||||
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
|
||||
|
||||
import torch
|
||||
|
||||
def detect_gpu_type():
|
||||
if torch.cuda.is_available():
|
||||
gpu_name = torch.cuda.get_device_name(0)
|
||||
if "NVIDIA" in gpu_name:
|
||||
return "NVIDIA GPU"
|
||||
elif "Radeon" in gpu_name:
|
||||
return "AMD GPU"
|
||||
else:
|
||||
return "Unknown GPU Type"
|
||||
else:
|
||||
return "No GPU Available"
|
||||
|
||||
gpu_type = detect_gpu_type()
|
||||
print("Detected GPU Type:", gpu_type)
|
||||
|
||||
if REINSTALL_ALL or not is_installed("xformers"):
|
||||
if platform.system() == "Windows":
|
||||
if platform.python_version().startswith("3.10"):
|
||||
|
|
@ -45,7 +60,7 @@ def prepare_environment():
|
|||
"You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness")
|
||||
if not is_installed("xformers"):
|
||||
exit(0)
|
||||
elif platform.system() == "Linux":
|
||||
elif platform.system() == "Linux" and gpu_type == 'NVIDIA GPU':
|
||||
run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
|
||||
|
||||
if REINSTALL_ALL or not requirements_met(requirements_file):
|
||||
|
|
|
|||
Loading…
Reference in New Issue