mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
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:
@@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
|
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
import fooocus_version
|
import fooocus_version
|
||||||
@@ -13,7 +12,6 @@ from modules.path import modelfile_path, lorafile_path, vae_approx_path, fooocus
|
|||||||
|
|
||||||
REINSTALL_ALL = False
|
REINSTALL_ALL = False
|
||||||
|
|
||||||
|
|
||||||
def prepare_environment():
|
def prepare_environment():
|
||||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu118")
|
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu118")
|
||||||
torch_command = os.environ.get('TORCH_COMMAND',
|
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"):
|
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)
|
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 REINSTALL_ALL or not is_installed("xformers"):
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
if platform.python_version().startswith("3.10"):
|
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")
|
"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"):
|
if not is_installed("xformers"):
|
||||||
exit(0)
|
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")
|
run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
|
||||||
|
|
||||||
if REINSTALL_ALL or not requirements_met(requirements_file):
|
if REINSTALL_ALL or not requirements_met(requirements_file):
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ Or if you want to open a remote port, use
|
|||||||
|
|
||||||
Coming soon ...
|
Coming soon ...
|
||||||
|
|
||||||
|
### Linux (AMD GPUs)
|
||||||
|
|
||||||
|
Installation is the same as Linux part. It has been tested for 6700XT. Works for both Pytorch 1.13 and Pytorch 2.
|
||||||
|
|
||||||
## List of "Hidden" Tricks
|
## List of "Hidden" Tricks
|
||||||
<a name="tech_list"></a>
|
<a name="tech_list"></a>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user