Generating an image is really slow
Some contextI’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 pickedalvdansen/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 thefrom_pretrainedclass 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 givenin 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 problemI’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 performedat mostin a couple of minutes. Yet, after ten minutes, a single iterations hasn’t finished.I was wondering if it was normal that this task isthatlong, considering that it defaults to 50 iterations, so that generating a single image at this rate would takeat least9 hours.SpecsFor information, my CPU’s model is i7-1260P. The environment, as spit out bytransformers-cli env, istransformersversion: 4.43.3Platform: Linux-6.6.43-x86_64-with-glibc2.39Python version: 3.11.9Huggingface_hub version: 0.24.2Safetensors version: 0.4.3Accelerate version: 0.32.0Accelerate config: 	not foundPyTorch version (GPU?): 2.3.1 (False)Tensorflow version (GPU?): not installed (NA)Flax version (CPU?/GPU?/TPU?): not installed (NA)Jax version: not installedJaxLib version: not installedAlso, 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.