Repository: stable-diffusion-webui
Issue: [Bug]: gfx906 ROCM won't work with  torch: 2.0.1+rocm5.4.2 but works with other AIs
Labels: asking-for-help-with-local-system-issues

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

Trying to make webui work with pytourch 2.0.1 + rocm 5.4.2 but It won't work.

### Steps to reproduce the problem

1. Download last dev.
2. Extract it
3. Run webui.sh
4. Generate.
5. terminal fill with it.

### What should have happened?

It should be generate like normal

### Commit where the problem happens

 b957dcf

### What Python version are you running on ?

Python 3.10.x

### What platforms do you use to access the UI ?

Linux

### What device are you running WebUI on?

AMD GPUs (RX 6000 above), AMD GPUs (RX 5000 below)

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

```Shell
Directly webui.sh give me that terminal errors.
But if I run with this
--no-half --disable-nan-check
It render black.
```


### List of extensions

No extra extensions directly from github

### Console logs

```Shell
Calculating sha256 for /media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors: Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 807.5s (import torch: 5.4s, import gradio: 3.2s, import ldm: 3.7s, other imports: 3.0s, setup codeformer: 0.3s, list SD models: 781.1s, load scripts: 9.8s, create ui: 0.7s, gradio launch: 0.2s).
6ce0161689b3853acaa03779ec93eafe75a02f4ced659bee03f50797806fa2fa
Loading weights [6ce0161689] from /media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
Creating model from config: /media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying optimization: sdp-no-mem... done.
Textual inversion embeddings loaded(0): 
Model loaded in 41.0s (calculate hash: 14.1s, load weights from disk: 0.3s, create model: 1.6s, apply weights to model: 18.6s, apply half(): 1.9s, load VAE: 2.8s, move model to device: 0.8s, load textual inversion embeddings: 0.9s).
  0%|                                                    | 0/20 [00:02<?, ?it/s]
Error completing request
Arguments: ('task(i3jff5ltdmmulfl)', 'miku', '', [], 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 2, 'Latent', 0, 0, 0, 0, '', '', [], 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0) {}
Traceback (most recent call last):
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/call_queue.py", line 57, in f
    res = list(func(*args, **kwargs))
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/txt2img.py", line 57, in txt2img
    processed = processing.process_images(p)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/processing.py", line 611, in process_images
    res = process_images_inner(p)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/processing.py", line 729, in process_images_inner
    samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/processing.py", line 977, in sample
    samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 383, in sample
    samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 257, in launch_sampling
    return func()
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 383, in <lambda>
    samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/repositories/k-diffusion/k_diffusion/sampling.py", line 145, in sample_euler_ancestral
    denoised = model(x, sigmas[i] * s_in, **extra_args)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 169, in forward
    devices.test_for_nans(x_out, "unet")
  File "/media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/modules/devices.py", line 156, in test_for_nans
    raise NansException(message)
modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.




Also with --no-half --disable-nan-check but it render black.



Creating model from config: /media/bcansin/ai/ai/mem/stable-diffusion-webui-dev/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 24.9s (import torch: 5.1s, import gradio: 2.7s, import ldm: 3.7s, other imports: 2.5s, setup codeformer: 0.2s, load scripts: 9.6s, create ui: 0.7s, gradio launch: 0.3s).
DiffusionWrapper has 859.52 M params.
Applying optimization: sdp-no-mem... done.
Textual inversion embeddings loaded(0): 
Model loaded in 5.7s (load weights from disk: 0.9s, create model: 1.3s, apply weights to model: 1.7s, load VAE: 0.3s, move model to device: 1.3s, load textual inversion embeddings: 0.1s).
100%|███████████████████████████████████████████| 20/20 [00:05<00:00,  3.42it/s]
Total progress: 100%|███████████████████████████| 20/20 [00:04<00:00,  4.26it/s]
Total progress: 100%|███████████████████████████| 20/20 [00:04<00:00,  4.25it/s]
```


### Additional information

I got AMD Radeon™ VII ( GFX9 GPUs  gfx906 Vega 20 ) and installed ROCM 5.5
And I only got problem with webui other AI works perfecly with 
even other AI in same system I use for webui work direcly with this:
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.4.2

Also I read this too. This is why I typing.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/10465

Please fix it I really want to get last pythourch and rocm version I Stuck with this
pip install torch==1.13.0+rocm5.2 torchvision==0.14.0+rocm5.2 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/rocm5.2

I begging for help at this point. Please help me. I gave my days to make it work but every time I try I fail.