diff --git a/services/background-removal-dis.py b/services/background-removal-dis.py new file mode 100644 index 0000000..d3a162c --- /dev/null +++ b/services/background-removal-dis.py @@ -0,0 +1,34 @@ +from services import Stack + + +class BGRemovalDIS(Stack): + def __init__(self): + super().__init__( + 'BGRemovalDIS', + 'bg-remove-dis-rocm', + 5005, + 'https://huggingface.co/spaces/ECCV2022/dis-background-removal' + ) + + def install(self): + self.git_clone(url=self.url, dest="webui") + self.install_requirements("webui/requirements.txt") + self.pip_install("gradio") # gradio is not in requirements.txt for some reason + + self.remove_line_in_file("os.", "webui/app.py") # remove manual clone of DIS from app.py (done below) + + self.git_clone("https://github.com/xuebinqin/DIS.git", dest="tmp-dis") + self.move_all_files_in_dir("tmp-dis/IS-Net", "webui") + self.remove_dir("tmp-dis") + + self.create_dir("webui/saved_models") + self.move_file_or_dir("webui/isnet.pth", "webui/saved_models/isnet.pth") + + # self.remove_dir("webui/.git") # saves a lot of space due to big repo + + super().install() + + def start(self): + args = ["--port", str(self.port)] + self.python(f"app.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"]) diff --git a/services/comfyui.py b/services/comfyui.py new file mode 100644 index 0000000..28242e3 --- /dev/null +++ b/services/comfyui.py @@ -0,0 +1,34 @@ +from services import Stack + + +class ComfyUI(Stack): + def __init__(self): + super().__init__( + 'ComfyUI', + 'comfyui-rocm', + 5004, + 'https://github.com/comfyanonymous/ComfyUI.git' + ) + + def install(self): + # Install the webui + self.git_clone(url=self.url, dest="webui") + self.install_requirements("webui/requirements.txt") + + # Install the manager + self.git_clone(url="https://github.com/ltdrdata/ComfyUI-Manager.git", dest="webui/custom_nodes/manager") + + # Add GGUF support + self.pip_install(["gguf", "numpy==1.26.4"]) + + # Add NF4 support for Flux + self.install_from_prebuilt("bitsandbytes") + self.git_clone(url="https://github.com/comfyanonymous/ComfyUI_bitsandbytes_NF4.git", + dest="webui/custom_nodes/ComfyUI_bitsandbytes_NF4") + + super().install() + + def start(self): + args = ["--port", str(self.port)] + self.python(f"main.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"]) diff --git a/services/stablediffusion-forge.py b/services/stablediffusion-forge.py new file mode 100644 index 0000000..47e5f73 --- /dev/null +++ b/services/stablediffusion-forge.py @@ -0,0 +1,27 @@ +from services import Stack + + +class StableDiffusionForge(Stack): + def __init__(self): + super().__init__( + 'StableDiffusion Forge WebUI', + 'stablediffusion-forge-rocm', + 5003, + 'https://github.com/lllyasviel/stable-diffusion-webui-forge' + ) + + def install(self): + # Install the webui + self.git_clone(url=self.url, dest="webui") + + self.python("launch.py --skip-torch-cuda-test --exit", current_dir="webui") + + # Add NF4 support for Flux + self.install_from_prebuilt("bitsandbytes") + + super().install() + + def start(self): + args = ["--listen", "--enable-insecure-extension-access", "--port", str(self.port)] + self.python(f"launch.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"]) diff --git a/services/stablediffusion-webui.py b/services/stablediffusion-webui.py new file mode 100644 index 0000000..b3638da --- /dev/null +++ b/services/stablediffusion-webui.py @@ -0,0 +1,27 @@ +from services import Stack + + +class StableDiffusionForge(Stack): + def __init__(self): + super().__init__( + 'StableDiffusion WebUI', + 'stablediffusion-webui-rocm', + 5002, + 'https://github.com/AUTOMATIC1111/stable-diffusion-webui' + ) + + def install(self): + # Install the webui + self.git_clone(url=self.url, branch="dev", dest="webui") + + self.python("launch.py --skip-torch-cuda-test --exit", current_dir="webui") + + # Add NF4 support for Flux + self.install_from_prebuilt("bitsandbytes") + + super().install() + + def start(self): + args = ["--listen", "--enable-insecure-extension-access", "--port", str(self.port)] + self.python(f"launch.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"]) diff --git a/services/txtgen.py b/services/txtgen.py new file mode 100644 index 0000000..5915167 --- /dev/null +++ b/services/txtgen.py @@ -0,0 +1,56 @@ +from services import Stack + + +class TextGeneration(Stack): + def __init__(self): + super().__init__( + 'Text Generation', + 'text-generation-rocm', + 5000, + 'https://github.com/oobabooga/text-generation-webui/' + ) + + def install(self): + # Install LlamaCpp from prebuilt + self.pip("install llama-cpp-python", ["CMAKE_ARGS=\"-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS\""]) # cpu + + # Install LlamaCpp for ROCM from source + # self.pip("install llama-cpp-python", ["CMAKE_ARGS=\"-DGGML_HIPBLAS=on\" FORCE_CMAKE=1"]) # manual gpu (only works if whole rocm suite installed) + # self.install_from_prebuilt("llama_cpp_python") # gpu (only works if whole rocm suite installed) + + # Install Triton for ROCM from prebuilt + # self.install_from_prebuilt("triton") + + # Install Triton for ROCM from source + # self.git_clone(url="https://github.com/ROCmSoftwarePlatform/triton.git") + # self.pip_install(['ninja', 'cmake']) + # self.pip("install -e .", path="triton") + + # Install the webui + self.git_clone(url=self.url, dest="webui") + self.remove_line_in_file(["accelerate", "lm_eval", "optimum", "autoawq", "llama_cpp_python"], + "../text-generation-rocm/webui/requirements_amd.txt") + self.install_requirements("../text-generation-rocm/webui/requirements_amd.txt") + self.pip_install(["accelerate", "optimum"]) + self.pip_install( + "https://github.com/casper-hansen/AutoAWQ_kernels/releases/download/v0.0.7/autoawq_kernels-0.0.7+rocm571-cp310-cp310-linux_x86_64.whl", + no_deps=True) + self.pip_install( + "https://github.com/casper-hansen/AutoAWQ/releases/download/v0.2.6/autoawq-0.2.6-cp310-cp310-linux_x86_64.whl", + no_deps=True) + # Fix llama trying to use cuda version + self.remove_line_in_file("llama_cpp_cuda", "../text-generation-rocm/webui/modules/llama_cpp_python_hijack.py") + + # Install useful packages + self.pip_install( + "https://github.com/turboderp/exllamav2/releases/download/v0.1.9/exllamav2-0.1.9+rocm6.1.torch2.4.0-cp310-cp310-linux_x86_64.whl") + self.install_from_prebuilt("bitsandbytes") + self.pip( + "install auto-gptq --no-build-isolation --extra-index-url https://huggingface.github.io/autogptq-index/whl/rocm573/") + + super().install() + + def start(self): + args = ["--listen", "--listen-port", str(self.port)] + self.python(f"server.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"]) diff --git a/services/xtts.py b/services/xtts.py new file mode 100644 index 0000000..960e9a7 --- /dev/null +++ b/services/xtts.py @@ -0,0 +1,38 @@ +from services import Stack + + +class XTTS(Stack): + def __init__(self): + super().__init__( + 'XTTS WebUI', + 'xtts-rocm', + 5001, + 'https://github.com/daswer123/xtts-webui' + ) + + def install(self): + # Install the webui + self.git_clone(url=self.url, dest="webui") + + self.remove_line_in_file("torch", "webui/requirements.txt") + self.install_requirements("webui/requirements.txt") + + # sed -i 's/device = "cuda" if torch.cuda.is_available() else "cpu"/device = "cpu"/' webui/scripts/utils/formatter.py + # sed -i 's/asr_model = WhisperModel(whisper_model, device=device, compute_type="float16")/asr_model = WhisperModel(whisper_model, device=device, compute_type="int8")/' webui/scripts/utils/formatter.py + + # Disable gpu for faster-whipser as ROCM isn't supported yet + self.replace_line_in_file("device = \"cuda\" if torch.cuda.is_available() else \"cpu\"", "device = \"cpu\"", + "webui/scripts/utils/formatter.py") + self.replace_line_in_file("asr_model = WhisperModel(whisper_model, device=device, compute_type=\"float16\")", + "asr_model = WhisperModel(whisper_model, device=device, compute_type=\"int8\")", + "webui/scripts/utils/formatter.py") + + # Deepspeed and ninja (not working yet) + # self.pip_install(["ninja", "deepspeed"]) + + super().install() + + def start(self): + args = ["--host", "0.0.0.0", "--port", str(self.port)] + self.python(f"server.py {' '.join(args)}", current_dir="webui", + env=["TORCH_BLAS_PREFER_HIPBLASLT=0"])