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

A few small quality of life changes #44

Merged
merged 2 commits into from
Aug 24, 2022

Conversation

warner-benjamin
Copy link
Contributor

@warner-benjamin warner-benjamin commented Aug 23, 2022

A few small quality of life changes:

  • added a python .gitignore preset to ignore the default image save location and model symbolic link
  • allow users to set the device to run stable diffusion with, defaults to 'cuda'
  • autocast will use the user set device so should run on CPU with bfloat16 accelerated ops if device='cpu'
  • cleaned up the stacked context manager lines

Changes tested and working with text2img.

@warner-benjamin warner-benjamin changed the title Small QoL Changes A few small quality of life changes Aug 23, 2022
@warner-benjamin
Copy link
Contributor Author

I see #43 also adds a gitignore with a few differences. Can harmonize this PR with 43, or you can choose 43's gitignore.

@artmen1516
Copy link
Contributor

I tested this PR since I cannot run original code from my Macbook pro because of cuda device, i tested with the option you added -d cpu and it successfully launched the dream.py script, but when I write something to generate an image I get the same error I was getting with original code AssertionError: Torch not compiled with CUDA enabled .
Here's the error I'm getting:

image

note: I have configured a virtual environment with pipenv, not using conda.

@warner-benjamin
Copy link
Contributor Author

warner-benjamin commented Aug 24, 2022

I missed some hardcoded cuda sections. Fixed those, but the k_diffusion package still appears to have them. This should allow users with multiple GPUs to pick which GPU to use by setting device if they are not using k_lms.

This doesn't appear to allow CPU generation, though, I get a "LayerNormKernelImpl" not implemented for 'Half' error for half precision, and in full precision a expected scalar type BFloat16 but found Float error. It's possible upgrading to PyTorch 1.12 would resolve either of these issues, but I'm not going to spend more time trying to get CPU generation to run.

@lstein lstein merged commit c24a16c into invoke-ai:main Aug 24, 2022
@lstein
Copy link
Collaborator

lstein commented Aug 24, 2022

Thanks for the PR!

IMO there's more community need for folding in the basunjindal VRAM optimizations than getting the thing to run on CPU (tho' that would be nice). If someone out there wants to work on an optimization port in a way that lets the user select whether or not to use them, I'd be totally grateful.

Also, as a heads up, I'm about to do two things:

  1. Refactor simplet2i.py to move all the PNG filenaming and manipulation into a separate module. This will change the API so that instead of returning an image name, txt2img() and img2img() return Image objects. I hope this doesn't break anyone's scripts.
  2. I'm going to attempt to merge shared code among txt2img() and img2img() and remove a few levels of indentation. Please hold off on additional PRs until tomorrow (Thursday) to avoid massive merge conflicts.

Lastly, I was playing around with the hugging face Diffusion modules last night and they're really elegant! I am strongly tempted to base a new version of dream.py on the HF libraries. Do they have (or plan to have) the features that the community has been pasting into the various CompViz derivatives (including this one) such as textual inversion and support for all the k_* samplers?

@warner-benjamin
Copy link
Contributor Author

IMO there's more community need for folding in the basunjindal VRAM optimizations than getting the thing to run on CPU (tho' that would be nice).

I agree. Setting the device was more about allowing users to pick which GPU to run it on if they have two, and I was hoping it would also just work on CPU since PyTorch-CPU is more mature than ROCm or MIPs.

@warner-benjamin warner-benjamin deleted the small-improvements branch August 24, 2022 16:27
@lstein
Copy link
Collaborator

lstein commented Aug 24, 2022

Issue #69 reports img2img reporting dying with an error message about not knowing which GPU device to use. When I check img2img myself, I'm getting "sqrt" "_vml_cpu" not implemented for 'Half' . I suspect these problems are related to your PR? I appreciate your looking into it.

lstein added a commit that referenced this pull request Aug 24, 2022
…ith the message 'sqrt _vml_cpu not implemented for 'Half'
@lstein
Copy link
Collaborator

lstein commented Aug 24, 2022

I was able to fix the sqrt error message by backing out the changes to ddim.py, lines 20-23. Still do not have confirmation on issue #69.

@warner-benjamin
Copy link
Contributor Author

warner-benjamin commented Aug 24, 2022

I thought I had chased down all the orphan device settings that were not respecting the Lightning model's device. But I clearly missed some. Looking into it.

@BlueAmulet BlueAmulet mentioned this pull request Aug 24, 2022
@warner-benjamin
Copy link
Contributor Author

I see you beat me to resolving it using a similar method to my approach.

austinbrown34 pushed a commit to cognidesign/InvokeAI that referenced this pull request Dec 30, 2022
…to fail with the message 'sqrt _vml_cpu not implemented for 'Half'
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

Successfully merging this pull request may close these issues.

3 participants