How to use Stable Diffusion XL locally with AMD ROCm. With AUTOMATIC1111 WebUI and ComfyUI on Linux.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello you want to use table diffusion XL without constantly waiting in the queue then install it locally if you have an AMD GPU then you can use both automatic web UI and com file UI with best performance on Linux in this video I will show you how to do that and let you know about any tricky Parts in advance I promise as you can see here we have Ubuntu version 2204 LTS by the way the embedded Corner version is 6.2.026 just a side note I have only managed to get Rockham version 565 running with this kernel other variants didn't seem to work first let's set up some prerequisites update the package manager and installer C plus plus standard library that we'll need later for stable diffusion as well as the curl tool which we'll use to download some files foreign [Music] now let's prepare the installation of AMG GPU installed with Rockham version 5.6 AMD GPU install is simply a collection of scripts that encapsulate a few installation routines and make our lives easier overall so feel free to use these scripts here it's easier than manually installing all the necessary components now it's important during the rockem installation itself that we specify graphics and rock M as use cases and nothing else like opengl as that can use issues later which we want to avoid here since this will take a bit of time it's running in Fast Forward here [Music] by the way as you can see here components compatible with our kernel 62026 are being installed it's not as some places might suggest that you can skip the kernel part no if the kernel components are not installed by rockem then rockem won't find the corner later and we won't be able to accelerate stable diffusion accordingly foreign [Music] what we haven't seen so far is this note about UEFI secure boot well I had already installed the screen capture program before so it was sort of preemptively taken care of you're probably seeing it for the first time now if you have ue5 secure boot installed then you need to roll a secret key there that's simply prerequisite for being able to update the kernel driver enter a password and then confirm it again [Music] when your boot don't continue with boot but instead choose enroll Mok which is the key you can look at it or just continue directly yes enroll the key and enter your password reboot the whole thing again and the key will be installed accordingly after this brief intermission we need to make two important inputs specifically we need to add our user to both the video and render groups if we don't do this torch won't be able to find the Rock and drivers later and troubleshooting this can be really cumbersome I've tried it myself [Music] now we're at the point where we can reboot pay attention to entering the Mok key during reboot as we saw earlier in case ufi secure boot is enabled on your system we are back after the reboot and what we want to try now is whether the rocket installation actually worked [Music] and yes we see the output gfx 1030 which indicates that it's working fine so far furthermore there's the command rocam SMI which allows us to see GPU utilization and we'll use that shortly again before that let's install jit on the respective website there's a hint on how to easily install it using apt in the case of Ubuntu [Music] let's do that here as well of course writing sudo before it to make it work [Music] next we'll set up a virtual environment I've chosen to use miniclonda [Music] the download is straightforward we select the Linux 64-bit version download the SR file and move it to our home directory [Music] with bash and the name of the downloaded as half file we start the installation accept the terms and typically answer yes to the following questions clicking through until the installation is complete [Music] minikonda now expects us to close and reopen the shell once that's a quick step of course thank you next let's create a virtual environment let's name it SD for stable diffusion and it should include python version 3.10.6 it seems that newer versions might not be compatible with storage so if you're experimenting make sure to use at least version 3.10 [Music] we activate the newly created virtual environment using conda activate SD and you can exit it later with conda deactivate after activation you will see the SD at the beginning of the prompt now let's proceed with installing automatic web UI we'll copy the URL of the repository use jit clone followed by the copied URL and then it will be downloaded swiftly [Music] foreign [Music] next we'll switch to the clones table diffusion directory inside the directory there's a requirements txt file and we'll use pip 3 to install the corresponding requirements this process takes a bit of time so I'll show it in fast forward [Music] now pay attention here as this is a common source of errors this happened to me at least once we need to uninstall Torch and torch Vision because they were installed from the torch website in a torch specific version however what we need are the corresponding Rock and compatible versions of these components so let's install the correct versions this is an important step and takes a moment so I'll show it in Fast Forward again foreign [Music] we are ready for the first important test as we can see torch has been installed correctly however what about half a support with rock M to find out we use another command if you see true it means that Hardware support is present if you don't see this something has gone wrong first try rebooting if that doesn't work consider starting over as I haven't found a way to get it running without seeing true no that's not a joke there's one more important prerequisite to fulfill we need a launch file to start the process you can download this file from the website I've linked below [Music] here you can see what's inside [Music] however we'll need to make some adjustments and for that we'll use the Nano text editor file HSI override gfx version should remain at 1100 if you have the latest AMD 7900 xdx or similar otherwise if you have something like radian RX 6800 like I do or something similar change it to 10 30. [Music] [Music] additionally for the launch parameters include no half way this is important as not doing so will result in constant very re-encoding during runtime which costs significant amount of performance and doesn't provide any benefit so suppressing it is best also you should deactivate the source V and flying since we're using miniconda as virtual environment [Music] foreign exit the Nano editor press Ctrl o and Ctrl X now here is a small trick in a separate shell have the command Rockham SMI being updated every second this will allow you to see if the graphics card is indeed working and being utilized by torch it's a quick check and now the exciting moment we launch our stable diffusion launcher and see if everything truly works so bash launch sh during the initial launch a few files will be downloaded such as the stable diffusion 1.5 model and some further initializations will be performed which is why we use fast forward again after the start has been finished we are presented with a URL and part which we can open to access the web interface of automatic stable diffusion initially the GPU won't be heavily utilized as this is the initialization phase the full utilization will occur during the corresponding iterations of stable diffusion [Music] [Music] now we're getting started and the test is running it briefly showed 1990 percent usage in general the process is functioning though it might not be very impressive yet this is because we're currently using stable diffusion 1.5 model with a resolution of 512 pixels and randomly generated image to switch to stable diffusion XL we need to download the corresponding model data we can do this through hugging phase [Music] selects models and enter stability Aid company behind stable diffusion then the files for Excel base 1.0 Excel refine 1.0 and sdxl there should be visible for download [Music] since these files are quite large I've already prepared and downloaded them now we need to distribute the files into the appropriate subdirectories for where it's models and where [Music] and the other two files go to the models stable diffusion directory [Music] the copying process might take a while since these files are large again I'll fast forward and will be done [Music] now we need to inform automatic web UI to use the new model files for stable diffusion XL let's perform a UI reload then we can select Excel base 1.0 this might take a moment but I'll speed it up for demonstration next we need to adjust the settings for the wear part in stable diffusion in the settings and the stable diffusion we can select SD Excel way [Music] then press apply now we have stable diffusion XL [Music] I have prepared a prompt from an interesting website with a variety of engaging prompts I've also linked it below for your reference [Music] it's important to set the sampling method such as DPM as well as the number of sampling steps typically I choose 30. also make sure to set the width and high 2024 as stxl has been trained on these dimensions [Music] when we generate the content please note that the first run might take a bit longer don't be alarmed by this subsequent runs will be faster once the initialization routine is complete [Music] process is underway and we can already see 99 GPU utilization indicating that we are indeed running with Rockham and the graphics card with my radian RX 6800 it usually takes around one second per iteration while this might not sound very fast it's notably faster than on Windows which can be up to 8 times slower this highlights the advantage of using Linux [Music] foreign [Music] it took a while as I mentioned because it was the first run for generating an initial image as a demonstration it's not bad at all the concept should be clear now and you can proceed to input your own prompts as promised we won't stop at automatic web UI we also want to install compa UI [Music] with the prerequisites we've set up this process can be very quick let's copy the URL of the confi UI repository clone it using grid clone and swiftly Hefty repository on our machine [Music] I encountered the small mishap here I accidentally downloaded it within the automatic stability diffusion directory I actually wanted it in the home directory so I moved it there in parallel to the automatic directory now let's navigate to The Comfy UI directory and quickly started with python Main py the prerequisites and dependencies are the same so this should work seamlessly by the way the URL to start the UI directly is provided here [Music] before we take a look at the UI let's ensure that we've already downloaded the model files and placed them in the correct subdirectories once again under models we copy they and we copy the base and refine our files this time to the checkpoints subdirectory the copying process is fast forwarded as it takes a considerable amount of time and just like that it's done [Music] the initial workflow offered by confer UI isn't particularly suitable for stable diffusion XL however you can download a very good workflow from the zyton I think it's pronunciated like that website which I've linked below simply download the current Json file with the corresponding workflow [Music] [Music] we'll then load this into the UI in the browser [Music] don't be confused if the content doesn't appear immediately you may need to zoom out once with your mouse wheel and generate an overview [Music] the refiner and base models are already entered and after reloading you can input the prompts negative prompts and supporting terms you can also customize these later I've started the process and it will take a moment now the GPU isn't active yet SBI and the initialization phase similar to automatic web UI the first run takes longer now we can see the authorizations in progress yes the GPU is underload and you can see the progress bar moving it will take a bit more time as this time we are also running a refiner pass overall I can say that both automatic web UI and comfi UI are greatly accelerated by rockem and Linux much faster than on Windows [Music] as I mentioned before you can now enter your own prompts and you should quickly get the hang of it if you want to achieve more you will need to delve deeper into these workflows in my opinion both options are comparable in terms of speed I do feel that Comfort UI is more stable and has better memory management especially when generating batches of multiple images of course this process can be more complex that's why I plan to further explore this area in the future for quick and simple tasks automatic web UI remains a good choice now as promised let's have a very short look at the windows version which operates using Microsoft direct ml as mentioned earlier it's slower I've entered parameters similar to those of automatic web UI on Linux and you can see that the speed isn't enjoyable at around 8 to 9 seconds per iteration foreign [Music] [Music] utilized around 90 percent and not the 99 scene on Linux for reasons unknown however the overall performance is significantly lower than on Linux it's definitely worth installing this setup on Linux to enjoy up to eight times the speed compared to Windows moreover the windows version I'm using here tends to consume more memory and can freeze if this short tutorial has helped you get your AMD graphics card up and running on Linux with raw Cam and stable diffusion please consider leaving a like if you would like feel free to leave comments as well
Info
Channel: Next Tech and AI
Views: 8,466
Rating: undefined out of 5
Keywords: stable diffusion, stable diffusion tutorial, stable diffusion ai, stable diffusion xl, amd rocm, nexttechandai, automatic1111 stable diffusion, comfyui, automatic1111, stable diffusion on radeon, AMD GPU AI Tutorial, stable diffusion for amd
Id: QEbI6v2oPvQ
Channel Id: undefined
Length: 26min 11sec (1571 seconds)
Published: Sat Aug 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.