How to run Stable Diffusion on AMD Graphics Cards | AI on AMD Graphics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] yo what's up man it's ryen Phoenix back at it with another video and today I'm going to show you guys how to get stable diffusion running on AMD radi on gpus this tutorial specifically for Radon 6,000 and 7,000 gpus so if you have a 7900 XT like me or if you're running a 6,800 or 6600 or whatever this tutorial will apply to you as well this tutorial will be done my second computer that I will be connected to using the windows remote desktop software so if you see any visual or audio glitches just know that it's most likely because I'm connected remotely in any case doesn't matter because the setup and execution are the same anyway all right so before we begin uh I would just like to go over some of these system requirements obviously you're going to need a radon 6,000 to 7 or 7,000 GPU with the latest drivers installed you'll need to be on a 64-bit version of Windows 10 or 11 I don't think it matters how much much RAM you have in your system but I would recommend having at least 8 GB and if you're a gamer you should have this installed on your on your system anyway the CPU doesn't matter either just use whatever you have I'm running a ryzen 5 3600x and my GPU is the Radeon RX 6800 which I will show you right now by opening task manager so as you can see here the GPU is the RX 6800 and my CPU is the ryzen 5 3600x before we continue I just kind of want to go over what stable diffusion is if you already know what it is then just skip to the next chapter of this tutorial because this won't apply to you so what is stable diffusion so unless you've been living under a rock for the last couple years you you'll have heard of artificial intelligence known as Ai and images generated by AI stable diffusion is a software that allows you to generate images using AI by simply giving it some instructions to work with these instructions are known as prompts and they are split into positive prompts and negative prompts I'll explain this later in the tutorial but for now just know that positive prompts are what you want the AI to generate and negative prompts are what you don't want it to generate stable diffusion is free to use if you have the hardware capable of running it so all the stuff you see in this tutorial is free and you don't have to pay for any of it the support for AMD is actually quite limited so we're going to have to install an alternate version of stable diffusion which has been made compatible with AMD graphics cards to install and run stable diffusion we're going to need four things number one Git Version Control software Toto git to interact with Git Version Control Python and the stable diffusion direct ml repository I'm going to I'm going to explain these each one of these one by one as I uh go through the process so let's start by installing git you don't really need to understand how get works but just as an overview get is a Version Control software that allows software developers to keep track of changes that have been made to code bases all right so to install G we need to open up our web browser and type get SCM into Google and then hit enter on our keyboard we then go to the get SC website we go to downloads windows and then we click on the 64bit get for Windows setup to initiate the download all right so once that's done we should find the download in our downloads folder so we're going to double click on it select yes select next next next next next next next next next next just keep pressing next until you start seeing the installer running [Music] all right and that's it so get uh version 2.42 has been set up on your computer you want to untick this and then click the Finish button one of the key ways you can know when get is installed is when you right click in a folder and you see these two options here so so get open get GUI here and open get bash here all right so next we want to install HTO get so we're going to go to google.com again and then type in ttoys get hit enter on our keyboard go to ttoys get.org click the big download button and then click on the download for 64-bit Windows to initiate the uh download all right so when we open up our downloads folder we should find the installer here we double click on it hit next then hit install so you're going to want to make sure that run first wizard is tched okay so this git.exe path should be filled in automatically if you follow the tutorial so if you install get before installing Toto git um you should uh have this already uh filled in but if it's not you just simply need to copy the path that you installed get in and uh paste uh paste it into here so I installed it in uh program files get bin and uh all I need to do is highlight this right click copy and then just paste it into here and that's it so once you've got that sorted out you click next you take don't store these settings now unless you uh well unless you want to of course but you don't need to do that this tutorial you click next and then you click finish so that should uh install uh Toy to skate fully and set it up so next we are going to install python so if we go back to google.com and we type in uh python download now the the specific version that we need to download is version 3.10.7 so you add 3.10.7 to the uh end of that and then hit enter the keyboard so it'll so what you want to do is go to this python release python 3.10.7 page and we scroll all the way down and until we see windows and solar 64bit we just left click on that to download python then if we go to our downloads folder we should find python so we want to double click on that to start the installer so what you want to do is make sure that the this specific option is ticked you absolutely have to make sure that this is ticked or you will have problems later on after that we just uh click the install Now link select the yes [Music] [Music] here is [Music] all right so once the install installation uh is complete you can just click the close button and that's it you don't need to verify anything uh to make sure that python is installed it should it should be all good all right so the final step is to is to download the stable diffusion direct ml repository so we're going to head over to Google and we're going to type stable diffusion direct ml H enter and it should be the first link that you see here uh if we click on this stable diffusion web UI would direct ml it should take you to this repository by uh this guy uh is I'm not going to try to pronounce that you'll know that you have the correct repository when you see this guy followed by the slash uh then stable diffusion web we web UI direct ml so what you want to do is come over here where it says code you want to left click on that make sure https is selected if it's not just left click on it then you want to come over here to this button and then left click on it to copy this URL and then you want to come over to your file explorer now you'll need to select a folder that you want to store staple diffusion in so me personally I'm just going to store it in the root directory of storage drive one so I'm going to right click I'm going to select get clone and what you should see is that the URL that we just copied from GitHub it should already be populated here in the URL section if it's not you go back in here left click on code highlight this right click copy and then go back into tortoise skit and then just paste the URL here the directory should already be populated so you you don't need to worry about that but it's basically this path here to the folder uh that you want to store stable diffusion and so I'm sewing in E and it's going to create this folder stable diffusion web web UI direct ml inside e so you don't need to do anything else but press okay [Music] all right after that you just click on close and that should be it as far as cloning the repository but before we conclude the step I just want to show you one very important thing that you need to do right after clone in the repository so we're going to go into the stable diffusion folder we're going to look for we're going to go scroll all the way down to the bottom until we find a file called Web Web ui- user which should be a Windows batch file so we're going to right click on it we're going to click edit and it should open up a notepad or whatever your default text editor is and then we're going to go to this first line here where uh just before the at symbol we're going to click we're going to press enter twice on our keyboard to create a couple of lines just like that and then we're going to go up to the first line using the arrow keys and then we're going to type get pull and then we're going to click file and then save and then we exit so what we've just done right there is we've just hold uh get we basically every every time we run this file it will run the get pole command which tells get to pull the latest working copy of this Repository so this will ensure that you are always running the latest version of the repository with all the fixes patches and all the updates you don't necessarily have have to do it this way you can always with Toto get installed you can always go into this folder right click into the folder and then go to the toy toys get submenu here and then all the way up to the top at the top you just left click on get pull and if you click okay it will pull all of the latest updates uh from the from GitHub and that's it but me personally I prefer doing it this way because it saves me the time of having to go into the folder every time and then try trying to pull the latest changes every single time so this is just a much more efficient use of time all right so that's kind of the basic setup uh so now we're we're going to go into um actually running stable diffusion so every every time you run stable diffusion you're going to have to run it through um this web UI user batch file so what I like to do is like I like to right click on the on the file and then go to send to and then left click on desktop to create a shortcut so we can now see that we have a shortcut to this exact uh file on our desktop and we can simply rename the shortcut to something like stable diffusion uh DML for direct ml right and then every time we want to run diffusion we just double click on the folder uh on the shortcut and you're good to go so that's what we're going to do right now so it should open up a command prompt window and uh you you'll see that uh it runs the G paole command first and then uh starts the setup [Music] process all right so the setup process is now complete so as you've just seen um it had to uh download um a model which is what's responsible for actually generating the images themselves so after the setup process is complete it'll give you a URL that you will see here a local URL so it should say running on local URL http1 1270 whatever this URL is so what you want to do is while you're focused on on the uh command prompt console or whatever is you want to hit control control on your keyboard and then left click on the address to open up the stable diffusion web UI and this is basically why you'll be doing all of your stuff you know uh generating all of your images okay so the next part is to actually test to see if it's working right and the only way to do that is by giving it a prompt and uh you know just giving this some data to work with to uh generate an image so if you haven't used this before um you're going to need uh some test data right so what I recommend you do is you open up a new tab and then go to prompt hero pump hero.com right so this serves as let me maximize this so This serves as kind of a a hub for uh you you know AI generated images and it gives people that are viewing uh you know information on how to create uh any of these uh images that you see here so what we're going to do is is scroll up to the top and then uh we want to go to the search by model section and then select stable diffusion we just left click on that and then on the version section we left click on 1.5 so we sort in by version 1.5 so you then scroll through here and uh just basically find something that you like right let me close this down so I'm going to scroll back up and yeah let's let's uh select this to work with right so what we want to do is essentially just kind of copy all of this right so this is this gives you this gives the model and stable diffus details on how to recreate this image right uh so we just want to right click on that after we've highlighted it we click on copy and then we paste it into here and then uh for the negative prompt we highlight this this bit like so right click copy and then paste it into the negative prompt um section so remember earlier how I said um prompts are divided into positive prompts and negative prompts so positive prompts are what you want negative prompts are what you don't want so as you can see this guy over here or this uh woman or whoever um he went into full detail telling uh stable diffusion exactly what he wanted you know Smoky makeup wild blonde hair uh best quality super detail etc etc this is what he wanted right uh and then this is what he didn't want 3D cartoon in anime sketches y y y right so he obviously went through a lot of experimentation to find out what he didn't want and uh what he also wanted in combination the two helped produce this uh image that you're seeing here but I'm going to it's not the only thing that help produce this specific image I'm going to get into that in a little bit so once you've got your positive and negative forms inserted um the only thing left to do is click the generate button but before we do that we're just going to right click on the taskar and uh open task manager and then we are going going to go into uh the performance uh tab here let's just pin task manager to the right and then our browser to the left so we go to the GPU GPU section right here so the aim of the game is to make sure that the 3D uh section in the GPU tab is at like 90 plus 90% that's how we know that's stable diffusion is actually using our GPU to uh create the image so with everything set we are going to click the generate button all right so we can see it running already it's about 25% complete and it gives you an ETA on when to expect it to be done and we can see over here that the uh GP utilization is like uh 97 98% which is a very good sign that's how you know that your GPU is working and we can see here in the uh dedicated GPU memory usage SE section that the memory usage has actually gone up and we are using 8.2 GB out of the 16 that we have um I'm going to talk about memory a little bit uh later just to give you uh some more information on that but basically the more you use stable diffusion um in one session the more memory uh it's going to consume and that comes with a certain pitfalls all right so you can see that um the uh soft has actually created the image but you know uh let's be real it it's not that great you know it's it's not um you know the eyes are up they're messed up you know uh it's just not the best so it looks nothing like what we're seeing over here right so the reason why the these two look so different is because um because of uh a different this guy or this woman used a different model right or checkpoint right so different uh checkpoints do different uh things they produce different types of images so what you have to keep in mind is that checkpoints are trained to do uh to generate specific types of images uh based on uh based on the prompts that are given so if I put these prompts into a different checkpoint it's going to produce a different image and I'm going to show you that right now all right so we're going to open a new tab and then go to sa.com that's C II T ai.com hit enter on our keyboard and uh this is another website where you can see examples of uh AI generated images and and the cool thing about it is that it gives you access to the checkpoint that allowed people to create that images so you can pretty much scroll through here um if you click on the model section to sort by models and uh scroll through here uh find something that you like like uh I don't know uh yeah something like this I guess and then uh you simply left click on the download uh to download the actual checkpoint and it gives you examples of what kind of images to expect so you can see some people have created some realistic looking images right here which is uh super cool but the one that I like to uh use is called NeverEnding dream so if I okay let me type never yeah never ending dream Ned so about 3 GB so what we're going to do is left click on this to download the uh checkpoint and it should start downloading the checkpoint all right so if we look in our downloads folder the checko has been downloaded so it should have the uh save save tensor uh file extension if it comes in a zip file you'll just have to extract it from that zip file and and then uh basically just right click on it copy or cut right and then paste it into the stable diffusion folder now in the stable diffusion folder you'll have to go to models stable diffusion right click and then paste it okay so the copying and pasting is now complete and we should be able to use the new checkpoint so if we minimize this and then go back to our stable diffusion uh browser Tab and then uh we click on this little refresh icon click on it and then we click on this Arrow here we should be able to select the new NeverEnding dream uh checkpoint so left click on that and you should see this processing uh thing over here cool so the new checkpoint is now has now been loaded so with the exact same um positive prompt negative prompt and generation settings we're going to just click on the generate button to see uh the different kind of imag that'll be generated here so let's go all right so as you can see the image looks a lot different right it this looks more uh it looks like less a bit less realistic and a bit more you know kind of um fantasy kind of mix with a little bit of anime with a with a bit of realism as well kind of combined which is uh why I really like um this checkpoint it's a very interesting one uh so as you can see uh if we if we click generate again uh it's going to generate a completely different image all right so this is the new image yeah that looks uh a lot better yeah I like that cool so um I'm now going to get into uh some of these settings over here right I'm going to with seed right so every time you generate an image using stable diffusion you it creates a unique identifier for the image right and that's called a seed so what you basically use a seed for is for situations where say you like an image that you have generated or an image that you have seen here or here and you basically just copy that seed and paste it into here uh let me right click this copy paste it into this field right here so you when you do that you're you're telling stable diffusion that you want an image that is similar to this right uh similar if not almost exactly like it right so it's very useful for when you want to work with a specific image so with this in mind uh I'm going to um crank up the size so this batch size option tells stable diffusion how many images create to create per batch right so we have one batch which is one uh generation Loop and in each Loop it creates two images right so if we have the set two and the set one it should give us two images so if we go go up here and then click generate all right and there we go so it's created two two images in this one batch so this is a snapshot of the two images side by side and we can look we can use the slider here the uh image slider here to look at each image uh individually and uh that's how you would use the batch size uh option to create multiple images uh per batch now you should be careful about the batch size being too high because if your vram is not big enough you'll have an you'll have a a situation where it produces an error because it doesn't have enough memory to complete the uh the generation right it doesn't have enough freerun to to generate the images the next thing that I will uh talk about is the sampling steps so sampling steps is basically how how much detail you want stable diffusion to uh go into when generating the image this can help up uh you know clear uh stuff like uh you know uh weird looking eyes you know mangled up fingers etc etc uh or maybe situations where you have hair follicles going through the ear or whatever like that you know so the the the more sampling steps there are the more I guess iterations that uh stable diffusion will go through when generating the image to produce a a much higher quality image but the high High you go the more GPU horsepower will be will be needed so if your GPU is not a specifically powerful one you will it will take like hours to uh you know generate a single image sampling steps is best used when you have an image to it a final image that you really want to perfect like for example if I if I wanted this one out and I really wanted to perfect it I might increase the sample steps to like I don't know 80 uh see what happens uh if not then uh 100 etc etc so you don't you shouldn't just kind of crank it all the way up to to maximum what you should do is kind of Crank It Up incrementally So maybe from you go from 20 to 40 to 60 to 80 and then to 100 but there comes a point where um you get diminishing returns where you have the slider at a at a very high value um and it takes a long time to complete the image but the image did not necessarily necessarily look better um than it did before so you're going to have to kind of like experiment I I probably wouldn't go above 80 um unless I am I was really really really uh trying to perfect things um to make things as perfect as possible but I think 80 for for most people should be the stopping point really okay so the sampler method also has a part to play in the image generation so each one of these I haven't really messed with all of these uh I've only messed with with a few um but each one of these will um you know create um a different type of image so if for example uh you wanted maybe a bit a more a slightly more cartoonish image uh you can play around with each one of these until you find one um that kind of uh suits your needs um so I'm not going to touch this uh because this is kind of more like a basic tutorial uh you're you're just going to have to experiment this on your own but different sampling methods have they tax the GPU uh differently so some may use more memory than others some may use less etc etc uh Harris fix is basically when you want to um upscale the image from say 512 to whatever you've got here to a much larger one um but it uses a ton of vram so if you if you don't have a lot of vram uh you're going to suffer with this now I know the 6800 has 16 GB of vram and you might think that oh that's enough but not really if I crank this all the way up to say uh if I crank the width and height to say 1024 uh 1048 by 1048 um it's going to give me memory errors telling me that I don't I don't have enough memory right if I uh keep this at like 512 by 512 and then I use a sampling step a sampling method to upscale the image to say 1024 by 1024 it's still going to give me memory errors because I just don't have enough memory yeah it's surprising that 16 GB of memory is not enough but hey you know it is what it is so be careful when using this but it's it's it's free to experiment with and I think all of the options here are self-explanatory except for this upscale upscaler option uh it this is just this is much like uh the sampling method option here so each upscaler Works differently and you know produces different results so you're going to have to experiment with each and every one of these until you find uh the one that suits you best for your for your um for the result that you want so we're just going to minimize this so it doesn't use the options so CFG scale is how um much creative freedom you want stable diffusion to have so the um the higher the CFG scale the less creative uh you want it to be and the lower the more creative you want it to be so um I think the default here is like a seven and and uh that produces you know decent results and then you can just kind of tweak this option to whatever you want um to achieve the result that you want so now I'm going to talk about this uh image to image um option okay so say uh you have an image that you like um whether that's an image that you've generated here or maybe say uh an image that you've downloaded from Google like this one for example example if I go to pictures and then I select this Bugatti shiron over here and then I move it over into the uh into the window here and then I say uh here Bugatti uh shiron speeding with no negative prompts uh what this will do is is it'll take uh this image uh merge it with the um prompts that you put into here and produce a new image based on the combination of the two so if I hit generate here and there you go you can see that it's taken this Bugatti over here uh with its colors and uh you know lights and everything like that and uh it has created a new image where the car is actually speeding on a racetrack and that's just incredible right and then obviously um you can go down here and then uh just like the uh text to image option you can tweak the sampling steps and uh you know CFG scale and etc etc to uh fine-tune your image to your liking so yeah I mean that's pretty much it right uh when it comes to Genera the images the last thing I'm going to show you is where the images are actually stored so if we go back to file Explorer and then we go to the stable diffusion um folder so that's uh stable diffusion uh then we click on outputs we click on uh text to image images the date folder so you can see right here that uh it has uh stored all of the generated images here so if we double click on this we can see some of the images here uh well all of the images here that have been uh stored that have been created sorry so um to see the uh image to image imag is like the one that we've just created here you double click on that folder and then yeah there you go that's the Bugatti Chiron uh speeding on the RAC track yeah and uh that's it uh oh uh this for fer contains all of the grids but this is not not all that useful really so yeah so that that's pretty much it with regards to uh stable diffusion so like I mentioned earlier the more you use the software the more you use the software in a session the more vram will be consumed within that session so um there are two ways to get around this right the first way is once the once the vram has reached its peak and you start getting V errors um you can close stable diffusion by going over to this console here and then uh clicking on the close button right so this will terminate the session and then you then uh go back to your desktop double click on this um shortcut that we created earlier to restart the fusion and then you can get back into uh creating your images again the second way of uh overcoming this difficulty is by uh um uh adding some modifications to the um to the we web user um batch file so we open this if we edit it again so there'll there'll be uh a a setting here called command line augs so command line arguments so this basically tells stable diffusion uh how to run within its a given environment so for vram specifically there are um a few uh uh command lines that we can use all right so if we go to Google and then type in stable diffusion augs and then uh look for this one command light argument and settings and uh make sure it's by automatic 11 one1 if we scroll all the way down we just see a list of all of the arguments that we can use um for setting up uh stable diffusion in the current environment so we can just hit contrl F on the keyboard to search for vram and uh the ones that we're looking for a medium vram and uh low vram if we just uh highlight this right click on it copy and then go back to the uh web user UI after this equal sign uh after command line ugs we just right click and paste right and then we we just click file save and then hit the cross now we're going to restart stable diffusion by first closing it through the terminal then we close our browser session we go back to our desktop double click on the shortcut and then St uh fire up stable diffusion again so now this time we're running with medium vram as you can see here cool so we're back and um this should kind of help fix some of the vrm issues at least that's what I did when I uh tested it on my uh radian 6800 um a while ago and yeah that's uh that's pretty much it um that's pretty much it to get you started like I said this is not like a a super you know in-depth tutorial it's just to kind of uh get you started get you up and running get you um generating your images and kind of uh figuring out how stuff works so stuff like this is you know it's your best friend to uh you know see what you like and try to recreate it you know download new um checkpoint point and just uh experiment and figure out uh what you can achieve with the software and uh yeah it it's something that can uh really that you can really put hours into and uh you know uh produce very uh interesting results so yeah that's it for the for this tutorial man uh I hope you guys uh found this useful and uh you know if you did drop a like drop a comment whatever you whatever you want to do uh yeah and I will catch you guys in the next one [Music] peace
Info
Channel: RisingPhoenix
Views: 8,614
Rating: undefined out of 5
Keywords: stable diffusion, stable diffusion tutorial, stable diffusion amd, stable diffusion radeon, stable diffusion rx 6800, stable diffusion tutorial 2023, stable diffusion directml, stable diffusion web ui
Id: ePM61L_gq0U
Channel Id: undefined
Length: 40min 45sec (2445 seconds)
Published: Fri Oct 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.