{"id":26203,"date":"2025-01-04T11:00:48","date_gmt":"2025-01-04T03:00:48","guid":{"rendered":"https:\/\/www.1ai.net\/?p=26203"},"modified":"2025-01-04T11:03:27","modified_gmt":"2025-01-04T03:03:27","slug":"stable-diffusion-%e5%85%a5%e9%97%a8%e6%8c%87%e5%8d%97%ef%bc%8cstable-diffusion-webui%e6%9c%ac%e5%9c%b0%e9%83%a8%e7%bd%b2%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.1ai.net\/en\/26203.html","title":{"rendered":"Stable Diffusion Getting Started Guide, Stable Diffusion WebUI Local Deployment Tutorials"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26204\" title=\"ed77fc57j00spjmya000rd000u000csm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/ed77fc57j00spjmya000rd000u000csm.jpg\" alt=\"ed77fc57j00spjmya000rd000u000csm\" width=\"1080\" height=\"460\" \/><\/p>\n<p>Recently took over a project that required the use of <a href=\"https:\/\/www.1ai.net\/en\/tag\/stable-diffusion\" title=\"_Other Organiser\" target=\"_blank\" >Stable Diffusion<\/a> I've been working on a project that requires me to redeploy an SD environment. This is not quite the same as my previous SD deployment, and I encountered some problems during the deployment process, and summarized a more perfect installation plan, which I'd like to share with you here.<\/p>\n<p>Project address: https:\/\/github.com\/AUTOMATIC1111\/stable-diffusion-webui<\/p>\n<p>environmental preparation<\/p>\n<p>Before I start deploying, I use the following environment:<\/p>\n<ul>\n<li>Python 3.10.6 (this version is recommended to avoid some compatibility issues)<\/li>\n<li>NVIDIA RTX 4090 24GB<\/li>\n<li>Windows 11<\/li>\n<li>Native CUDA 12.4<\/li>\n<\/ul>\n<p>deployment process<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">At first I was installing the dependencies one by one in a step-by-step fashion, but found it tedious to switch directories too many times. Then I wrote a simple script to automate the process.<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">First, clone the main project:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code>git clone https:\/\/github.com\/AUTOMATIC1111\/stable-diffusion-webui.git\r\ncd stable-diffusion-webui\r\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\"><span class=\"\">conda<\/span>Environmental Creation<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code>conda create -p . \\Dlab python=3.10.6 -y\r\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">Then create a dependency library directory:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code>mkdir -p repositories &amp;&amp; cd repositories\r\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">Here's the auto-install script I wrote to get all the dependencies installed at once:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code>\r\nrepos=(\r\n    \"Stability-AI\/stablediffusion:stable-diffusion-stability-ai\"\r\n    \"CompVis\/taming-transformers:taming-transformers\"\r\n    \"sczhou\/CodeFormer:CodeFormer\"\r\n    \"salesforce\/BLIP:BLIP\"\r\n    \"Stability-AI\/generative-models:generative-models\"\r\n)\r\n\r\n\r\nfor repo in \"${repos[@]}\"; do\r\n    IFS=':' read -r github_path local_path &lt;&lt;&lt; &quot;$repo&quot;\r\n    echo &quot;Cloning and installing $github_path...&quot;\r\n    git clone &quot;https:\/\/github.com\/$github_path.git&quot; &quot;$local_path&quot;\r\n    cd &quot;$local_path&quot;\r\n    pip install -e .\r\n    cd ...\r\ncd ... done\r\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">The next step is to install the other necessary dependencies, these are the versions I've summarized after stepping through the pits and they work perfectly:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code># installs the base dependencies\r\npip install transformers==4.19.2 diffusers invisible-watermark --prefer-binary\r\n\r\n# k-diffusion must install the latest version from git\r\npip install git+https:\/\/github.com\/crowsonkb\/k-diffusion.git --prefer-binary\r\n\r\n# Go back to the home directory and install the project dependencies\r\ncd ...\r\npip install -r requirements.txt --prefer-binary\r\n\r\n# These are the versions I've tested over and over again, so I recommend installing them as follows\r\npip install pytorch_lightning==1.9\r\npip install -U xformers==0.0.28.post2 torchvision==0.20.0 torchaudio==2.5.0 --index-url https:\/\/download.pytorch.org\/whl\/cu124\r\npip install pydantic==1.10.11\r\npip install wandb==0.15.12\r\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\">Finally start the service:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\"><code>python launch.py --xformers --no-gradio-queue<\/code><\/pre>\n<p>Pothole Record<\/p>\n<ol>\n<li><strong>Dependency version conflict<\/strong><br \/>\nThe pitfall is the dependency versioning issue, in particular the versions of PyTorch and xformers have to match. The version combinations I listed above are tested over and over again and work perfectly.<\/li>\n<li><strong>network problem<\/strong><br \/>\nScientific Internet access. If you really can't download it, we recommend using a mirror source.<\/li>\n<\/ol>\n<p><strong>Chinese localization<\/strong><\/p>\n<p>After entering the interface select Extensions and click Load from to load<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26205\" title=\"725f5512j00spjmya001md000u000fym\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/725f5512j00spjmya001md000u000fym.jpg\" alt=\"725f5512j00spjmya001md000u000fym\" width=\"1080\" height=\"574\" \/><\/p>\n<p>Find zh_CN Localization and click Install.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26206\" title=\"89e5e24fj00spjmya001ud000u000g6m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/89e5e24fj00spjmya001ud000u000g6m.jpg\" alt=\"89e5e24fj00spjmya001ud000u000g6m\" width=\"1080\" height=\"582\" \/><\/p>\n<p>Once installed you can see in the installed plugins screen the<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26207\" title=\"8081348dj00spjmya001cd000u000fym\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/8081348dj00spjmya001cd000u000fym.jpg\" alt=\"8081348dj00spjmya001cd000u000fym\" width=\"1080\" height=\"574\" \/><\/p>\n<p>Then you come to the User interface screen<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26208\" title=\"c72c1edcj00spjmya0011d000u000f0m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/c72c1edcj00spjmya0011d000u000f0m.jpg\" alt=\"c72c1edcj00spjmya0011d000u000f0m\" width=\"1080\" height=\"540\" \/><\/p>\n<p>Select zh_CN<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26209\" title=\"6b3e4ed7j00spjmya001cd000u000g5m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/6b3e4ed7j00spjmya001cd000u000g5m.jpg\" alt=\"6b3e4ed7j00spjmya001cd000u000g5m\" width=\"1080\" height=\"581\" \/><\/p>\n<p>Apply settings and restart the UI<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26210\" title=\"c23fea7aj00spjmya001ed000u000g5m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/c23fea7aj00spjmya001ed000u000g5m.jpg\" alt=\"c23fea7aj00spjmya001ed000u000g5m\" width=\"1080\" height=\"581\" \/><\/p>\n<p>After restarting the webui, the interface is now in Chinese.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26211\" title=\"62377b7ej00spjmya0017d000u000fym\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/62377b7ej00spjmya0017d000u000fym.jpg\" alt=\"62377b7ej00spjmya0017d000u000fym\" width=\"1080\" height=\"574\" \/><\/p>\n<p>Generated images for testing and ran successfully!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26212\" title=\"4e8291acj00spjmya001md000u000g5m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/01\/4e8291acj00spjmya001md000u000g5m.jpg\" alt=\"4e8291acj00spjmya001md000u000g5m\" width=\"1080\" height=\"581\" \/><\/p>","protected":false},"excerpt":{"rendered":"<p>Recently, I took over a project that needs to use Stable Diffusion, and I need to redeploy a set of SD environment. This is not quite the same as my previous SD deployment, and I encountered some problems during the deployment process, and summarized a more perfect installation plan, which I'd like to share with you here. Project address: https:\/\/github.com\/AUTOMATIC1111\/stable-diffusion-webui Environment Preparation Before starting the deployment, I use the following environment: Python 3.10.6 (this version is recommended to avoid some compatibility issues) NVIDIA RTX 4090 24GB Windows 11 Native CUDA12<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[149,144],"tags":[197,3494,2852],"collection":[262],"class_list":["post-26203","post","type-post","status-publish","format-standard","hentry","category-jiaocheng","category-baike","tag-stable-diffusion","tag-webui","tag-2852","collection-stablediffusion"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts\/26203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/comments?post=26203"}],"version-history":[{"count":0,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts\/26203\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/media?parent=26203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/categories?post=26203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/tags?post=26203"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/collection?post=26203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}