huggingface / huggingface/diffusers

playground cuda error

Offen
#8,523 15 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
stale
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

https://github.com/huggingface/diffusers/blob/896fb6d8d7c10001eb2a92568be7b4bd3d5ddea3/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py#L728

When I initialize without using `to('cuda')`, the model exists in the cpu, so here self.device gets the handle on the cpu, refer to the code above, whether we change it to `device`

## error msg:
init_latents = (init_latents - latents_mean) * self.vae.config.scaling_factor / latents_std
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

## os:
diffusers==diffusers-0.28.2

## this is my code:

```
import torch
from PIL import Image
from diffusers import StableDiffusionXLImg2ImgPipeline, EDMDPMSolverMultistepScheduler

sd_xl_path = '../models/Stable-diffusion/playground-v2.5-xl-aesthetic'
img_path = './image_1.png'

pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(sd_xl_path,
torch_dtype=torch.float16,
add_watermarker=False,
)

pipe.enable_model_cpu_offload()
pipe.scheduler = EDMDPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)

image = Image.open(img_path)

images = pipe(prompt='a beautiful girl',
image=image,
guidance_scale=3.0,
num_inference_steps=30,
strength=0.5
).images
print(images)

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start at src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py around line 728 and reproduce the provided StableDiffusionXLImg2ImgPipeline example with enable_model_cpu_offload(). Inspect the tensors used in the failing init_latents expression. Done means the example completes without a CPU/CUDA device mismatch on diffusers 0.28.2.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python, pytorch
Bereich
machine-learning
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.