Generating an image is really slow

Some context

I’m trying to generate an image from a textual prompt, and compare the various options available for this task, because I am very new to this, so I don’t know which one is most fit to my use case. I’d like to avoid having to train anything myself, and rather resort to a off-the-shelf solution. If I understood correctly, this is roughly what pretrained models available on the hugging face hub are for. I tried downloading one (chosen more or less at random, I picked alvdansen/phantasma-anime · Hugging Face), but I didn’t manage to actually load it and run it with a prompt to get an image out of it (all the from_pretrained class methods I’ve tried want a JSON config file, not a safetensors file). So, I started with a simpler task, to simply run on my computer the example given in the documentation of text-to-image diffusers:

import torch
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
image = pipe("an image of an astronaut riding a horse on Mars").images[0]

The problem

I’m doing this on a laptop that doesn’t have a (dedicated) GPU, so I knew that I wouldn’t have the results right away, but I expected a single iteration to be performed at most in a couple of minutes. Yet, after ten minutes, a single iterations hasn’t finished.

I was wondering if it was normal that this task is that long, considering that it defaults to 50 iterations, so that generating a single image at this rate would take at least 9 hours.

Specs

For information, my CPU’s model is i7-1260P. The environment, as spit out by transformers-cli env, is

  • transformers version: 4.43.3
  • Platform: Linux-6.6.43-x86_64-with-glibc2.39
  • Python version: 3.11.9
  • Huggingface_hub version: 0.24.2
  • Safetensors version: 0.4.3
  • Accelerate version: 0.32.0
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.3.1 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed

Also, during the generation of the image, I noted that it mostly uses only two cores, although it occasionally uses all the 16 cores. I was wondering whether there was a way to make it use more aggressively the resources of my machine.