Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running stable diffusion in colab. #9941

Open
Mikeskates opened this issue Nov 17, 2024 · 4 comments
Open

Error running stable diffusion in colab. #9941

Mikeskates opened this issue Nov 17, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Mikeskates
Copy link

Describe the bug

I have been using a notebook that I found on a youtube video, so that I could use Stable Diffusion to generate images in colab. and it was working for months. but 5 days ago the same code started generating errors and I can no longer use it. Can someone help me?

This is the error I get...

AttributeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
1777 try:
-> 1778 return importlib.import_module("." + module_name, self.name)
1779 except Exception as e:

32 frames
AttributeError: partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
RuntimeError: Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback):
partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/diffusers/utils/import_utils.py in _get_module(self, module_name)
853 return importlib.import_module("." + module_name, self.name)
854 except Exception as e:
--> 855 raise RuntimeError(
856 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its"
857 f" traceback):\n{e}"

RuntimeError: Failed to import diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion because of the following error (look up to see its traceback):
Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback):
partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)

Reproduction

#this is the code I used

!pip install diffusers["torch"] transformers
!pip install accelerate
!pip install git+https://github.com/huggingface/diffusers

import torch
from diffusers import StableDiffusionPipeline
from diffusers import DPMSolverMultistepScheduler

pipe = StableDiffusionPipeline.from_pretrained("IDK-ab0ut/Yiffymix_v43",torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.safety_checker = None
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

#it also doesn't work if I change the checkpoint to a different model. Please help! (I don't know anything about coding)

Logs

No response

System Info

I'm using colab so I don't know if you want their system info or the shitty laptop that I am on. on colab I am using a T4GPU. My laptop is garbage. don't really know it's stats, only that this worked for months and now doesn't.

Who can help?

No response

@Mikeskates Mikeskates added the bug Something isn't working label Nov 17, 2024
@a-r-r-o-w
Copy link
Member

Hi. As the error states, this does not seem related to Diffusers. Could you try and make sure that torchvision is correctly installed in Colab?

If you see that it is being installed/upgraded/downgraded when you do pip install diffusers in Colab, please make sure to restart the notebook.

If the torchvision version you are using does not match the one required by Diffusers, or is the latest release (which might be untested to work by us), you could be facing these errors.

@SahilCarterr
Copy link
Contributor

Hey @Mikeskates There is no a bug or a issue in StableDiffusionPipeline is working Fine and checkout Diffusers tutorial here to understand better about diffusers Library.
To solve your problem Start from a new runtime and use the code below.

!pip install diffusers accelerate transformers
import torch
from diffusers import StableDiffusionPipeline
from diffusers import DPMSolverMultistepScheduler

pipe = StableDiffusionPipeline.from_pretrained("IDK-ab0ut/Yiffymix_v43",torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.safety_checker = None
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

For further discussion feel free to ask in discussion tab here

@Mikeskates
Copy link
Author

Thank you SahilCarterr

@sayakpaul
Copy link
Member

Feel free to close the issue if you think it's resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants