Skip to content

Using lpw_stable_diffusion with sequential_cpu_offload gives 'NotImplementedError: Cannot copy out of meta tensor; no data!' #2531

Closed
@d1g1t

Description

@d1g1t

Describe the bug

Trying to use the example code from https://huggingface.co/docs/diffusers/using-diffusers/custom_pipeline_examples
with cpu offloading as suggested at https://huggingface.co/docs/diffusers/optimization/fp16#offloading-to-cpu-with-accelerate-for-memory-savings
I have removed the pipe.to("cuda") as suggested.

Reproduction

#!/usr/bin/python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", custom_pipeline="lpw_stable_diffusion", torch_dtype=torch.float16
)
#pipe = pipe.to("cuda")

prompt = "best_quality (1girl:1.3) bow bride brown_hair closed_mouth frilled_bow frilled_hair_tubes frills (full_body:1.3) fox_ear hair_bow hair_tubes happy hood japanese_clothes kimono long_sleeves red_bow smile solo tabi uchikake white_kimono wide_sleeves cherry_blossoms"
neg_prompt = "lowres, bad_anatomy, error_body, error_hair, error_arm, error_hands, bad_hands, error_fingers, bad_fingers, missing_fingers, error_legs, bad_legs, multiple_legs, missing_legs, error_lighting, error_shadow, error_reflection, text, error, extra_digit, fewer_digits, cropped, worst_quality, low_quality, normal_quality, jpeg_artifacts, signature, watermark, username, blurry"

pipe.enable_sequential_cpu_offload()

pipe.text2img(prompt, negative_prompt=neg_prompt, width=512, height=512, max_embeddings_multiples=3).images[0].save('mem_test.jpg')

Logs

No response

System Info

  • huggingface_hub version: 0.12.1
  • Platform: Linux-5.15.0-60-generic-x86_64-with-glibc2.35
  • Python version: 3.10.6
  • Running in iPython ?: No
  • Running in notebook ?: No
  • Running in Google Colab ?: No
  • Token path ?: /home/d1g1t/.cache/huggingface/token
  • Has saved token ?: True
  • Who am I ?: d1g1t
  • Configured git credential helpers:
  • FastAI: N/A
  • Tensorflow: N/A
  • Torch: 1.13.1
  • Jinja2: 3.0.3
  • Graphviz: N/A
  • Pydot: N/A
  • Pillow: 9.4.0
  • hf_transfer: N/A
  • ENDPOINT: https://huggingface.co
  • HUGGINGFACE_HUB_CACHE: /home/d1g1t/.cache/huggingface/hub
  • HUGGINGFACE_ASSETS_CACHE: /home/d1g1t/.cache/huggingface/assets
  • HF_HUB_OFFLINE: False
  • HF_TOKEN_PATH: /home/d1g1t/.cache/huggingface/token
  • HF_HUB_DISABLE_PROGRESS_BARS: None
  • HF_HUB_DISABLE_SYMLINKS_WARNING: False
  • HF_HUB_DISABLE_IMPLICIT_TOKEN: False
  • HF_HUB_ENABLE_HF_TRANSFER: False

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions