Repository: stable-diffusion-webui
Issue: [Bug]: HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION 
Labels: bug-report,platform:amd

### Is there an existing issue for this?

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

### What happened?

Ran the `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2` command to install `torch 2.0.1+rocm5.4.2`.  Now after running `./webui.sh` I receive:

```
:0:rocdevice.cpp            :2673: 35922360365 us: 32315: [tid:0x7f633bd6f640] Device::callbackQueue aborting with error : HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION: The agent attempted to access memory beyond the largest legal address. code: 0x29
./webui.sh: line 241: 32315 Aborted                 (core dumped) "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
```

### Steps to reproduce the problem



I am using `Pop!_OS 22.04 LTS x86_64`  with a AMD Radeon RX 5700 XT




When running  `./webui.sh` I received the following version check.
```
==============================================================================
You are running torch 1.13.1+rocm5.2.
The program is tested to work with torch 2.0.0.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
```
I decided to try generate image anyways, but instead of getting expected prompt, I receive a empty gray box.:

![image](https://github.com/AUTOMATIC1111/stable-diffusion-webui/assets/105018272/e70506de-4af3-46ef-b9d4-6c04566cd696)

I then run `./webui.sh --reinstall-torch` but still receive the same version check informing me  I am running `torch 1.13.1+rocm5.2`.

```
./webui.sh --reinstall-torch

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on pop user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
python venv already activate: /home/pop/Auto1111/stable-diffusion-webui/.venv
################################################################

################################################################
Launching launch.py...
################################################################
Cannot locate TCMalloc (improves CPU memory usage)
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
Version: v1.4.1
Commit hash: f865d3e11647dfd6c7b2cdf90dde24680e58acd8
Installing torch and torchvision
Looking in indexes: https://download.pytorch.org/whl/rocm5.2
Requirement already satisfied: torch==1.13.1+rocm5.2 in ./.venv/lib/python3.10/site-packages (1.13.1+rocm5.2)
Requirement already satisfied: torchvision==0.14.1+rocm5.2 in ./.venv/lib/python3.10/site-packages (0.14.1+rocm5.2)
Requirement already satisfied: typing-extensions in ./.venv/lib/python3.10/site-packages (from torch==1.13.1+rocm5.2) (4.4.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in ./.venv/lib/python3.10/site-packages (from torchvision==0.14.1+rocm5.2) (9.5.0)
Requirement already satisfied: numpy in ./.venv/lib/python3.10/site-packages (from torchvision==0.14.1+rocm5.2) (1.23.5)
Requirement already satisfied: requests in ./.venv/lib/python3.10/site-packages (from torchvision==0.14.1+rocm5.2) (2.28.1)
Requirement already satisfied: certifi>=2017.4.17 in ./.venv/lib/python3.10/site-packages (from requests->torchvision==0.14.1+rocm5.2) (2022.12.7)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.venv/lib/python3.10/site-packages (from requests->torchvision==0.14.1+rocm5.2) (1.26.13)
Requirement already satisfied: charset-normalizer<3,>=2 in ./.venv/lib/python3.10/site-packages (from requests->torchvision==0.14.1+rocm5.2) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in ./.venv/lib/python3.10/site-packages (from requests->torchvision==0.14.1+rocm5.2) (3.4)
Installing requirements
Launching Web UI with arguments: --reinstall-torch
No module 'xformers'. Proceeding without it.
==============================================================================
You are running torch 1.13.1+rocm5.2.
The program is tested to work with torch 2.0.0.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
Loading weights [6ce0161689] from /home/pop/Auto1111/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
preload_extensions_git_metadata for 7 extensions took 0.00s
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 3.8s (import torch: 1.7s, import gradio: 0.6s, import ldm: 0.2s, other imports: 0.5s, load scripts: 0.3s, create ui: 0.4s).
Creating model from config: /home/pop/Auto1111/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying attention optimization: Doggettx... done.
Textual inversion embeddings loaded(0): 
MIOpen(HIP): Warning [SQLiteBase] Missing system database file: gfx1030_20.kdb Performance may degrade. Please follow instructions to install: https://github.com/ROCmSoftwarePlatform/MIOpen#installing-miopen-kernels-package
Model loaded in 2.5s (load weights from disk: 0.6s, create model: 0.4s, apply weights to model: 0.6s, apply half(): 0.4s, move model to device: 0.3s).
```

From https://pytorch.org/get-started/locally/ I run `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2` which outputs:
```
Successfully installed cmake-3.25.0 lit-15.0.7 mpmath-1.2.1 pytorch-triton-rocm-2.0.1 sympy-1.11.1 torch-2.0.1+rocm5.4.2 torchaudio-2.0.2+rocm5.4.2 torchvision-0.15.2+rocm5.4.2
```

I again run `./webui.sh` but receive the following error:
```
:0:rocdevice.cpp            :2673: 35922360365 us: 32315: [tid:0x7f633bd6f640] Device::callbackQueue aborting with error : HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION: The agent attempted to access memory beyond the largest legal address. code: 0x29
./webui.sh: line 241: 32315 Aborted                 (core dumped) "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
```


### What should have happened?

I expected to the web ui to open and funtion properly, but it crashes instead.

### Version or Commit where the problem happens

Version: v1.4.1

### 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 5000 below)

### Cross attention optimization

Automatic

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

Mozilla Firefox

### Command Line Arguments

```Shell
None
```


### List of extensions

None

### Console logs

```Shell
(Auto1111) pop@pop-os:~/Auto1111/stable-diffusion-webui$ ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on pop user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
python venv already activate: /home/pop/Auto1111/stable-diffusion-webui/.venv
################################################################

################################################################
Launching launch.py...
################################################################
Cannot locate TCMalloc (improves CPU memory usage)
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
Version: v1.4.1
Commit hash: f865d3e11647dfd6c7b2cdf90dde24680e58acd8
Installing requirements
Launching Web UI with arguments: 
No module 'xformers'. Proceeding without it.
Loading weights [6ce0161689] from /home/pop/Auto1111/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
preload_extensions_git_metadata for 7 extensions took 0.00s
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 4.1s (import torch: 1.9s, import gradio: 0.6s, import ldm: 0.2s, other imports: 0.5s, load scripts: 0.4s, create ui: 0.4s, gradio launch: 0.1s).
Creating model from config: /home/pop/Auto1111/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying attention optimization: Doggettx... done.
Textual inversion embeddings loaded(0): 
:0:rocdevice.cpp            :2673: 35922360365 us: 32315: [tid:0x7f633bd6f640] Device::callbackQueue aborting with error : HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION: The agent attempted to access memory beyond the largest legal address. code: 0x29
./webui.sh: line 241: 32315 Aborted                 (core dumped) "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"

```
```


### Additional information

_No response_