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

dream.py issue on M1 Mac: torch._C' has no attribute '_cuda_resetPeakMemoryStats' #234

Closed
yudhanjaya opened this issue Aug 31, 2022 · 7 comments

Comments

@yudhanjaya
Copy link

yudhanjaya commented Aug 31, 2022

M1 Mac. After model load,


Loading model from models/ldm/stable-diffusion-v1/model.ckpt
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Using half precision math. Call with --full_precision to use more accurate but VRAM-intensive full precision.
>> Setting Sampler to k_lms
model loaded in 7.59s
* Initialization done! Awaiting your command (-h for help, 'q' to quit)
dream> "a tower of books"

this error happens:

Traceback (most recent call last):
  File "/Users/yudhanjaya/stable-diffusion/scripts/dream.py", line 518, in <module>
    main()
  File "/Users/yudhanjaya/stable-diffusion/scripts/dream.py", line 99, in main
    main_loop(t2i, opt.outdir, opt.prompt_as_dir, cmd_parser, infile)
  File "/Users/yudhanjaya/stable-diffusion/scripts/dream.py", line 208, in main_loop
    image_list  = t2i.prompt2image(image_callback=callback, **vars(opt))
  File "/Users/yudhanjaya/stable-diffusion/ldm/simplet2i.py", line 283, in prompt2image
    torch.cuda.torch.cuda.reset_peak_memory_stats()
  File "/Users/yudhanjaya/miniconda3/envs/ldm/lib/python3.10/site-packages/torch/cuda/memory.py", line 260, in reset_peak_memory_stats
    return torch._C._cuda_resetPeakMemoryStats(device)
AttributeError: module 'torch._C' has no attribute '_cuda_resetPeakMemoryStats'

I've done all the steps in trouble-shooting: as far as I can tell, loading is not an issue. What am I doing wrong?

@sergiocasero
Copy link

I can reproduce it on MAC M1 pro, if I just run img2text directly works as expected

@rcknight
Copy link

Same issue here - txt2img script works fine but dream fails with this error

@junukwon7
Copy link

Seems like this is a kind of a patch, however returning black squares.

@personjerry
Copy link

Just comment out torch.cuda.torch.cuda.reset_peak_memory_stats() on line 283 of simplet2i.py

# torch.cuda.torch.cuda.reset_peak_memory_stats()

@yudhanjaya
Copy link
Author

yudhanjaya commented Aug 31, 2022

Can confirm that the original scripts work: I just generated Sheldon Cooper as a GTA character, no issues with txt2img.py.

Just comment out torch.cuda.torch.cuda.reset_peak_memory_stats() on line 283 of simplet2i.py

# torch.cuda.torch.cuda.reset_peak_memory_stats()

Thanks! Just tried this, but I don't seem to be getting output. It still seems to be trying to use cuda - but the 'it' here appears to be dream.py (as best as I can make out) and not the sd scripts themselves.


dream> "Cat Pharaoh dreaming of pyramids"
Generating:   0%|                                                                   | 0/1 [00:00<?, ?it/s]
"LayerNormKernelImpl" not implemented for 'Half'
Are you sure your system has an adequate NVIDIA GPU?
Usage stats:
   0 image(s) generated in 0.01s
   Max VRAM used for this generation: 0.00G
   Max VRAM used since script start:  0.00G

@yudhanjaya yudhanjaya changed the title MAC: torch._C' has no attribute '_cuda_resetPeakMemoryStats' dream.py issue on M1 Mac: torch._C' has no attribute '_cuda_resetPeakMemoryStats' Aug 31, 2022
@lstein
Copy link
Collaborator

lstein commented Aug 31, 2022

This is fixed in pull request #256. Just waiting for a code review to merge.

@lstein lstein closed this as completed Aug 31, 2022
@yudhanjaya
Copy link
Author

This is fixed in pull request #256. Just waiting for a code review to merge.

Thanks, much appreciated!

lstein added a commit that referenced this issue Aug 31, 2022
* fix AttributeError crash when running on non-CUDA systems; closes issue #234 and issue #250
* although this prevents dream.py script from crashing immediately on MPS systems, MPS support still very much a work in progress.
austinbrown34 pushed a commit to cognidesign/InvokeAI that referenced this issue Dec 30, 2022
)

* fix AttributeError crash when running on non-CUDA systems; closes issue invoke-ai#234 and issue invoke-ai#250
* although this prevents dream.py script from crashing immediately on MPS systems, MPS support still very much a work in progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants