-
Notifications
You must be signed in to change notification settings - Fork 309
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
Fixes to run on CPU and MPS #36
base: main
Are you sure you want to change the base?
Conversation
d5162d4
to
0648ba7
Compare
kandinsky2/kandinsky2_1_model.py
Outdated
@@ -30,6 +30,8 @@ def __init__( | |||
): | |||
self.config = config | |||
self.device = device | |||
if not torch.has_cuda: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, this does not work upon attempting to run on CPU when having CUDA-enabled version of PyTorch installed (an example use-case: I have a CUDA device, but I want to generate a higher-resolution image, and I don't have enough VRAM to do that on the GPU). Maybe we should check device
directly (at least this workaround works for me)?
if not torch.has_cuda: | |
if device == "cpu": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but maybe device!="cuda"
then, because same is needed for "mps" device (Apple Silicon), I don't know about others.
0648ba7
to
bd5bef9
Compare
I tried the above but i am having this error: RuntimeError: Expected one of cpu, cuda, ipu, xpu, mkldnn, opengl, opencl, ideep, hip, ve, fpga, ort, xla, lazy, vulkan, mps, meta, hpu, mtia, privateuseone device type at start of device string: CUDA |
As far as I understand (from the error message), you wrote CUDA in uppercase in your code, while PyTorch expect lowercase naming. |
Thank you, i managed to get it to work, yer, was trying to push it onto run on CPU, and in the end, the time it takes on the M1 Mac is too crazy, around 40 mins to process. I read on the other thread that it error out due to low gRam on 1070Ti, i ran it on my other window's laptop it also error out due to low gRam. Just dropping down the notes for anyone else that read this thread. |
@WojtekKowaluk , thank you for this fix @clarklight , I've tested on M1 SoC 16GB as well and it achieves 8-10 seconds per iteration in my case, but you can try to use an |
To run this on the Mac, i have to use CPU right, because there is no Cuda on the GPU? I just tested it again running on the CPU, i just tried it again still 120 second per it. from kandinsky2 import get_kandinsky2 |
@clarklight there is no CUDA support in GPU, that's correct. But there is support for another acceleration on the GPU, that's |
@CoruNethron Sweet, thank you! I got it to work! Yes its around 1.3second/it, but the outputted image are not images haha i will try to figure out why. |
@clarklight I took some ideas about image export with unique file name here: |
@CoruNethron Most of my images are broken for some reason.....but if i run it on the web version, it runs fine... |
bd5bef9
to
4b3d3d5
Compare
I'm getting the following error, if I try to use img2img with mps:
|
I have fixed that one, but still getting other errors with img2img
after I change sampler to p_sampler I get another one:
|
There are still some hardcoded references to |
I have fixed samplers, for JSON error I have fixed it here: seruva19/kubin#80 |
is this plms_sampler? I think that one is broken. ddim_sampler and p_sampler should work fine :) |
For mac, MPS can be used. I've also created a pull request to handle mps (69759df)
|
Some changes required to run it on CPU and other devices.