From 0fee58d4bfafa5f85a41b21e31205666f85e795e Mon Sep 17 00:00:00 2001 From: Gourieff <777@lovemet.ru> Date: Sun, 5 Nov 2023 16:43:41 +0700 Subject: [PATCH] FIX: CUDA detection when no CUDA +VersionUP (0.5.0 alpha5) --- README.md | 2 +- README_RU.md | 2 +- install.py | 4 ++-- scripts/reactor_faceswap.py | 42 +++++++++++++++++++++---------------- scripts/reactor_version.py | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5c7f7c6..3cb80a1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ logo - ![Version](https://img.shields.io/badge/version-0.5.0_alpha4-lightgreen?style=for-the-badge&labelColor=darkgreen) + ![Version](https://img.shields.io/badge/version-0.5.0_alpha5-lightgreen?style=for-the-badge&labelColor=darkgreen) Buy Me a Coffee at ko-fi.com diff --git a/README_RU.md b/README_RU.md index 14cb95e..e0088ff 100644 --- a/README_RU.md +++ b/README_RU.md @@ -2,7 +2,7 @@ logo - ![Version](https://img.shields.io/badge/версия-0.5.0_alpha4-lightgreen?style=for-the-badge&labelColor=darkgreen) + ![Version](https://img.shields.io/badge/версия-0.5.0_alpha5-lightgreen?style=for-the-badge&labelColor=darkgreen) Buy Me a Coffee at ko-fi.com diff --git a/install.py b/install.py index d7b9567..57a10b8 100644 --- a/install.py +++ b/install.py @@ -97,9 +97,9 @@ except: with open(req_file) as file: install_count = 0 + ort = "onnxruntime-gpu" + import torch try: - ort = "onnxruntime-gpu" - import torch if torch.cuda.is_available(): if first_run: last_device = "CUDA" diff --git a/scripts/reactor_faceswap.py b/scripts/reactor_faceswap.py index 25fb944..125e270 100644 --- a/scripts/reactor_faceswap.py +++ b/scripts/reactor_faceswap.py @@ -1,7 +1,10 @@ import os, glob import gradio as gr from PIL import Image -import torch.cuda as cuda +try: + import torch.cuda as cuda +except: + cuda = None from typing import List @@ -136,24 +139,27 @@ class FaceSwapScript(scripts.Script): ) with gr.Tab("Settings"): models = get_models() - if cuda.is_available(): - with gr.Row(): - device = gr.Radio( - label="Execution Provider", - choices=DEVICE_LIST, - value=DEVICE, - type="value", - info="If you already run 'Generate' - RESTART is required to apply. Click 'Save', (A1111) Extensions Tab -> 'Apply and restart UI' or (SD.Next) close the Server and start it again", - scale=2, + if cuda is not None: + if cuda.is_available(): + with gr.Row(): + device = gr.Radio( + label="Execution Provider", + choices=DEVICE_LIST, + value=DEVICE, + type="value", + info="If you already run 'Generate' - RESTART is required to apply. Click 'Save', (A1111) Extensions Tab -> 'Apply and restart UI' or (SD.Next) close the Server and start it again", + scale=2, + ) + save_device_btn = gr.Button("Save", scale=0) + save = gr.Markdown("") + setattr(device, "do_not_save_to_config", True) + save_device_btn.click( + set_Device, + inputs=[device], + outputs=[save], ) - save_device_btn = gr.Button("Save", scale=0) - save = gr.Markdown("") - setattr(device, "do_not_save_to_config", True) - save_device_btn.click( - set_Device, - inputs=[device], - outputs=[save], - ) + else: + device = "CPU" else: device = "CPU" with gr.Row(): diff --git a/scripts/reactor_version.py b/scripts/reactor_version.py index b9eb334..dad5874 100644 --- a/scripts/reactor_version.py +++ b/scripts/reactor_version.py @@ -1,5 +1,5 @@ app_title = "ReActor" -version_flag = "v0.5.0-a4" +version_flag = "v0.5.0-a5" from scripts.reactor_logger import logger, get_Run, set_Run