<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: gladevise</title>
    <description>The latest articles on Forem by gladevise (@gladevise).</description>
    <link>https://forem.com/gladevise</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F567550%2F04fdf53b-7525-4097-a6ea-d65dba4413d9.png</url>
      <title>Forem: gladevise</title>
      <link>https://forem.com/gladevise</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gladevise"/>
    <language>en</language>
    <item>
      <title>Building a Stable Diffusion WebUI local environment on Ubuntu 22.04</title>
      <dc:creator>gladevise</dc:creator>
      <pubDate>Mon, 29 May 2023 09:51:30 +0000</pubDate>
      <link>https://forem.com/gladevise/building-a-stable-diffusion-webui-local-environment-on-ubuntu-2204-5gd7</link>
      <guid>https://forem.com/gladevise/building-a-stable-diffusion-webui-local-environment-on-ubuntu-2204-5gd7</guid>
      <description>&lt;p&gt;This article guides you on how to set up a Stable Diffusion environment on Ubuntu 22.04.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation of Python, wget, git
&lt;/h2&gt;

&lt;p&gt;First, install the necessary applications such as python, wget, and git.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wget git python3 python3-venv


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After installation, check the Python version.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

python &lt;span class="nt"&gt;--version&lt;/span&gt;
Python 3.10.6


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  CUDA Installation
&lt;/h2&gt;

&lt;p&gt;Next, install CUDA.&lt;/p&gt;
&lt;h3&gt;
  
  
  Confirming the version of CUDA compatible with PyTorch
&lt;/h3&gt;

&lt;p&gt;Before installing CUDA, check the version of CUDA that is compatible with PyTorch. By accessing the &lt;a href="https://pytorch.org/" rel="noopener noreferrer"&gt;PyTorch official site&lt;/a&gt; and setting the PyTorch Build to Stable, the OS to Linux, the Package to Pip, and the Language to Python, you can find out which version of CUDA is available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmwjgd8of3a6nu6p1uy7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmwjgd8of3a6nu6p1uy7.png" alt="PyTorch_CUDA_Version"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, it was confirmed that CUDA 11.7 or 11.8 could be used. Since this article might be outdated, I recommend you to confirm the available CUDA versions using this method in advance.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing CUDA
&lt;/h3&gt;

&lt;p&gt;To download an older version of CUDA, first access the &lt;a href="https://developer.nvidia.com/cuda-toolkit-archive" rel="noopener noreferrer"&gt;cuda-toolkit-archive&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since we are downloading version 11.7 this time, choose either 11.7.0 or 11.7.1. As corrections at the patch level might be included, it is recommended to choose 11.7.1 unless you have a specific reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm1gcmygrjsa4630auxbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm1gcmygrjsa4630auxbg.png" alt="CUDA_Archive"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, by entering your environment on the &lt;a href="https://developer.nvidia.com/cuda-11-7-1-download-archive?target_os=Linux&amp;amp;target_arch=x86_64&amp;amp;Distribution=Ubuntu&amp;amp;target_version=22.04&amp;amp;target_type=deb_local" rel="noopener noreferrer"&gt;CUDA Toolkit 11.7 Update 1 Downloads&lt;/a&gt; site, the necessary installation commands will be generated. This time we are using an Ubuntu 22.04 environment with an Intel CPU, so make the selections as follows. Please choose according to your PC environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18wz1d0ftdhfr7enlgaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18wz1d0ftdhfr7enlgaf.png" alt="CUDA_Select_Target_Platform"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result of the selection, the following commands are displayed.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /var/cuda-repo-ubuntu2204-11-7-local/cuda-&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;-keyring&lt;/span&gt;.gpg /usr/share/keyrings/
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;cuda-11-7


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Before starting the installation process, there is one thing to note. The last &lt;code&gt;apt install cuda&lt;/code&gt; command needs to include a version, like &lt;code&gt;sudo apt install cuda-11-7&lt;/code&gt;. Otherwise, the latest version of CUDA will be installed. PyTorch may not be compatible with the latest version of CUDA. Therefore, always specify the version when installing.&lt;/p&gt;

&lt;p&gt;After installation is complete, you can check the version of CUDA by running the following command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

/usr/local/cuda-11.7/bin/nvcc &lt;span class="nt"&gt;--version&lt;/span&gt;
nvcc: NVIDIA &lt;span class="o"&gt;(&lt;/span&gt;R&lt;span class="o"&gt;)&lt;/span&gt; Cuda compiler driver
Copyright &lt;span class="o"&gt;(&lt;/span&gt;c&lt;span class="o"&gt;)&lt;/span&gt; 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If the path is not set correctly, you may run into issues later. Therefore, I recommend adding the following description to your &lt;code&gt;~/.bashrc&lt;/code&gt; file to set the path to CUDA.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="c"&gt;# Setting CUDA PATH&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/usr/local/cuda-11.7/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;LD_LIBRARY_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/usr/local/cuda-11.7/lib64:&lt;/span&gt;&lt;span class="nv"&gt;$LD_LIBRARY_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After saving, open a new terminal and execute &lt;code&gt;which nvcc&lt;/code&gt; to confirm that the path is set correctly.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

❯ which nvcc
/usr/local/cuda-11.7/bin/nvcc


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Checking the PyTorch Installation Command
&lt;/h2&gt;

&lt;p&gt;Visit the &lt;a href="https://pytorch.org/" rel="noopener noreferrer"&gt;PyTorch official page&lt;/a&gt; and select the command to install.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmwjgd8of3a6nu6p1uy7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmwjgd8of3a6nu6p1uy7.png" alt="PyTorch_CUDA_Version"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Currently, as the latest version of CUDA that PyTorch supports is 11.7, you should use &lt;code&gt;pip3 install torch torchvision torchaudio&lt;/code&gt;. However, it is recommended to note down the command specifying the version of CUDA for future reference when versions like 11.8 or 12.0 are added.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

pip &lt;span class="nb"&gt;install &lt;/span&gt;torch torchvision torchaudio &lt;span class="nt"&gt;--extra-index-url&lt;/span&gt; https://download.pytorch.org/whl/cu117


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This command is to be noted in the place where you set the command to install PyTorch in the Stable Diffusion WebUI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Stable Diffusion WebUI
&lt;/h2&gt;

&lt;p&gt;First, clone the repository.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

git clone &lt;span class="nt"&gt;--depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nt"&gt;--branch&lt;/span&gt; v1.2.1 https://github.com/AUTOMATIC1111/stable-diffusion-webui


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;webui-user.sh&lt;/code&gt; file is used for detailed configuration.&lt;/p&gt;

&lt;p&gt;For instance, the Stable Diffusion WebUI is designed to be cloned under &lt;code&gt;~/&lt;/code&gt; by default. But if you've cloned it somewhere else, you need to change &lt;code&gt;install_dir&lt;/code&gt; as follows.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;install_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/home/&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;whoami&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/Apps"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The PyTorch installation command is also set here.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;TORCH_COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;xformers, which slightly speeds up image generation, can also be enabled by adding &lt;code&gt;COMMANDLINE_ARGS&lt;/code&gt; as follows.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;COMMANDLINE_ARGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"--autolaunch --xformers"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The script is granted execution rights and run with the following command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;chmod &lt;/span&gt;755 webui-user.sh
bash ./webui-user.sh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then run &lt;code&gt;webui.sh&lt;/code&gt; in the same terminal.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bash ./webui.sh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On the first run, it may take 1-3 hours as it will need to download the model and dependencies.&lt;/p&gt;

&lt;p&gt;If the installation is successful, the WebUI will be displayed at &lt;a href="http://127.0.0.1:7860/" rel="noopener noreferrer"&gt;http://127.0.0.1:7860/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;Here is a list of common errors and their solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  The program 'nvcc' is currently not installed. You can install it by typing: sudo apt install nvidia-cuda-toolkit
&lt;/h3&gt;

&lt;p&gt;This error occurs when CUDA is not installed, or when the path is not set correctly. Please make sure that an executable file exists at &lt;code&gt;/usr/local/cuda-11.7/bin/nvcc&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  No module 'xformers'. Proceeding without it.
&lt;/h3&gt;

&lt;p&gt;This error occurs when xformers is not installed. Add &lt;code&gt;--xformers&lt;/code&gt; to &lt;code&gt;COMMANDLINE_ARGS&lt;/code&gt; in &lt;code&gt;webui-user.sh&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;COMMANDLINE_ARGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"--autolaunch --xformers"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  RuntimeError: Couldn't install torch.
&lt;/h3&gt;

&lt;p&gt;This error occurs when the installation of PyTorch fails for some reason.&lt;/p&gt;

&lt;p&gt;In my case, the cause of this error was that the version of CUDA supported by the PyTorch I was trying to install did not match the version of CUDA installed on my system.&lt;/p&gt;

&lt;p&gt;By default, the Stable Diffusion WebUI tries to install PyTorch with the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

pip &lt;span class="nb"&gt;install &lt;/span&gt;&lt;span class="nv"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;1.12.1+cu113 &lt;span class="nv"&gt;torchvision&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;0.13.1+cu113 &lt;span class="nt"&gt;--extra-index-url&lt;/span&gt; https://download.pytorch.org/whl/cu113


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, it is trying to install PyTorch that is compatible with CUDA 11.3. However, as a result of running &lt;code&gt;sudo apt install cuda&lt;/code&gt; when I was installing CUDA, CUDA 12.1 was installed instead.&lt;/p&gt;

&lt;p&gt;As explained at the beginning of the article, I was able to successfully install by matching the versions of PyTorch and CUDA.&lt;/p&gt;

&lt;p&gt;However, this solution may not work in all environments. I hope that those who encounter a similar error will find this information helpful in resolving the issue.&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>stablediffusion</category>
      <category>ai</category>
      <category>aiart</category>
    </item>
    <item>
      <title>Building a Stable Diffusion WebUI environment with RunPod</title>
      <dc:creator>gladevise</dc:creator>
      <pubDate>Sun, 07 May 2023 09:01:42 +0000</pubDate>
      <link>https://forem.com/gladevise/building-a-stable-diffusion-webui-environment-with-runpod-46al</link>
      <guid>https://forem.com/gladevise/building-a-stable-diffusion-webui-environment-with-runpod-46al</guid>
      <description>&lt;p&gt;As Google Colab has restricted the execution of Stable Diffusion in the free tier, we introduce &lt;a href="https://www.runpod.io/" rel="noopener noreferrer"&gt;RunPod&lt;/a&gt; as an alternative cloud resource.&lt;/p&gt;

&lt;p&gt;What you need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$10&lt;/li&gt;
&lt;li&gt;RunPod account&lt;/li&gt;
&lt;li&gt;Backblaze account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, visit &lt;a href="https://www.runpod.io/" rel="noopener noreferrer"&gt;RunPod&lt;/a&gt; and &lt;a href="https://www.backblaze.com/" rel="noopener noreferrer"&gt;Backblaze&lt;/a&gt; to create accounts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Paying the fee
&lt;/h2&gt;

&lt;p&gt;RunPod requires a prepayment, so you will need to pay a minimum of $10 upfront.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftppg7rcvb0xknjvetae0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftppg7rcvb0xknjvetae0.png" alt="SetCreditAmount"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will be redirected to the Stripe page, where you can enter your credit card information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez6iar8oz2ate7s4z3yq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez6iar8oz2ate7s4z3yq.png" alt="SetCreditCardInfo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your payment is successful, the following screen will be displayed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0kepgz39s6vifw2bxg4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0kepgz39s6vifw2bxg4.png" alt="SuccessPayment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a Stable Diffusion environment
&lt;/h2&gt;

&lt;p&gt;We will build a Stable Diffusion environment with RunPod.&lt;/p&gt;

&lt;p&gt;Go to the Secure Cloud and select the resources you want to use. In this case, we will choose the cheapest option, the &lt;strong&gt;RTX A4000&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fncn4oq212hr81se1q14m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fncn4oq212hr81se1q14m.png" alt="SelectResource"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the existing templates, select &lt;strong&gt;RunPod Fast Stable Diffusion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1n103yio177p2ind5w2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1n103yio177p2ind5w2.png" alt="SelectFastStableDiffusion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the confirmation screen is displayed, click &lt;strong&gt;Deploy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3dml94t6kixm5depol9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3dml94t6kixm5depol9.png" alt="ConfirmDeploy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;My Pods&lt;/strong&gt; and check the deployed Pod.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1fd6ihpxug8r4huajvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1fd6ihpxug8r4huajvi.png" alt="GoToMyPods"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After confirming that the CPU usage has decreased, click &lt;strong&gt;Connect&lt;/strong&gt; and then &lt;strong&gt;Connect to Jupyter Lab&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhslxj7g4ap970qnexvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhslxj7g4ap970qnexvz.png" alt="ConnectToJupyterLab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the &lt;strong&gt;RNPD-A1111.ipynb&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvu34wyainecypw8k6bgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvu34wyainecypw8k6bgz.png" alt="OpenRNPD-A1111.ipynb"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the notebook is open, execute the cells in order from &lt;strong&gt;Dependencies&lt;/strong&gt;, &lt;strong&gt;Install/Update AUTOMATIC1111 repo&lt;/strong&gt;, &lt;strong&gt;Model Download/Load&lt;/strong&gt;, &lt;strong&gt;ControlNet&lt;/strong&gt;, to &lt;strong&gt;Start Stable-Diffusion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When you run Start Stable-Diffusion, a URL like &lt;code&gt;Running on local URL: https://foobar-3000.proxy.runpod.net&lt;/code&gt; will be displayed, so access it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fray47q2cjrpoi91tdy09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fray47q2cjrpoi91tdy09.png" alt="StableDiffusionOnRunPod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy generating images within the limits of your credit with the familiar interface.&lt;/p&gt;

&lt;p&gt;To stop, click &lt;strong&gt;Stop&lt;/strong&gt; in My Pods.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnd2sci1zqsd2m9cohnti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnd2sci1zqsd2m9cohnti.png" alt="StopPod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A confirmation screen will appear, so click &lt;strong&gt;Stop Pod&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7b0xccvwdkamtdyg1t5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7b0xccvwdkamtdyg1t5.png" alt="ConfirmStopPod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned on the confirmation screen, RunPod will continue to charge you until the storage you are using is released, even after stopping the Pod. In the example above, $0.014 will be deducted per hour.&lt;/p&gt;

&lt;p&gt;The only way to stop this is to click &lt;strong&gt;Terminate&lt;/strong&gt; to completely delete the Pod.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj8p3a5kx3r2smwrd8ew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj8p3a5kx3r2smwrd8ew.png" alt="TerminatePod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Saving RunPod data with Backblaze
&lt;/h2&gt;

&lt;p&gt;As it stands, the generated images will be lost, so we will save them to Backblaze.&lt;/p&gt;

&lt;p&gt;Go to Backblaze and click &lt;strong&gt;Create a Bucket&lt;/strong&gt; from Buckets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhmap6xvw5oboik8zys9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhmap6xvw5oboik8zys9.png" alt="CreateBucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the Bucket Unique Name and click &lt;strong&gt;Create a Bucket&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmvyj38lp5rhrbgvbgltz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmvyj38lp5rhrbgvbgltz.png" alt="SetBucketProperties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, go to Application Keys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flv0jxqq5ltlsbjpm82dj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flv0jxqq5ltlsbjpm82dj.png" alt="GoToApplicationKeys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Add a New Application Key&lt;/strong&gt; to issue a new key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71w3oyfqz37w6dkfm9ke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71w3oyfqz37w6dkfm9ke.png" alt="AddNewApplicationKey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the key name and specify the bucket you set earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7gvm7irj5r1h2oba76j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7gvm7irj5r1h2oba76j.png" alt="SetApplicationKeyProperties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take note of the &lt;strong&gt;keyID&lt;/strong&gt; and &lt;strong&gt;keyName&lt;/strong&gt; displayed here.&lt;/p&gt;

&lt;p&gt;Return to RunPod and click &lt;strong&gt;CloudSync&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91dotm0atylwj0d2vd0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91dotm0atylwj0d2vd0u.png" alt="ClickCloudSync"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the cloud storage selection screen appears, click &lt;strong&gt;Backblaze B2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi41zn4znacw7xnfkng0y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi41zn4znacw7xnfkng0y.png" alt="SelectBackblazeB2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Copy to Backblaze B2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yo9674wnujqdksx606m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yo9674wnujqdksx606m.png" alt="CopyToBackblazeB2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the &lt;strong&gt;keyID&lt;/strong&gt; and &lt;strong&gt;keyName&lt;/strong&gt; you noted earlier as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Account ID: keyID displayed when generating the key in Backblaze
Application Key: keyName displayed when generating the key in Backblaze
Bucket Path: {bucket} is the bucketName, {folder} is an appropriate name. ex: RunPodCloudSyncSDWebUI/fast-stable-diffusion
Pod Path: /workspace


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frp5b0qr97p8jo85q8l5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frp5b0qr97p8jo85q8l5d.png" alt="SetCloudSyncPropertiesTo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will save the output results and properties of Stable Diffusion to Backblaze B2.&lt;/p&gt;

&lt;p&gt;Once the upload is complete, you can check the specified folder in Backblaze's Browse Files to see that the files have been saved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8vzr4t2gyqsvv6h0vf4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8vzr4t2gyqsvv6h0vf4.png" alt="BrowseFiles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, even if you terminate the Pod, the generated images will not be lost. When launching the next Pod, click &lt;strong&gt;Copy from Backblaze B2&lt;/strong&gt; to copy files from Backblaze B2, allowing you to continue generating images from where you left off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you frequently generate images with Stable Diffusion, Google Colab Pro is more cost-effective.&lt;/li&gt;
&lt;li&gt;If you only generate images occasionally with Stable Diffusion, RunPod's pay-as-you-go flexibility may be better.&lt;/li&gt;
&lt;li&gt;If you temporarily need more specs than those provided by Google Colab, such as for model training, RunPod is more suitable.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>stablediffusion</category>
      <category>googlecolab</category>
      <category>runpod</category>
    </item>
  </channel>
</rss>
