running out of memory on introduction_to_stablediffusion.ipynb
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- jupyter-notebook, python, pytorch
- Domain
- ai, data-visualization, machine-learning
Research direction
The issue is in introduction_to_stablediffusion.ipynb, specifically the cell running base and refiner models. Start by checking GPU memory usage in Colab with a T4. Look at the model loading and inference steps; consider reducing batch size, image resolution, or using memory optimization techniques like gradient checkpointing. The error trace points to a conv2d operation in PyTorch. Verify the environment variables like PYTORCH_CUDA_ALLOC_CONF. Running the notebook step-by-step and monitoring memory with torch.cuda.memory_summary will help identify the peak usage.
Written by the indexing model from the issue text.
Description
Thanks for this notebook @rkdan ! This is great!
In introduction_to_stablediffusion.ipynb running on Google Colab with an instance of a T4 GPU, I am running out of memory.
My code is here:
I can run until here (where I get an error):
# run both experts
image_base = base(
prompt=prompt,
num_inference_steps=n_steps,
denoising_end=high_noise_frac,
output_type="latent",
).images
image_final = refiner(
prompt=prompt,
num_inference_steps=n_steps,
denoising_start=high_noise_frac,
image=image_base,
).images[0]
Error message is
---------------------------------------------------------------------------
OutOfMemoryError Traceback (most recent call last)
<ipython-input-8-410c6a79b4f8> in <cell line: 0>()
7 ).images
8
----> 9 image_final = refiner(
10 prompt=prompt,
11 num_inference_steps=n_steps,
17 frames
/usr/local/lib/python3.11/dist-packages/torch/nn/modules/conv.py in _conv_forward(self, input, weight, bias)
547 self.groups,
548 )
--> 549 return F.conv2d(
550 input, weight, bias, self.stride, self.padding, self.dilation, self.groups
551 )
OutOfMemoryError: CUDA out of memory. Tried to allocate 512.00 MiB. GPU 0 has a total capacity of 14.74 GiB of which 306.12 MiB is free. Process 6006 has 14.44 GiB memory in use. Of the allocated memory 14.17 GiB is allocated by PyTorch, and 145.94 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
My code is here:
- Dominant language
- Jupyter Notebook
- Stars
- 21
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from acceleratescience/diffusion-models
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Add devcontainer Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
acceleratescience/diffusion-models#10 · 1 assignee ·
All issues in acceleratescience/diffusion-models
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
p:2-high pydanty:bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
pydantic/pydantic-ai#8642 · 2 comments ·
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug external groq
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langchain-ai/langchain#40771 · 1 comment ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100