{"id":576,"date":"2023-02-05T23:48:00","date_gmt":"2023-02-05T12:48:00","guid":{"rendered":"https:\/\/www.samontab.com\/web\/?p=576"},"modified":"2023-02-07T16:10:38","modified_gmt":"2023-02-07T05:10:38","slug":"simplest-and-cheapest-way-to-run-stable-diffusion-with-your-own-hardware","status":"publish","type":"post","link":"https:\/\/www.samontab.com\/web\/2023\/02\/simplest-and-cheapest-way-to-run-stable-diffusion-with-your-own-hardware\/","title":{"rendered":"Simplest and cheapest way to run Stable Diffusion with your own hardware"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>TL;DR<\/strong>: Grab a <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/Apple-Desktop-Computer-10%E2%80%91core-Ethernet\/dp\/B0BSHGHGXR?crid=A62LF7U4ZGMO&amp;keywords=mac+mini&amp;qid=1675599652&amp;sprefix=mac+min%2Caps%2C426&amp;sr=8-1&amp;linkCode=ll1&amp;tag=sebmonmypasan-20&amp;linkId=12995ad80e89c982633b4c83eef6c5a4&amp;language=en_US&amp;ref_=as_li_ss_tl\" target=\"_blank\">Mac Mini M2<\/a> or a <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/Apple-Desktop-Computer-10%E2%80%91core-Ethernet\/dp\/B0BSHFS6XX?crid=A62LF7U4ZGMO&amp;keywords=mac%2Bmini&amp;qid=1675599652&amp;sprefix=mac%2Bmin%2Caps%2C426&amp;sr=8-1&amp;th=1&amp;linkCode=ll1&amp;tag=sebmonmypasan-20&amp;linkId=cd1af03c9b8e0d9a5840d50c66d1a633&amp;language=en_US&amp;ref_=as_li_ss_tl\" target=\"_blank\">Mac Mini M2 Pro<\/a> if you want to generate images faster, then download <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/godly-devotion\/MochiDiffusion\" target=\"_blank\">MochiDiffusion<\/a> and start generating your images at home. Note: I&#8217;m using referral links in this post, so if you buy something I might receive a commission.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Stable_Diffusion\" target=\"_blank\">Stable Diffusion<\/a> is a deep learning model that allows you to generate images by simply writing a text prompt, like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"512\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/photo.png\" alt=\"\" class=\"wp-image-577\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/photo.png 512w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/photo-300x300.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/photo-150x150.png 150w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><figcaption class=\"wp-element-caption\">&#8220;A photograph of an astronaut riding a horse&#8221;<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Before the release of Stable Diffusion, you would have needed to access cloud services to generate images like this. Some of the most popular ones are <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/DALL-E\" data-type=\"URL\" data-id=\"https:\/\/en.wikipedia.org\/wiki\/DALL-E\" target=\"_blank\">DALL-E<\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Midjourney\" target=\"_blank\">Midjourney<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, you&#8217;re able to do this with your own hardware. Usually, this would require you to setup a rather expensive PC with a powerful GPU, but with the <a rel=\"noreferrer noopener\" href=\"https:\/\/machinelearning.apple.com\/research\/stable-diffusion-coreml-apple-silicon\" target=\"_blank\">latest research from Apple<\/a>, you&#8217;re now able to run Stable Diffusion with Core ML on their new ARM devices(M1, M2, etc).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The base configuration of the newly released <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/Apple-Desktop-Computer-10%E2%80%91core-Ethernet\/dp\/B0BSHGHGXR?crid=A62LF7U4ZGMO&amp;keywords=mac+mini&amp;qid=1675599652&amp;sprefix=mac+min%2Caps%2C426&amp;sr=8-1&amp;linkCode=ll1&amp;tag=sebmonmypasan-20&amp;linkId=12995ad80e89c982633b4c83eef6c5a4&amp;language=en_US&amp;ref_=as_li_ss_tl\" target=\"_blank\">Mac Mini M2<\/a> is the best deal you can get in terms of the cheapest device that can be used with Stable Diffusion. But if you want to have faster generation of images, then the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/Apple-Desktop-Computer-10%E2%80%91core-Ethernet\/dp\/B0BSHFS6XX?crid=A62LF7U4ZGMO&amp;keywords=mac%2Bmini&amp;qid=1675599652&amp;sprefix=mac%2Bmin%2Caps%2C426&amp;sr=8-1&amp;th=1&amp;linkCode=ll1&amp;tag=sebmonmypasan-20&amp;linkId=cd1af03c9b8e0d9a5840d50c66d1a633&amp;language=en_US&amp;ref_=as_li_ss_tl\" target=\"_blank\">Mac Mini M2 Pro<\/a> is an incredible device that runs faster and comes with more RAM and more disk space, which is handy since each of these models is quite large. Also, keep in mind that you might be able to find the older <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/Apple-Mini-Chip-256GB-Storage\/dp\/B08TDNXTVK\/ref=sr_1_3?crid=3PM7FA1S7QWWM&amp;keywords=mac+mini+m1&amp;qid=1675600098&amp;sprefix=mac+min%2Caps%2C388&amp;sr=8-3\" target=\"_blank\">Mac Mini M1<\/a> at good prices. Any of these devices are able to run Stable Diffusion, the main difference would be the speed in which they do it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, to be able to run Stable Diffusion on the Mac Mini natively, you&#8217;ll need to download an application called <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/godly-devotion\/MochiDiffusion\" target=\"_blank\">MochiDiffusion<\/a>. After you install it, you&#8217;ll also need to download a Stable Diffusion model, prepared specially for Core ML. You can find some <a rel=\"noreferrer noopener\" href=\"https:\/\/huggingface.co\/coreml\" target=\"_blank\">ready to use models here<\/a>. In particular, you want to get the <strong>split_einsum<\/strong> version of the model, which is the one compatible with the Neural Engine of the Mac Mini. For example, if you want the latest Stable Diffusion model, which is 2.1, you can find it <a rel=\"noreferrer noopener\" href=\"https:\/\/huggingface.co\/coreml\/coreml-stable-diffusion-2-1-base\/tree\/main\/split_einsum\" target=\"_blank\">here<\/a>. Simply unzip the file and place it under <strong>\/Users\/YOUR_USERNAME\/Documents\/MochiDiffusion\/models<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"653\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-1024x653.png\" alt=\"\" class=\"wp-image-578\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-1024x653.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-300x191.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-768x490.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-1536x980.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/gui-2048x1307.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Mochi Diffusion v2.2 with Stable Diffusion v2.1 model<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You can now simply write your prompt where it says &#8220;<strong>Include in Image:<\/strong>&#8220;, and also you can write stuff you don&#8217;t want to see in the &#8220;<strong>Exclude from image:<\/strong>&#8221; box. When you&#8217;re asked about the Compute Unit option, make sure to select &#8220;<strong>Use Neural Engine<\/strong>&#8221; as we&#8217;re using the <strong>split_einsum<\/strong> models.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"254\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/neural.png\" alt=\"\" class=\"wp-image-579\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/neural.png 737w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/02\/neural-300x103.png 300w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><figcaption class=\"wp-element-caption\">Select <strong>Use Neural Engine<\/strong> whenever you see this as we&#8217;re using <strong>split_einsum<\/strong> models<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now you&#8217;re ready to generate your first image, simply click <strong>Generate<\/strong> and wait. When you click Generate for the first time after you load a model, it will take some extra time to compile it and optimise it for your device. After this is done, it will generate the next images much faster. Once the image appears on the screen, you can simply select it and click on the icon with the arrow pointing down at the top to save it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The generated images are 512&#215;512, but you have the option to check the HD box to enlarge your images in generation time to 2024&#215;2024 using <a rel=\"noreferrer noopener\" href=\"https:\/\/arxiv.org\/abs\/2107.10833\" target=\"_blank\">Real-ESRGAN<\/a>. You can also enlarge the images later if you select them and click on the magic wand icon on top. And that&#8217;s really all you need to start generating images with your Mac Mini. Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR: Grab a Mac Mini M2 or a Mac Mini M2 Pro if you want to generate images faster, then download MochiDiffusion and start generating your images at home. Note: I&#8217;m using referral links in this post, so if you buy something I might receive a commission. Stable Diffusion is a deep learning model that [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,21,6],"tags":[68,67],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-computer-vision","category-open-source","category-photography","tag-open-source","tag-stable-difussion"],"_links":{"self":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/comments?post=576"}],"version-history":[{"count":0,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/media?parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}