Taking Stable Diffusion for a spin on a basic laptop

I’ve been quite intrigued by the recent public releases of Dall-E followed by Stable Diffusion which allow you to generate images from simple text prompts, & had been trying them out on the free online platforms. The main limitation of these is that you are limited to a certain quota for free, and to really try an opensource tool like Stable Diffusion locally, you need to pretty beefy system with a high end GPU.

All that changed when I came across a project on GitHub that lets you run Stable Diffusion on the CPU thanks to Intel’s OpenVINO framework. I promptly took it for a spin on my 4 year old laptop with an Intel quad core 8th gen CPU. The instructions are provided on the GitHub project itself as expected. If you are using Windows like me, you can do the following:

  • Install Anaconda which simplifies the Python setup.
  • Create a new environment in Anaconda for the project.
  • Open the terminal, create a directory for the project & clone the GitHub repository for the project using the git clone https://github.com/bes-dev/stable_diffusion.openvino.git command with the project web URL.
  • Follow the installation instructions on the project page:
    • Install the project dependencies using pip install -r requirements.txt
    • Enable Developer Mode in Windows settings which allows the model to be downloaded on first run.
    • If you plan to use the web interface also install streamlit drawable canvas using pip install streamlit-drawable-canvas, as this module dependency seemed to be missing in the documentation & gave me errors on trying to run the web demo.
  • Run the script as per instructions replacing the prompt if you want (the developer seems to be a GoT/Emilia Clarke fan) – python demo.py --prompt "Street-art painting of Emilia Clarke in style of Banksy, photorealism"

On my laptop it takes about 8-10 min to generate an image, though a more powerful CPU with more RAM should be able to cut it down to 3-4 min as mentioned in the project page benchmarks. Either way, it is a worthwhile tradeoff to be able to run it locally.

Here are a couple of results from the prompts I ran on my laptop (I chose a couple of the timeless beauties to see what Stable Diffusion has to offer):

Power efficiency of AlphaGo’s victory

So another decade maybe before it achieves power parity?

Lee Sedol used about 20 Watts of power to operate. By contrast, AlphaGo runs on a whopping 1920 CPUs and another 280 GPUs for an estimated power consumption of approximately 1 MW (200 W per CPU and 200 W per GPU). That’s 50,000 times as much power as the amount of power that Lee Sedol’s brain uses and the two are not quite evenly matched but it is close enough to use for comparison.

Source: Another Way Of Looking At Lee Sedol vs AlphaGo · Jacques Mattheij

The Road to Artifical Intelligence

Siri and Google Now are but a tiny drop in the ocean that is going to be AI. We’re quite a few years away, but we’ll get there eventually as hardware develops further and our understanding of the brain continues to grow:

But scientists aren’t just aiming for smaller. They’re trying to build machines that do things computer have never done before. No matter how sophisticated algorithms are, today’s machines can’t fetch your groceries or pick out a purse or a dress you might like. That requires a more advanced breed of image intelligence and an ability to store and recall pertinent information in a way that’s reminiscent of human attention and memory. If you can do that, the possibilities are almost endless.

via The Man Behind the Google Brain: Andrew Ng and the Quest for the New AI | Wired Enterprise | Wired.com.