lshqqytiger / stable-diffusion-webui-amdgpu

Stable Diffusion web UI
GNU Affero General Public License v3.0
1.79k stars 185 forks source link

[Bug]: 1.8.0 CodeFormer and Restore faces not working #412

Closed Lgrme closed 6 months ago

Lgrme commented 6 months ago

Checklist

What happened?

CodeFormer and Restore faces don't work in version A1111 1.8.0. In version 1.7.0 everything works fine. An error appears, the process of changing the face does not occur.

Steps to reproduce the problem

1) Extras - CodeFormer - Generate 2) txt2img - Restore faces - Generate

What should have happened?

Must get face restoration.

What browsers do you use to access the UI ?

Google Chrome

Sysinfo

sysinfo-2024-03-07-21-09.json

Console logs

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.8.0
Commit hash: bef51aed032c0aaa5cfd80445bc4cf0d85b408b5
Launching Web UI with arguments: --opt-sdp-attention
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Loading weights [912c9dc74f] from H:\SD\stable-diffusion-webui\models\Stable-diffusion\SDXL\(SDXL)-realvisxlV40_v40Bakedvae.safetensors
Creating model from config: H:\SD\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 12.4s (prepare environment: 1.5s, import torch: 3.5s, import gradio: 0.7s, setup paths: 0.9s, initialize shared: 0.3s, other imports: 0.4s, load scripts: 2.4s, create ui: 0.4s, gradio launch: 2.3s).
Applying attention optimization: sdp... done.
Model loaded in 5.8s (load weights from disk: 0.4s, create model: 0.4s, apply weights to model: 3.9s, load textual inversion embeddings: 0.2s, calculate empty prompt: 0.5s).
tiled upscale: 100%|███████████████████████████████████████████████████████████████████| 30/30 [00:07<00:00,  4.04it/s]
*** Failed face-restoration inference
    Traceback (most recent call last):
      File "H:\SD\stable-diffusion-webui\modules\face_restoration_utils.py", line 86, in restore_with_face_helper
        cropped_face_t = restore_face(cropped_face_t)
      File "H:\SD\stable-diffusion-webui\modules\codeformer_model.py", line 53, in restore_face
        return self.net(cropped_face_t, w=w, adain=True)[0]
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\spandrel\architectures\CodeFormer\arch\codeformer.py", line 711, in forward
        x = block(x)
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
        return forward_call(*args, **kwargs)
      File "H:\SD\stable-diffusion-webui\venv\lib\site-packages\spandrel\architectures\CodeFormer\arch\codeformer.py", line 584, in forward
        x = swish(x)
    RuntimeError: nvrtc: error: invalid value for --gpu-architecture (-arch)

    nvrtc compilation failed:

    #define NAN __int_as_float(0x7fffffff)
    #define POS_INFINITY __int_as_float(0x7f800000)
    #define NEG_INFINITY __int_as_float(0xff800000)

    template<typename T>
    __device__ T maximum(T a, T b) {
      return isnan(a) ? a : (a > b ? a : b);
    }

    template<typename T>
    __device__ T minimum(T a, T b) {
      return isnan(a) ? a : (a < b ? a : b);
    }

    extern "C" __global__
    void fused_sigmoid_mul(float* tx_1, float* aten_mul) {
    {
      float tx_1_1 = __ldg(tx_1 + (long long)(threadIdx.x) + 512ll * (long long)(blockIdx.x));
      aten_mul[(long long)(threadIdx.x) + 512ll * (long long)(blockIdx.x)] = tx_1_1 * (1.f / (1.f + (expf(0.f - tx_1_1))));
    }
    }

---

Additional information

Windows 11 Pro 23H2 5800x3D 7900xtx 32Gb RAM ZLUDA 3.5 win + HIP SDK ROCm 5.7.1 + AUTOMATIC1111 version: [v1.8.0], python: 3.10.6, torch: 2.2.0+cu118,  xformers: N/A,  gradio: 3.41.2 In version A1111 1.7.0 everything worked fine, but in version A1111 1.8.0 CodeFormer and Restore faces don't work. Everything else works great. ZLUDA is currently only compatible with cu118. cu121 is not yet supported. I installed torch: 2.1.2+cu118, torch: 2.0.1+cu118. There are no changes, I settled on the latest version of torch: 2.2.0+cu118. I updated pip 24 in an attempt to fix the problem, but it didn't help. On version 1.7.0 everything works fine. I think there is some kind of error or incompatibility due to the addition of some kind of “spandrel” in version 1.8.0.

CS1o commented 6 months ago

Hey, im running currently on 1.8.0 with Zluda and have no Problems. (7900XTX)

No issues with anything on torch: 2.2.0+cu118. Codeformer and Facerestore work normaly.

I see you have --opt-sdp-attention in your webui-user.bat. This argument causes errors mostly on AMD.

You should remove it and instead add: --use-zluda --medvram-sdxl --update-all-extensions --update-check --skip-ort Then delete the venv folder and relaunch the webui-user.bat. With that everything should work.

Lgrme commented 6 months ago

Hey, im running currently on 1.8.0 with Zluda and have no Problems. (7900XTX)

No issues with anything on torch: 2.2.0+cu118. Codeformer and Facerestore work normaly.

I see you have --opt-sdp-attention in your webui-user.bat. This argument causes errors mostly on AMD.

You should remove it and instead add: --use-zluda --medvram-sdxl --update-all-extensions --update-check --skip-ort Then delete the venv folder and relaunch the webui-user.bat. With that everything should work.

I'm glad to hear that this works for at least someone, it means that the problem is somewhere specific for me, I'll try it. Thanks for the information!

lshqqytiger commented 6 months ago

Most of features using rtc (runtime compiler) are unavailable on ZLUDA since there's some NVIDIA CUDA specific things that are not compatible with ROCm/HIP. ZLUDA backend of this repository and SD.Next is forcing such features to use CPU. But you are on the upstream, so this issue is not able to reproduce in this repository.