(OUTDATED) How to install XFormers and run Stable Diffusion 1.5x faster on 4GB RAM
HTML-код
- Опубликовано: 28 май 2024
- XFormers is a library by facebook research which increases the efficiency of the attention function, which is used in many modern machine learning models, including Stable Diffusion. First we look at why the XFormers is so effective, then we actually install XFormers locally to achieve a 1.5x speed boost.
Discord: / discord
Profiling Outcomes: docs.google.com/spreadsheets/...
00:00 - Summary
00:45 - XFormer Explanation
09:32 - Initial Benchmark
11:16 - Install Webui
14:17 - Install Python
16:42 - Install CUDA
18:26 - Verify Webui Installation
22:22 - Install Visual Studio
23:48 - Install XFormers
32:10 - Results
------- Links -------
Article I stole (B I G thanks to Matthieu Toulemont): www.photoroom.com/tech/stable...
Github Guide: github.com/AUTOMATIC1111/stab...
Reddit Guide: / automatic1111_xformers...
Rentry guide: rentry.org/sdg_faq#xformers-i...
Xformers Github: github.com/facebookresearch/x...
Webui repo: github.com/AUTOMATIC1111/stab...
Download Visual Studio Installer: visualstudio.microsoft.com/do...
Download CUDA 11.3: developer.nvidia.com/cuda-11....
Download Python 3.10: www.python.org/downloads/rele...
Git for Windows: git-scm.com/downloads
------- Music -------
This Video: • Video
------- Thumbnail -------
Images from (many thanks): / 1579542236597215232
#stablediffusion #aiart #xformers #tutorials #techtutorials - Наука
🚫🚫🚫🚫🚫It seems like there is a MUCH easier way to install xformers 🚫🚫🚫🚫🚫
I made a walkthrough here: ruclips.net/video/ZVqalCax6MA/видео.html&ab_channel=koiboi
ALSO some common errors:
(1) failed with exit code 4294967295
(2) Cannot open compiler generated file: '': Invalid argument
Both indicate that there are issues with paths being too long, so you need to move your webui directory directly into the C:\ drive to make the path shorter.
If this helped, thank Ceaseless Vibing in the discord for prompting this addendum!
If you are running an older card (older than Pascal, Turing and Ampere (1000, 2000, 3000 series))you need to build xformers yourself and force the webui to accept it.
Some anons have reported significantly worse performance with xformers on 700 and 900 series cards, consider this before you proceed.
For newer cards the same is true, build Xformers! RTX 40 series Ada Lovelace users will need to follow this guide until the new one has implemented this feature.
For subsequent times when you open the WebUI, can you use the command prompt to open it, or do you still need to open webui-user.bat each time? Is there any explanation of this in the video at what point?
Dude full hand holding guides - big thanks n’ would appreciate more like it (Stable diffusion related or others). Ty beast.
no worries dude, I'm also doing it to learn myself. Any specific topics?
This is really helpful, I'm going to test it later and hopefully it means I can add my laptop to my intranet and get that to generate images, whilst I work on my main PC. My laptop has a very basic old Nvidia GPU, but this might make it possible to become an image generator for me.
My god, you are my hero!! I literally pulled my hair to get this working, finally I saw you mention that you need Visual Studio Community 2022 to make it work!! You saved me from getting crazy!! 😱😱😱
I know it's outdated. But the quality of the vid and information is amazing. Also digging the chill music.
Matt has some great stuff in the work for Photoroom and the free stable diffusion their site is using.
you can follow the steps in the git they are good but this video is great for the requirements part awesome man thanks smooth installation
This is great, thanks a lot 😊
Worked fine for me with Cuda 11.7 and VS 2022, no build errors.
Niiiiiiice, this is VERY good to know
Very Good info!
i have an rtx 30xx. just had to add "--xformers" in the bat and all was installed automatically. Just need to edit "Webui-user.bat" and set: COMMANDLINE_ARGS= --xformers. This trick works only with 30xx serie. Older gpus require different installation of xformer and probably require all steps as you explained in this video.
wait... really? ok I'll look into this!
@@lewingtonn i'll send you the exact line were to add this code, once i'll back at home
@@lewingtonn Can confirm, just add is to the webui-user.bat and run that bat and you'll see it install. set COMMANDLINE_ARGS= --xformers
@@lewingtonn yip works on my 3060ti. had tried earlier with failures until i realized my automatic1111 webui was a week behind with its updates...
Thanks. Seemd to work with my gtx1050ti as well. Cuts 9s of generation time on a 512x512 20 step generation.
Very cool thank you!
So there isn’t any catch at all? Just faster and cheaper?
I mean why would anyone not want to use this. Locally or not
I couldn't be bothered, but will check it out now.
Thanks for this!
Desperatly want to try this on my Steamdeck, runs sooooooo much better with XFormers on my 3080ti around 17it/s now.
You only need to edit the webui-user.bat (and run that bat afterwards) with the following addition. set COMMANDLINE_ARGS= --xformers
webui-user.bat calls webui.bat, which will create a new python venv (I believe that's why he runs process.py directly to dodge new venv). I manually edited webui.bat to not do that.
I couldn't get this to work. my webui director is called C:\StableDiffusion Automatic1111> That is where I open up .\venv\scripts\activate in cmd line right? I keep getting "not recotgnized as internal or external command et c. Cana't see to figure out how to do that venv part
so even after adding 'set NVCC_FLAGS=-allow-unsupported-compiler' i still cant build xformers. not exactly sure why but I still get an error.
My Stable Diffusion is installed on a different drive, not on Disk C. How can I run it in cmd.exe when drive C is the default?
i was able to make it work, stable diffusion on an AMD card, with this command "set COMMANDLINE_ARGS = --lowvram --precision full --no-half --skip-torch-cuda-test" ..I have 16gb of ram and 4gb of graphics card but it's still sooo slow. 3-4 hours to create like 3 images.. does xformers work for AMD? Or is there something to make it faster when generating images?
So if my PC can do 768x768 at it limits, then with XFormers i can raise limits?
Thank you for the great guide.
Does anyone happen to know if this also speeds up textual inversion and/or hypernetwork?
What makes image generation faster, is it the graphics card or what? Is NVIDIA 4 and 6GB good or not?
⚠ UPDATE:
If you use a Pascal, Turing or Ampere card, you shouldn't need to build manually anymore. Uninstall your existing xformers and launch the repo with --xformers. A compatible wheel will be installed.
I'm stuck on the pip install -r requirements.txt
It keeps saying access denied. What can I do? 😭😭
Hey man, I've been able to run SD without a problem in my machine, but I can't really generate in the highest resolutions yet because it's not that new of a GPU. Do you think XFormers can help out my performance?
yes, for sure, Xformers makes the memory requirements lower at all resolutions (though my other video on Xformers is probably easier to follow)
CUDA 11.8 here and xformers working fine.
on NVIDIA GeForce GTX 1650 4GB Vram is it possible? CUDA Core : 896 Asus TUF Gaming, please answer me. i would love to use stable deffusion!
thx for this bofore this I could only render 500x500 now I can go to 1000+
dear is nividia 4-6 gb is good or not for stable diffi
Is this only for Nvidia cards because stable diffusion doesn't work to well with amd.
It's annoying hearing works on 4gb but not saying Nvidia.
Might want to start saying works for Nvidia, amd sometime later at beginning of the video.
yeah, my apologies, there's lots of things to keep in mind
HOW LONG DOES SETUP PY DEVELOP FOR XFORMERS take? It's been 30 minutes and nothing is over
when using "pip install -e ."
I got an error
"No CUDA runtime is found, using CUDA_HOME="
"NameError: name 'this_dir' is not defined"
any help
I got the Same error
This Boomer here can't thank you enough for this. Thank you!
tks u so much 😍
hey, i'm getting an error while running the ai, it says this: File "C:\stable-diffusion-webui\modules\sd_hijack_optimizations.py", line 18, in
import xformers.ops
ModuleNotFoundError: No module named 'xformers'
do u know how to fix it? the xformers installation went perfectly fine, no errors
same
This approach is a "little" bit helpful if you have an AMD or No GPU or under 8GB.
But if you want a taste of the intended performance using a Colab notebook is better.
If you have the GPU W 8GB or better.. this must slow it down not speed it up, as it reduces use of VRAM. GPUs live to use their VRAM.
If you are getting poor performance but have a modern NVIDIA w 6GB or better VRAM, you probably need to ensure CUDA is working. There is a step in the AUTOMATIC1111 steps which validates that SD can see CUDA. If it can't see CIDA you will have slow performance. But often that just takes a nudge or two.
If you can't get CUDA to work, your performance will be dismal but these steps will help.
I will need to try this just to see if i can increase the size of images generated.
Hei mann i got 1660p gpu but idk it always run out of memory when i "interogate" is there anyway to fix this?
the only things I would suggest are (1) smaller images sizes and (2) close ALL other programs
@@lewingtonn mannnn, crazy!! Its workinggggg!!!
@@evilra6552 I know my stuff!!!
16:31 when I type “python - -version” it says Python 3.8.2
How do I change this?
you need to install python 3.10 as shown in the video, this should automatically give python 3.10 priority over your usual python
@@lewingtonn I installed python 10, it didn’t give priority
@@MeNoOther hmmmmm, ok then once it's installed you will need to give it priority. You can do this by modifying the PATH and making sure that python 3.10 is higher on the list than the other python
does this work with gtx 1060 3gb :D?
I read that performance was marginal with a 10 series card, (1080ti in my case) though on windows 7 I cannot use 3.10 or a modern version of Cuda
F
I still can't get pip to install cv2 whatever tf that is.
speed? gtx 1660 nividia?
I get this message Environment variable torch_cuda_arch_list-6.1 not defined 0.0
I GETH THE same error,,, its list=6.1 not list-6.1
i put 6.1 too , i have rtx 1060
nice video,
is anyone able to get xformers run on apple m1/m2?
Did git pull delete you checkpoint? 🙄
Also I would advocate strongly to use a venv or conda environment whenever working on projects like this, it will make your life a lot easier in the long run! 😊
Yeah so when doing ACTUAL coding I like venv a lot, but I found the install much easier just using the RAW python. The venv the repo provided kept falling over
Hi, thanks for the video. My question is if anyone is running this on a macbook pro. 🙏🏼
hi thanks for sharing the video can i know if it work with
NVIDIA GeForce GT 1030
Display Memory: 6035 MB
Dedicated Memory: 1982 MB
Shared Memory: 4052 MB
I'm like 99% sure that it will, assuming you can install CUDA 11.3, so try that first!
Lol, yeah, the boomers complained about their custom car parts not being delivered on time.
We complain about our cardboard box homes leaking, while we data mine text prompts hoping not to be Google banned from getting food tomorrow.
They still tell us how good we have it, and how hard life was when they had to walk through snow to get to the store.
That was before they got their dream job at 16.
The level of delusion in this comment is unmeasurable
@@andremonteiro1506 Why do you think that? You arent a boomer are you? Enjoy that social security buddy, because it will be going the same way as the international economy - to the dirt.
the cuda compatibility rating doesnt really matter as long your gpu is 3.7 or higher. if you know for sure you have a compatible series you can get away with lying to it and saying you have the lowest possible of 3.7, then instead of --xformers run your launcher with --force-enable-xformers and you'll get whatever you're actual performance is. i found this out the other day experimenting with sli'd dual gpu's but one of them fails with a score 3.5 didnt matter if i lied, wouldnt run , the 980 i didnt even bother to look it up, i just said it had 3.7 and it let me slide. ran fine till had a linux kernel incident (once again needed libssl1.1 - not more, not less especially not 1.1-1.1.01, forgot to disable the sketchy repo, and goobled up a god-awful hodgepodge of kernel mods/initramfs junk, and killed my sweet baby... now im reinstalling everything) xP
damn MOrdO, tech support levels are off the chain, the heck you even watching these videos for haha? Seems like you're way ahead of the game
Does it work on amd gpu ?
at this stage no 😢
The one shortcut you took made it impossible for me to figure out
:'( I'm sad to hear that, but within 30 mins of this comment was someone else telling me I need to make my videos shorter... sigh
It's not ancient it's GTX 1650 4gb 🥺
What I’m trying to install is Waifu Difussion, the creator made a guide but it’s really bad
attention is all you need
What if I don’t even have a gpu?
you can still install xformers on a remote GPU or on google colab... remote computers are just regular computers after all
CUDA toolkit???
I have a GTX 1050, are you even sure about this?!
The title of the video tricked me - I thought SD version 1.5 was available for local install, but it's "1.5x faster"
Haha sorry, not clickbait I swear
@@lewingtonn pls pin the comment about the adding xformers to bat file or better, make a video about it. i absolutely love how you explained the basics of xformers, i hope you sorta do the same for bat
@@afrosymphony8207 I don't know what's going on there since I haven't tried it myself, is there a guide or something online which says how to do the "bat" thing?
why is this outdated?
We have ALL this memory but we can't handle a long string of naming conventions in a path?
Who caused that design flaw?
The same guy who said 64kb is more than enough memory than the human race will ever need?
20 images / 79 seconds? Really dude?
is that slow or fast?
oooooh I inverted the math haha, yeah I got it right in the end and corrected the spreadsheet though!
use virutal environments you mad man
un modelo sd pesa 4 GB 😱
soooo I have 3.8 gb of vram
What the heck kind of weird GPU is that??
@@lewingtonn Must be the MSI GeForce GTX 1051.3 super (1660*(3.8/6GB)) :P
@@lewingtonn it's an integrated graphics card it's okay for photo editing but six for gaming in any circumstance.
@@JoeMama._. yeah, unlikely that that will be CUDA compatible, so you're probably out of luck
RIP 😢
I got this error and I dont know what to do
I tried to install with ven and wthout ven, i also installed latested Cuda 11 and even tried installing with cuda 10 but nothing helped.
HELP PLEASE
error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\bin\
vcc.exe' failed with exit code 4294967295
I got it used pip install --pre -U xformers and it worked
added to automatic1111 -- (self contained no messy windows leftovers basically)
fuck i hate conda
great tutorial, also for any one who interested there is git repo with docker full easy setup AbdBarho/stable-diffusion-webui-docker, i run stable diffusion auto on 750 ti 2gb vram with --lowvram set.
Hey there followed u step by step (though i didnt install on C: as its to ful)
i got this error code on the last step durring pip install:
Generating code
Finished generating code
attention.obj : error LNK2001: unresolved external symbol __imp___tls_offset_?init@?1??lazy_init_num_threads@internal@at@@YAXXZ@4_NA
attention.obj : error LNK2001: unresolved external symbol __imp___tls_index_?init@?1??lazy_init_num_threads@internal@at@@YAXXZ@4_NA
build\lib.win-amd64-cpython-310\xformers\_C.pyd : fatal error LNK1120: 2 unresolved externals
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120
I have a AMD GPU 🥲
I just found this config option that seems to fix the long paths issue (or at least it did for me) >>
git config --system core.longpaths true
HA, so I ran into that and I thought I was super clever but then ANOTHER WORSE long paths issue came up. I ended up just moving directly to C:\ and that solved it
@@lewingtonn gotta love code, there is always one more issue waiting lol 🙂
@@lewingtonn Oh my god, thanks for your comment, i didn't realise i ran into that other long path issue. THANK YOU
i was able to make it work, stable diffusion on an AMD card, with this command "set COMMANDLINE_ARGS = --lowvram --precision full --no-half --skip-torch-cuda-test" ..I have 16gb of ram and 4gb of graphics card but it's still sooo slow. 3-4 hours to create like 3 images.. does xformers work for AMD? Or is there something to make it faster when generating images?