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

Использует память GPU , когда явно указано 'cpu' #26

Open
MichaelMonashev opened this issue Apr 4, 2023 · 2 comments

Comments

@MichaelMonashev
Copy link

Code to reproduce:

from kandinsky2 import get_kandinsky2

model = get_kandinsky2('cpu', task_type='text2img', cache_dir='/tmp/kandinsky2', model_version='2.1', use_flash_attention=False)

after run nvidia-smi

@pablonieto0981
Copy link

Hi, yesterday faced this issue, and solved it with a hack. Basically you should go into the unet.py (of the kandinsky library) and change self.use_fp16 = use_fp16 to self.use_fp16 = False #use_fp16; also you might probably need to chnage, in the conv.py of PyTorch library...

return F.conv2d(input, weight, bias, self.stride, self.padding, self.dilation, self.groups)

to

return F.conv2d(input.float(), weight, bias, self.stride, self.padding, self.dilation, self.groups)

...in both cases the problem is that some weights of the model are changed to fp16, which is only accepted by the GPU, thus raising an error. .float() makes them fp32, which are CPU acceptable.

@WojtekKowaluk
Copy link

@pablonieto0981, I think better place to change this is configs.py, not unet.py. This is what worked for me:
#36

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

3 participants