Go back

How to get Techlatest Stable Diffusion with InvokeAI Web Interface on GCP (Google Cloud Platform)

This section describes how to launch and connect to Techlatest Stable Diffusion with InvokeAI Web Interface in a Google Compute environment using the available Cloud Launcher offering.

Note: Stable diffusion requires a lot of processing, so a GPU instance is recommended. If you want to use a CPU instance due to the high price of GPU instances, you should use instances with a higher CPU.

GPU’s are not available in some zones and for some instance types.

Below are recommended VM configuration requirements:

  • GPU VM : NVIDIA T4 with 1 GPU with n1-standard-4 (4 vcpu 15GB memory) configuration
  • CPU VM : e2-standard-4 (4vcpu, 16gb ram)

For CPU, its the minimum spec but more cpu is preferred. Instances with AMD GPU are not recommended.

/img/gcp/stable-diffusion/gpu-instance.png

/img/gcp/stable-diffusion/cpu-instance.png

Note: GPU instance will perform 10 times or more faster when processing request compared to CPU instance . Typical GPU instance will take few seconds to render images compared to 7-10 minutes by CPU instance, hence GPU instances are preferred.

  1. Open Techlatest Stable Diffusion with InvokeAI Web Interface listing on GCP Marketplace
  2. Click Launch.

/img/gcp/invoke-ai/marketplace.png

  • It will take you to the agreement page. On this page, you can change the project from the project selector on top navigator bar as shown in the below screenshot.
  • Accept the Terms and agreements by ticking the checkbox and clicking on the AGREE button. /img/common/gcp_agreement_page.png
  • It will show you the successfully agreed popup page. Click on Deploy. /img/common/gcp_agreement_accept_page.png

Select a zone where you want to launch the VM(such as us-east1-)

Optionally change the number of cores and amount of memory. ( This defaults to 4 vCPUs and 15 GB ram. For better performance please add GPU from the GPU section as shown in the below screenshot.)

Optionally change the boot disk type and size. (This defaults to ‘Standard Persistent Disk’ and 70 GB respectively)

Optionally change the network name and subnetwork names. Be sure that whichever network you specify has ports 22 (for ssh), 3389 (for RDP) and 80 (for HTTP) exposed.

Click Deploy when you are done.

Techlatest Stable Diffusion with InvokeAI Web Interface will begin deploying.

/img/gcp/invoke-ai/deployed.png

  1. A summary page displays when the compute engine is successfully deployed. Click on the Instance link to go to the instance page .

  2. On the instance page, click on the “SSH” button, select “Open in browser window”.

/img/gcp/puppet-support/ssh-option.png

  1. This will open SSH window in a browser.
  2. Run below command to set the password for “ubuntu” user
sudo passwd ubuntu

/img/gcp/jupyter-python-notebook/ssh-passwd.png

  1. Now the password for ubuntu user is set, you can connect to the VM’s desktop environment from any local windows machine using RDP or linux machine using Remmina.

  2. To connect using RDP via Windows machine, first note the external IP of the VM from VM details page as highlighted below

/img/gcp/jupyter-python-notebook/external-ip.png

  1. Then From your local windows machine, goto “start” menu, in the search box type and select “Remote desktop connection”

  2. In the “Remote Desktop connection” wizard, paste the external ip and click connect

/img/gcp/jupyter-python-notebook/rdp.png

  1. This will connect you to the VM’s desktop environment. Provide “ubuntu” as the userid and the password set in step 6 to authenticate. Click OK

/img/gcp/puppet-support/rdp-login.png

  1. Now you are connected to out of box Techlatest Stable Diffusion with InvokeAI Web Interface environment via Windows machines.

/img/gcp/invoke-ai/rdp-desktop.png

  1. To connect using RDP via Linux machine, first note the external IP of the VM from VM details page,then from your local Linux machine, goto menu, in the search box type and select “Remmina”.

    Note: If you don’t have Remmina installed on your Linux machine, first Install Remmina as per your linux distribution.

/img/gcp/common/remmina-search.png

  1. In the “Remmina Remote Desktop Client” wizard, select the RDP option from dropdown and paste the external ip and click enter.

/img/gcp/common/remmina-external-ip.png

  1. This will connect you to the VM’s desktop environment. Provide “ubuntu” as the userid and the password set in step 6 to authenticate. Click OK

/img/gcp/common/remmina-rdp-login.png

  1. Now you are connected to out of box Techlatest Stable Diffusion with InvokeAI Web Interface environment via Linux machine.

/img/gcp/invoke-ai/rdp-desktop.png

Once you are connected to GUI environment, follow below steps to launch InvokeAI Web Interface.

  1. Setting up a huggingface account.

/img/gcp/invoke-ai/huggingface-token.png
/img/gcp/invoke-ai/read-role.png

  1. Now open the terminal inside GUI and run below commands-
cd /home/ubuntu/invokeai
./invoke.sh

/img/gcp/invoke-ai/execute-invokeai.png

  1. It will prompt you some questions. For the first prompt, select the option 2 as generate images using browser based UI.

/img/gcp/invoke-ai/select-browser-based-ui.png

  1. Next it will ask you to download models, select “r” to download recommended model. You can choose any option other than skip, it is recommended to select “r”. If you select all, make sure you have enough disk space to download all models.

/img/gcp/invoke-ai/download-model.png

  1. After providing all the above option, it will ask for inputting the token at the command prompt, paste the token created in hugging face in step 17 above and click enter.
    Wait till the setup finishes. Once setup is complete, restart the VM.

/img/gcp/invoke-ai/press-enter.png

/img/gcp/invoke-ai/enter-token.png

  1. After VM launch for the first time, GPU instances will take 2-5 minutes and CPU instances will take 5-10 minutes  to launch the app in the browser.

    Wait for 2-5 or 5-10 minutes depending on if your VM is GPU or CPU based and then access the InvokeAI GUI via browser by copying the public IP of the VM from the VM’s overview page and paste it in the browser and then hit enter.

    Note: Please use http and not https in the URL when accessing InvokeAI interface in GUI, for eg. http://vm_public_ip.

  2. The Stable Diffusion InvokeAI GUI comes with lots of options and settings. The first window shows text to image page.There are three main sections.
    1. A control panel on the left, which contains various settings for text to image generation.
    2. The current image section in the middle, which shows a large format version of the image you are currently working on.
    3. A gallery section on the right that contains a history of the images you have generated.

/img/gcp/invoke-ai/invokeai-web-ui.png

  1. Provide the Prompt and click on Invoke button and wait till it finishes.

/img/gcp/invoke-ai/text-to-image.png

  1. You can see and edit all the images in viewer window. Click on viewer icon as shown below to load the images.

/img/gcp/invoke-ai/viewer.png

/img/gcp/invoke-ai/viewer-window.png

  1. You can also access the web console by clicking web console arrow in the left-bottom

/img/gcp/invoke-ai/open-console.png

/img/gcp/invoke-ai/console.png

  1. For more information on how to use the GUI, Go to InvokeAI Web UI
  2. You can access InvokeAI directory at /home/ubuntu/invokeai.
    The images created from GUI are stored under /home/ubuntu/invokeai/output directory.
    To access this directory, connect to VM’s Desktop environment as explained above, and navigate to home - > ubuntu -> invokeai-> output directory.

/img/gcp/invoke-ai/invokeai-directory.png

/img/gcp/invoke-ai/output-directory.png

  1. You can also access the sourcecode of the InvokeAI. It is available under sourcecode folder on Desktop.

/img/gcp/stable-diffusion/source-code-folder-on-desktop.png

/img/gcp/stable-diffusion/source-code.png

Credits:

https://github.com/CompVis/stable-diffusion.git
https://github.com/AbdBarho/stable-diffusion-webui-docker
https://github.com/AUTOMATIC1111/stable-diffusion-webui
https://github.com/Sygil-Dev/sygil-webui
https://github.com/invoke-ai/InvokeAI
https://invoke-ai.github.io/InvokeAI/other/CONTRIBUTORS/

Go back