DEV Community

Axlfc
Axlfc

Posted on • Edited on

How to install Stable Diffusion in an Ubuntu 22.04 GNU/Linux Oracle VirtualBox VM

Here's how I managed to install Stable Diffusion AI image generator with Linux-Auto-Customizer to be able to run it within an Ubuntu 22.04 GNU/Linux VirtualBox VM. Minimum 16GB of memory recommended.

  • Install Python3, cmake and Linux-Auto-Customizer:
    sudo apt install -y python3 cmake git
    git clone https://github.com/AleixMT/Linux-Auto-Customizer
    cd Linux-Auto-Customizer
    git checkout stablediffusion_feature
    sudo bash src/core/install.sh -v -o customizer

  • Download .cpkt model weights manually (huggingface account will be needed):
    The model file needed by Stable Diffusion is hosted on Hugging Face.
    You will need to register with any email address.
    Once registered, head to the latest model repository, which at the time of writing is stable-diffusion-v-1-4-original.
    Under the ‘files and versions’ tab, download the checkpoint file, sd-v1-4.ckpt.
    Link to download weights

  • Load the weights of the Stable Diffusion model in ~/.customizer/cache directory named as stableDiffusion_bundle_file:
    mv ~/Downloads/sd-v1-4.ckpt ~/.customizer/cache/model.ckpt

  • Reload bash environment:
    bash

  • Set up Stable Diffusion:
    customizer-install -v -o stableDiffusion

  • Reload bash environment:
    bash

  • Run function stablediffusion:
    stablediffusion "A cat riding a rocket from outer earth"

Now we have Stable Diffusion installed running on our CPU in the Ubuntu 22.04 GNU/Linux Oracle VirtualBox VM, it is considerably running slower than running it in the GPU in bare metal.

Happy VM AI art generating!

A cat riding a rocket from outer earth
A cat riding a rocket from outer earth!!
FUN!

Did this article helped you? Share it, comment or give a like if it did! 😄

Top comments (0)