{"id":521,"date":"2023-05-23T12:01:43","date_gmt":"2023-05-23T19:01:43","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/windowsai\/?p=521"},"modified":"2023-06-08T10:32:06","modified_gmt":"2023-06-08T17:32:06","slug":"dml-stable-diffusion","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/windowsai\/dml-stable-diffusion\/","title":{"rendered":"DirectML \u2764 Stable Diffusion"},"content":{"rendered":"<p>Text-to-image models are amazing tools that can transform natural language into stunning images. Stable Diffusion is particularly interesting. The base model can create images from text and since it\u2019s open-source developers can customize it for their own needs and preferences. With some extra training, developers can fine-tune their model to generate images of any domain, subject, or style they want.<\/p>\n<p>We are demonstrating what can be done with Stable Diffusion models in two of our Build sessions: <a href=\"https:\/\/build.microsoft.com\/en-US\/sessions\/8aab36d1-d27d-46dd-81ec-eb3f49cfee6a?source=sessions\">Shaping the future of work with AI<\/a> and <a href=\"https:\/\/build.microsoft.com\/en-US\/sessions\/0ea15726-1273-4a7c-a71a-efc635172a3b?source=sessions\">Deliver AI-powered experiences across cloud and edge, with Windows<\/a>.<\/p>\n<p>We&#8217;ve optimized DirectML to accelerate transformer and diffusion models, like Stable Diffusion, so that they run even better across the Windows hardware ecosystem. Our goal is to enable developers to infuse apps with AI hardware acceleration at scale. For more on how Stable Diffusion lights up on our partners\u2019 hardware with DML, check out:<\/p>\n<ul>\n<li>AMD: <a href=\"https:\/\/gpuopen.com\/amd-microsoft-directml-stable-diffusion\/\">https:\/\/gpuopen.com\/amd-microsoft-directml-stable-diffusion\/<\/a><\/li>\n<li>NVIDIA: <a href=\"https:\/\/nam06.safelinks.protection.outlook.com\/?url=https%3A%2F%2Fblogs.nvidia.com%2Fblog%2F2023%2F05%2F23%2Fmicrosoft-build-nvidia-ai-windows-rtx&amp;data=05%7C01%7CJacques.Van%40microsoft.com%7C7532ff8ce4654656ee3608db58dbcdae%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638201473770813536%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=rAA4hAOfMVs8cTh8ZFvGMU55sAuojGVrjjd75nl2T98%3D&amp;reserved=0\">https:\/\/blogs.nvidia.com\/blog\/2023\/05\/23\/microsoft-build-nvidia-ai-windows-rtx<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Getting the best performance with DirectML<\/h3>\n<p>We worked closely with the <a href=\"https:\/\/github.com\/microsoft\/Olive\/tree\/main\/examples\/directml\/stable_diffusion\">Olive<\/a> team to build a powerful optimization tool that leverages DirectML to produce models that are optimized to run across the Windows ecosystem. For more on Olive with DirectML, check out our post, <a href=\"https:\/\/devblogs.microsoft.com\/windowsai\/optimize-directml-performance-with-olive\">Optimize DirectML performance with Olive<\/a><\/p>\n<p>You can use Olive to ensure your Stable Diffusion model works as well as possible with DirectML. Make sure your model is in the ONNX format; you can use <a href=\"https:\/\/microsoft.github.io\/Olive\/api\/passes.html#onnxconversion\">Olive<\/a> to do this conversion. Once you\u2019ve done this, follow the steps in our <a href=\"https:\/\/devblogs.microsoft.com\/windowsai\/optimize-directml-performance-with-olive\">DML and Olive blog post<\/a><\/p>\n<p>See <a href=\"https:\/\/github.com\/microsoft\/Olive\/tree\/main\/examples\/directml\/stable_diffusion\">here<\/a> for a sample that shows how to optimize a Stable Diffusion model<em>. <\/em>We\u2019ve tested this with <a href=\"https:\/\/github.com\/CompVis\/stable-diffusion\">CompVis\/stable-diffusion-v1-4<\/a> and <a href=\"https:\/\/huggingface.co\/runwayml\/stable-diffusion-v1-5\">runwayml\/stable-diffusion-v1-5<\/a>. Stable Diffusion models with different checkpoints and\/or weights but the same architecture and layers as these models will work well with Olive.<\/p>\n<p>&nbsp;<\/p>\n<h3>DirectML in action<\/h3>\n<p>Check out tomorrow\u2019s Build Breakout Session to see Stable Diffusion in action: <a href=\"https:\/\/build.microsoft.com\/en-US\/sessions\/0ea15726-1273-4a7c-a71a-efc635172a3b?source=sessions\">Deliver AI-powered experiences across cloud and edge, with Windows<\/a><\/p>\n<p>See <a href=\"https:\/\/github.com\/microsoft\/Olive\/tree\/main\/examples\/directml\/stable_diffusion\">here<\/a> for a Python sample showing how to use Stable Diffusion with Olive.<\/p>\n<p>We also built some samples to show how you can use DirectML in general in <a href=\"https:\/\/github.com\/microsoft\/DirectML\/tree\/master\/Samples\">C++<\/a>. For more links to help you get started, check out our <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/ai\/directml\/dml\">documentation<\/a> and <a href=\"https:\/\/microsoft.github.io\/DirectML\/links.html\">helpful links page<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h3>Driver Support<\/h3>\n<p>We recommend upgrading to the latest drivers for the best performance.<\/p>\n<p><strong>AMD: <\/strong>AMD has released optimized graphics drivers supporting AMD RDNA\u2122 3 devices including AMD Radeon\u2122 RX 7900 Series graphics cards. <a href=\"https:\/\/www.amd.com\/en\/support\/kb\/release-notes\/rn-rad-win-23-5-2\" target=\"loopstyle_link\" rel=\"noopener\" data-loopstyle=\"link\" data-auth=\"NotApplicable\">Download AMD Software: Adrenalin Edition 23.5.2<\/a><\/p>\n<p><strong>Intel: <\/strong>Developers interested in Intel drivers supporting Stable Diffusion on DirectML should contact Intel Developer Relations for additional details<\/p>\n<p><strong>NVIDIA: <\/strong>Users of NVIDIA GeForce RTX 20, 30 and 40 Series GPUs, can see these improvements first hand, in <a href=\"https:\/\/nam06.safelinks.protection.outlook.com\/?url=https%3A%2F%2Fwww.nvidia.com%2FDownload%2FdriverResults.aspx%2F204969%2Fen-us%2F&amp;data=05%7C01%7CJacques.Van%40microsoft.com%7C37f2bb2da3414bfe6d9008db5c60f982%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638205343830418780%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=zdknBhYOa%2Bn337dXv8isLCqTbhaG8tezw%2BNOfYnPgCk%3D&amp;reserved=0\">GeForce Game Ready Driver 532.03<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Get hold of us<\/h3>\n<p>The AI space is changing fast! In case you run into any problems feel free to open an issue on our <a href=\"https:\/\/github.com\/microsoft\/DirectML\/issues\">Github repo<\/a> or email us at <a href=\"mailto:askdirectml@microsoft.com\">askdirectml@microsoft.com<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Text-to-image models are amazing tools that can transform natural language into stunning images. Stable Diffusion is particularly interesting. The base model can create images from text and since it\u2019s open-source developers can customize it for their own needs and preferences. With some extra training, developers can fine-tune their model to generate images of any domain, [&hellip;]<\/p>\n","protected":false},"author":2237,"featured_media":74,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-ai"],"acf":[],"blog_post_summary":"<p>Text-to-image models are amazing tools that can transform natural language into stunning images. Stable Diffusion is particularly interesting. The base model can create images from text and since it\u2019s open-source developers can customize it for their own needs and preferences. With some extra training, developers can fine-tune their model to generate images of any domain, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts\/521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/users\/2237"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/comments?post=521"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts\/521\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/media\/74"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/media?parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/categories?post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/tags?post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}