Beginners guide using automatic1111 and stable diffusion with AMD gpus! Tips , tricks, and gotchas!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there hbers and Engineers Fe engineer here so the other day we set up stable diffusion running on our AMD gpus and the video started to get a little bit long but I wanted to also include tips and tricks for using stable diffusion with AMD gpus as well as just some general help for things that you may run into and problems that you may come across so with that let's get into using stable diffusion and going through what we can do with our AMD gpus I do want to go over a handful of things that you may run into running automatic 1111 with AMD uh depending on the settings that you set for different things you may run across an error that comes through your command prompt saying uh kernel not found if you run into that error specifically all you need to do is hit contrl C which will bring up this terminate batch job tell it yes then hit up twice and then reload and that should fix the error if you happen to run into an error where it says something about allive cash cannot be found one time when I was loading a a new model I ended up with this error saying that all of cash could not be found if you run into that error here we are in our stable diffusion web UI direct ml if we look inside of models there is a folder called All of cash if at any point you run into something when you're trying to optimize a model or load a new model and it says that this allive cache folder cannot be found the way to fix it is to effectively just create a new folder call it all of cash with a capital o and a Capital C and then just hit enter so that you will have you will then have a folder called All of cash and that's really all it's looking for is just a folder with that exact name it doesn't have to have anything in it so if you run into that error just create a new folder call it all of cache and that should fix it for you those are the most common errors I have run into when running automatic 1111 on AMD however a another thing that you can do is inside of this folder you will notice this venv this stands for virtual environment and this is where Anaconda installs all of the virtual environment settings and things for this specific project so what you can do if things get really screwed up and you are simply restarting it won't work your Olive cache folder is in there but it's still just not running and you don't really understand what's going on you can literally just hit the delete button delete out this virtual environment folder and then once you delete out that virtual environment folder to get Anaconda to rebuild it what you do is instead of webui dobat use web ui- user dobat and then- show nx-- backend directml just like normal but the key is this web ui- user this will have Anaconda rebuild this virtual environment entirely now with all that being said if things are up and running the way you want only use the webui dobat file don't use web ui- user because web ui- user will also potentially pull in new new GitHub updates for some of the repositories you will notice inside of here we have repositories and inside of these repositories there are in fact more things every time you use that web ui- user it will try to pull all of these all over again and so when you use web ui- user if you have not used this for like a few months if you use webui dobat nothing should change and so if it worked before it should continue working if you use web ui- user you may run into a scenario where some of these repositories have updated and something effectively new is broken and so generally speaking you only want to use web ui- user if you are planning on rebuilding your entire virtual environment other than that I would not use web ui- user on a regular basis especially not to just start it up those are most of the problems that I have seen come through somewhat regularly and that should help you if you do run into those to be able to get around it and get stable diffusion back up and running some other command line arguments that folks may end up needing and I will have both some of the standard ones in the video description below as well as a link that goes out to show you all of the command line arguments but ones that some people may be particularly interested in is-- low Ram this is for exactly what you think it's for a GPU that has a low amount of vram generally speaking probably 4 gigs or maybe even less I don't think you could get it to run on a 2 gig card and on a 4 gig card it's going to be difficult so you will probably need to set something like low Ram there's also a medium Ram which does sacrifice a little bit of performance but it should help if you uh are running out of RAM on your video card setting something like this will help as well as there are tons of different different ones uh that you can essentially set for like split attention and sub quad attention and these are ways to utilize your memory a little bit more efficiently generally they do come with a bit of a performance trade-off so for folks who want to be maximum lazy and don't feel like typing in these command line arguments every time you can just do it this way and the reason why I like using webui dobat instead of web ui- user is that web UI bat if it works today effectively I should never need to change anything and it should work tomorrow next week next month because it's not trying to update any of the GitHub repositories whereas web ui- user does tend to try to update GitHub repositories I'm going to try to keep this video very straightforward and very straight to the point because we have quite a bit to go over in order to run your stable diffusion with Anaconda similar to what we did when we set it up you can type in cond info D- envs this gives you a listing of your different cond environments that you can enable in order to enable an environment cond activate and then the environment name so sdore Olive you can tell that we're now in our activated environment because we're at sdore Olive instead of Base the command just like when we set it up to run stable diffusion is webui dobat D- nx-- backend direct ml once this has finished loading you will see running on local URL 1271 7860 and then you should be able to go to your stable diffusion generating images in stable diffusion is done by using prompts and stable diffusion uses a prompt and a negative prompt think of the prompt as the things you want to see in the image and the negative prompt as things that you specifically want to not see in the image let's go through a very simple example of this for a prompt you could have a a girl and for the negative prompt well let's just generate this prompt a girl you can tell this is exceedingly non-specific and we'll just say that while she looks a little bit odd here we'll say she's wearing a white shirt and we'll say that we don't want to see that white shirt well she is no longer wearing a white shirt so you can see that the negative prompt can be used as a way to control effectively variables when building prompts there are two ways of doing it if you search the internet and look for best prompts you may see things that come out looking like this a girl wearing a black shirt with a red hat who has green hair running in a field of wild flowers and on the internet many times they will not get give you a negative prompt at all and if we hit generate this may produce an okay result but honestly I mean that's kind of okay I guess it's somewhat reasonable I find that these long senten like prompts are not necessarily the best I like to separate the things I do want and then negative prompt a whole lot of things that I don't want but what I do is I keep it in very very small digestible pieces for the AI and what I mean by that is a girl with green hair comma Red Hat comma field of wild flowers and then if we just hit generate from that we will probably get something very similar again to this actually that kind of looks better overall the the eye is a little odd but other than that and I don't know what this is but I find that the AI does significantly better when you tell it very small blurbs of things that you want and you affect let the AI put it together you'll see here I put red hat in it put the Hat on the person it doesn't have a hat just floating off in the air so there's a lot of times where you don't need to be so overly descriptive to say a girl wearing a red hat you can put that in if you're going to leave it as just that but I already had a girl with green hair and saying wearing a red hat is just making it very complicated for the Ai and instead I can just say a girl with green hair cuz I want a girl with green hair and then I can just say red hat other things that will significantly improve your experience are things that you don't even think about stuff like professional photography professional lighting professional color grading 8K ultra realistic photo realistic Dynamic lighting Ray tracing HDR and then what we want to use the negative prompts for is separating out things that we really really really do not want and stuff that we do not want is stuff like low resolution medium resolution ugly mouth formed deformed oh another common one that you can put in the top is Masterpiece extra limbs extra digits three hands three legs gross text artist name these are very common things to potentially put in that helps to just weed out kind of bad examples whoa I find that sometimes faces get really strange let's just regenerate so you'll see we've regenerated quite a few times and we keep having kind of messed up faces the sampling method seems to affect this quite a lot and so by changing over to uler ancestral pretty much right off the bat I got a great result this is a really good picture overall you'll see the face is unbelievably better even uler seems to work very well uh my generally the ones that I use all the time are going to be uler or uler ancestral I mean these images are really good and compared to the one that I was just doing you can tell that I mean I ran it three separate times and got really odd faces changing my sampling method over here significantly improved things next up after messing around with using prompts to generate the image that you want sampling steps effectively this is how many times it will go over and take a look at it and potentially make refinements if you're using a card that's fast enough you really want to bump this up if you can you will just tend to get better images out of more sampling steps although you can tell that even at only 20 sampling steps it's possible to get really good results but let's bump this up to 150 all the way up and see if this does better I think there's a bit more detail in this one and you can see that the the photography part you know the the landscape is is somewhat defocused and the uh the foreground is more focused so keeping your sampling steps up it takes longer to generate every image but if you have a fast enough card you should definitely consider bumping up the sampling steps moving on to the next piece with AMD cards I have noticed this highres fix simply does not work you can try it out if you want you can add highres steps if you want I have just not been able to ever get it to work appropriately it just does not seem to work the refiner the refiner is only for using stable diffusion XL models and those models include both a base and a refiner I have gotten them installed I have gotten them to technically run I have never been able to get this refiner to actually work appropriately and because of that when you run stable diffusion XL it doesn't matter what you're running if you're running the base model the refiner then effectively if it doesn't trigger the refiner you will not get good results so while I have gotten stable diffusion XL loaded in and running I've never been able to get the refiner to work so I've never gotten good results because the refiner is required moving on to the next piece width and height this does exactly what you think it will change the width and the height of the output image I would not generally recommend changing it from 512 and the reason why is because when you are putting in prompts and you are testing things out and you are trying to get an image that you like generating at 512 512 is where you're going to see really good performance if you generate say double the size at 1024 x 1024 it will take roughly four times longer to generate an image and if you are trying to get an image that you like generate them at 512 or you could potentially even go smaller to generate them quickly once you get an image that you like even at a smaller scale then you can upscale it by a multiplier so effectively from 512 we could multiply by two and get 1024 by 1024 and that is why I do not recommend changing the width and height here however if you want to get a different aspect ratio instead of a square we could do 1024x 52 and now we will get a more landscape looking shot although you will notice because we now have a lot more pixels that we're generating my iterations per second has significantly dropped but we now have a different aspect ratio image the batch count I'm going to drop this back down to 512 what the batch count does is it effectively tells stable diffusion use all of these settings and because I am maybe looking for interesting ideas or things like that just automatically create X number of images and so what it will do is it will run one entire image it will stop and then it will run a second time time and then a third time and it will run the number of times of the batch count graphics cards that don't have as much vram will significantly benefit from it stopping and starting because it effectively allows it to offload uh stuff out of memory and once it generates the images you will see that it it gives them to us in a nice little grid and you'll see that all three of these images looked fairly good if you drop the batch count down to one and take the batch size and move it up to three when we hit run now you will see my iterations per second are no longer 20 now it's 10 but I did get three images again so effectively it ran three but it ran them all at the same time again for cards that are lower in vram you may not be able to change the batch size at all it may effectively run out of memory and stop working so if you're on a higher memory card you can probably use batch size if you want you will get slightly better performance because you're able to effectively run all of the all of the images in one pass even though it's doing multiple images versus batch count which has to do one then stop then start then do one then stop then start but so it's going to depend on the amount of vram that you really have as to whether you can use batch size and whether you should use batch size CFG scale basically tells the AI how closely of attention to pay to exactly what your prompt is CFG scale of one gives it a large amount of creative freedom and a CFG scale all the way at 30 effectively tells it to have little to no creative freedom and to just basically do exactly what is in here and the default is seven I find that that typically works very nicely it's a nice mix between creative expression but still following your prompt but what we want to do is we want to upscale this image so let's click on this little button right here this is the inpainting button so go ahead and click on that and so you'll see that it moved this girl into here and there's another one over here what we can do is use just resize change the sampling method to not be terrible change the sampling steps we want to do 150 because we really like this one resize by two this should resize it from 512 to 1024 and you shouldn't need to change your prompt if you do want to change your prompt you can and by changing your prompt in here it will effectively tell it when it's using this as inspiration to maybe change a bit or a piece of it you'll notice since we're generating a much larger image the iterations per second have dropped substantially and so now now we have another great image only now it's 1024 instead of 512 as this is mostly a beginner's guide I am not going to go over all of the finer details of training and Hyper Networks and Laura and things like that there is a settings tab inside of the settings tab there is all sorts of options to choose from and things to effectively play around with until you get things that you like um generally speaking for most people you shouldn't necessarily need to make very many changes to the settings but just know that there is a lot in here thank you so much for watching my videos hbers and Engineers I create and edit all these videos on my own so any likes and subscribes will massively help out the channel and allow me to continue creating content to help people if you got value out of this please consider liking and subscribing to the channel to be notified when new content drops if there's something I've not covered but you would like to see a video on it please leave a comment down below and again a massive thank you to everyone I hope you have a great great day
Info
Channel: FE-Engineer
Views: 1,942
Rating: undefined out of 5
Keywords: Stable Diffusion, AMD, DirectML, ONNX, Olive, Automatic1111, AI
Id: tQ0lc_Mq1rE
Channel Id: undefined
Length: 25min 30sec (1530 seconds)
Published: Sun Nov 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.