woctezuma / stable-diffusion-colab

Colab notebook for Stable Diffusion Hyper-SDXL.
https://github.com/Stability-AI/generative-models
MIT License
320 stars 82 forks source link

No module named 'triton'" / CUDA Error #5

Closed ataa closed 1 year ago

ataa commented 1 year ago

Thanks for making this.

I have two issue:

  1. I get this error:

    "WARNING:root:A matching Triton is not available, some optimizations will not be enabled.
    Error caught was: No module named 'triton'"

    But I was able to generate images without any issue.

  2. After generating the image, there's no way to free up GPU memory and getting cuda memory error when trying to generate more high resolution images. someone suggested this:

from numba import cuda
import torch 
device = cuda.get_current_device()
device.reset()

and it did empty the gpu memory but somehow detach the cuda device from the notebook!

CUDA error: invalid argument
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
woctezuma commented 1 year ago
  1. I get this error.

It is not an error, it is only a warning. I have not looked into it as I have not noticed any issue related to this warning so far.

  1. After generating the image, there's no way to free up GPU memory and getting cuda memory error.

I have not run out of memory when using xformers. However, if the installation of xformers was skipped or if it failed, then:

- model_id = "stabilityai/stable-diffusion-2"
+ model_id = "stabilityai/stable-diffusion-2-base"
- num_images = 4
+ num_images = 1

when trying to generate more high resolution images.

In any case, don't run the whole notebook repeatedly, only run the last cell if you want to generate more images:

prompt = "A pikachu fine dining with a view to the Eiffel Tower"

images = pipe(
    prompt,
    num_images_per_prompt=1,
    guidance_scale=9,
    num_inference_steps=25,
    height=image_length,
    width=image_length,
    ).images

media.show_images(images)
ataa commented 1 year ago

Thank you for your prompt reply,

parrot-20

woctezuma commented 1 year ago

Wow, this is a beautiful picture!

Sadly, I don't have an answer for your issue with clearing the GPU memory. All I can think of would be to "restart the runtime".

ataa commented 1 year ago

I managed to find a quick and dirty solution:

!ps -aux|grep 'python3 -m ipykernel_launcher' | awk '{print $2}' | xargs kill -9 then Ctrl-F9. So it does not re-download dependency packages again.

Also found the max resolution for my colab free plan,

num_images = 1
guidance_scale=20,
num_inference_steps=20,
image_length = 1400

index

woctezuma commented 1 year ago

Beautiful picture! And thanks for sharing your workaround! 🤗