(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
  • НаукаНаука

Комментарии • 124

  • @lewingtonn
    @lewingtonn  Год назад +11

    🚫🚫🚫🚫🚫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!

    • @Efotix
      @Efotix Год назад +2

      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.

    • @ceaselessvibing5997
      @ceaselessvibing5997 Год назад +1

      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.

    • @Wen_079
      @Wen_079 Год назад

      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?

  • @kylbau
    @kylbau Год назад +4

    Dude full hand holding guides - big thanks n’ would appreciate more like it (Stable diffusion related or others). Ty beast.

    • @lewingtonn
      @lewingtonn  Год назад

      no worries dude, I'm also doing it to learn myself. Any specific topics?

  • @ZeroIQ2
    @ZeroIQ2 Год назад +1

    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.

  • @swannschilling474
    @swannschilling474 Год назад +1

    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!! 😱😱😱

  • @krozareq
    @krozareq Год назад

    I know it's outdated. But the quality of the vid and information is amazing. Also digging the chill music.

  • @Nutronic
    @Nutronic Год назад +1

    Matt has some great stuff in the work for Photoroom and the free stable diffusion their site is using.

  • @Semi-Cyclops
    @Semi-Cyclops Год назад

    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

  • @swannschilling474
    @swannschilling474 Год назад +1

    This is great, thanks a lot 😊

  • @everydreamai
    @everydreamai Год назад

    Worked fine for me with Cuda 11.7 and VS 2022, no build errors.

    • @lewingtonn
      @lewingtonn  Год назад

      Niiiiiiice, this is VERY good to know

  • @FilmFactry
    @FilmFactry Год назад +1

    Very Good info!

  • @p_p
    @p_p Год назад +11

    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.

    • @lewingtonn
      @lewingtonn  Год назад +2

      wait... really? ok I'll look into this!

    • @p_p
      @p_p Год назад +1

      @@lewingtonn i'll send you the exact line were to add this code, once i'll back at home

    • @woobeforethesun
      @woobeforethesun Год назад +4

      @@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

    • @lytanshade
      @lytanshade Год назад

      @@lewingtonn yip works on my 3060ti. had tried earlier with failures until i realized my automatic1111 webui was a week behind with its updates...

    • @jwvanmiddelkoop8501
      @jwvanmiddelkoop8501 Год назад +1

      Thanks. Seemd to work with my gtx1050ti as well. Cuts 9s of generation time on a 512x512 20 step generation.

  • @andremonteiro1506
    @andremonteiro1506 Год назад

    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

  • @wboumans
    @wboumans Год назад

    I couldn't be bothered, but will check it out now.

  • @Jinofcoolnes
    @Jinofcoolnes Год назад

    Thanks for this!

  • @sharkeys
    @sharkeys Год назад +1

    Desperatly want to try this on my Steamdeck, runs sooooooo much better with XFormers on my 3080ti around 17it/s now.

  • @hidinginplainsight1787
    @hidinginplainsight1787 Год назад +6

    You only need to edit the webui-user.bat (and run that bat afterwards) with the following addition. set COMMANDLINE_ARGS= --xformers

    • @junpengqiu4054
      @junpengqiu4054 Год назад

      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.

  • @AndyHTu
    @AndyHTu Год назад

    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

  • @vanitygamer7817
    @vanitygamer7817 Год назад

    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.

  • @user-li1cm3ek7q
    @user-li1cm3ek7q 8 месяцев назад

    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?

  • @diegosanabria860
    @diegosanabria860 Год назад

    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?

  • @denisplay8258
    @denisplay8258 Год назад

    So if my PC can do 768x768 at it limits, then with XFormers i can raise limits?

  • @watchingthestuff
    @watchingthestuff Год назад

    Thank you for the great guide.
    Does anyone happen to know if this also speeds up textual inversion and/or hypernetwork?

  • @iREM0015
    @iREM0015 Год назад

    What makes image generation faster, is it the graphics card or what? Is NVIDIA 4 and 6GB good or not?

  • @ZeroCool22
    @ZeroCool22 Год назад +5

    ⚠ 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.

  • @Kentoloupe
    @Kentoloupe 11 месяцев назад

    I'm stuck on the pip install -r requirements.txt
    It keeps saying access denied. What can I do? 😭😭

  • @farawaybrawlhacks2341
    @farawaybrawlhacks2341 Год назад

    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?

    • @lewingtonn
      @lewingtonn  Год назад

      yes, for sure, Xformers makes the memory requirements lower at all resolutions (though my other video on Xformers is probably easier to follow)

  • @ZeroCool22
    @ZeroCool22 Год назад +1

    CUDA 11.8 here and xformers working fine.

  • @jambrud123
    @jambrud123 11 месяцев назад

    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!

  • @MrCGangsta
    @MrCGangsta Год назад +1

    thx for this bofore this I could only render 500x500 now I can go to 1000+

  • @iREM0015
    @iREM0015 Год назад

    dear is nividia 4-6 gb is good or not for stable diffi

  • @zonegaming3498
    @zonegaming3498 Год назад +4

    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.

    • @lewingtonn
      @lewingtonn  Год назад

      yeah, my apologies, there's lots of things to keep in mind

  • @Modozenmusic
    @Modozenmusic Год назад

    HOW LONG DOES SETUP PY DEVELOP FOR XFORMERS take? It's been 30 minutes and nothing is over

  • @daetoyinzen5983
    @daetoyinzen5983 Год назад

    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

    • @time019
      @time019 Год назад

      I got the Same error

  • @sifu2u_now
    @sifu2u_now Год назад +1

    This Boomer here can't thank you enough for this. Thank you!

  • @mtit6253
    @mtit6253 Год назад

    tks u so much 😍

  • @Daiyamaruu
    @Daiyamaruu Год назад

    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

  • @PJAOK
    @PJAOK Год назад +1

    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.

  • @KennethLoebenberg
    @KennethLoebenberg Год назад

    I will need to try this just to see if i can increase the size of images generated.

  • @evilra6552
    @evilra6552 Год назад

    Hei mann i got 1660p gpu but idk it always run out of memory when i "interogate" is there anyway to fix this?

    • @lewingtonn
      @lewingtonn  Год назад

      the only things I would suggest are (1) smaller images sizes and (2) close ALL other programs

    • @evilra6552
      @evilra6552 Год назад +2

      @@lewingtonn mannnn, crazy!! Its workinggggg!!!

    • @lewingtonn
      @lewingtonn  Год назад +1

      @@evilra6552 I know my stuff!!!

  • @MeNoOther
    @MeNoOther Год назад

    16:31 when I type “python - -version” it says Python 3.8.2
    How do I change this?

    • @lewingtonn
      @lewingtonn  Год назад

      you need to install python 3.10 as shown in the video, this should automatically give python 3.10 priority over your usual python

    • @MeNoOther
      @MeNoOther Год назад

      @@lewingtonn I installed python 10, it didn’t give priority

    • @lewingtonn
      @lewingtonn  Год назад

      @@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

  • @shikimori85
    @shikimori85 Год назад

    does this work with gtx 1060 3gb :D?

  • @praxis22
    @praxis22 Год назад

    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

  • @HalkerVeil
    @HalkerVeil Год назад

    I still can't get pip to install cv2 whatever tf that is.

  • @MrLaura34
    @MrLaura34 Год назад

    speed? gtx 1660 nividia?

  • @NoiseOfNetrino
    @NoiseOfNetrino Год назад

    I get this message Environment variable torch_cuda_arch_list-6.1 not defined 0.0

    • @Modozenmusic
      @Modozenmusic Год назад +1

      I GETH THE same error,,, its list=6.1 not list-6.1
      i put 6.1 too , i have rtx 1060

  • @gankam
    @gankam Год назад +1

    nice video,
    is anyone able to get xformers run on apple m1/m2?

  • @swannschilling474
    @swannschilling474 Год назад

    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! 😊

    • @lewingtonn
      @lewingtonn  Год назад

      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

  • @suzanazzz
    @suzanazzz Год назад

    Hi, thanks for the video. My question is if anyone is running this on a macbook pro. 🙏🏼

  • @Quizolo
    @Quizolo Год назад +1

    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

    • @lewingtonn
      @lewingtonn  Год назад +1

      I'm like 99% sure that it will, assuming you can install CUDA 11.3, so try that first!

  • @greenflamingoentertainment8613
    @greenflamingoentertainment8613 Год назад +1

    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.

    • @andremonteiro1506
      @andremonteiro1506 Год назад

      The level of delusion in this comment is unmeasurable

    • @greenflamingoentertainment8613
      @greenflamingoentertainment8613 Год назад

      @@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.

  • @mordokai597
    @mordokai597 Год назад +1

    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

    • @lewingtonn
      @lewingtonn  Год назад

      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

  • @andreialcaza
    @andreialcaza Год назад +1

    Does it work on amd gpu ?

  • @artisinalbread4378
    @artisinalbread4378 Год назад

    The one shortcut you took made it impossible for me to figure out

    • @lewingtonn
      @lewingtonn  Год назад

      :'( 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

  • @anwesharajisharma
    @anwesharajisharma Год назад +1

    It's not ancient it's GTX 1650 4gb 🥺

  • @ultralaggerREV1
    @ultralaggerREV1 Год назад

    What I’m trying to install is Waifu Difussion, the creator made a guide but it’s really bad

  • @chyldstudios
    @chyldstudios Год назад

    attention is all you need

  • @tjgonline1304
    @tjgonline1304 Год назад +1

    What if I don’t even have a gpu?

    • @lewingtonn
      @lewingtonn  Год назад

      you can still install xformers on a remote GPU or on google colab... remote computers are just regular computers after all

  • @ultralaggerREV1
    @ultralaggerREV1 Год назад

    CUDA toolkit???
    I have a GTX 1050, are you even sure about this?!

  • @uncannyvalleyproductions
    @uncannyvalleyproductions Год назад

    The title of the video tricked me - I thought SD version 1.5 was available for local install, but it's "1.5x faster"

    • @lewingtonn
      @lewingtonn  Год назад

      Haha sorry, not clickbait I swear

    • @afrosymphony8207
      @afrosymphony8207 Год назад +2

      @@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

    • @lewingtonn
      @lewingtonn  Год назад

      @@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?

  • @vanitygamer7817
    @vanitygamer7817 Год назад

    why is this outdated?

  • @HalkerVeil
    @HalkerVeil Год назад

    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?

  • @mctennys
    @mctennys Год назад +1

    20 images / 79 seconds? Really dude?

    • @lewingtonn
      @lewingtonn  Год назад

      is that slow or fast?

    • @lewingtonn
      @lewingtonn  Год назад

      oooooh I inverted the math haha, yeah I got it right in the end and corrected the spreadsheet though!

  • @the_spektor
    @the_spektor Год назад

    use virutal environments you mad man

  • @cristhianpatino4766
    @cristhianpatino4766 Год назад

    un modelo sd pesa 4 GB 😱

  • @JoeMama._.
    @JoeMama._. Год назад

    soooo I have 3.8 gb of vram

    • @lewingtonn
      @lewingtonn  Год назад

      What the heck kind of weird GPU is that??

    • @cl1mbat1ze
      @cl1mbat1ze Год назад

      @@lewingtonn Must be the MSI GeForce GTX 1051.3 super (1660*(3.8/6GB)) :P

    • @JoeMama._.
      @JoeMama._. Год назад

      @@lewingtonn it's an integrated graphics card it's okay for photo editing but six for gaming in any circumstance.

    • @lewingtonn
      @lewingtonn  Год назад

      @@JoeMama._. yeah, unlikely that that will be CUDA compatible, so you're probably out of luck

    • @lewingtonn
      @lewingtonn  Год назад

      RIP 😢

  • @oli5389
    @oli5389 Год назад

    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

    • @oli5389
      @oli5389 Год назад

      I got it used pip install --pre -U xformers and it worked

  • @ac3d657
    @ac3d657 Год назад

    added to automatic1111 -- (self contained no messy windows leftovers basically)
    fuck i hate conda

  • @jokernev1
    @jokernev1 Год назад

    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.

  • @aDAMoscar
    @aDAMoscar Год назад

    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

  • @Skulll9000
    @Skulll9000 Год назад

    I have a AMD GPU 🥲

  • @ZeroIQ2
    @ZeroIQ2 Год назад +1

    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

    • @lewingtonn
      @lewingtonn  Год назад +1

      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

    • @ZeroIQ2
      @ZeroIQ2 Год назад

      @@lewingtonn gotta love code, there is always one more issue waiting lol 🙂

    • @loucascubeddu
      @loucascubeddu Год назад

      @@lewingtonn Oh my god, thanks for your comment, i didn't realise i ran into that other long path issue. THANK YOU

  • @diegosanabria860
    @diegosanabria860 Год назад

    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?