Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow for using CPU if no CUDA device is detected #123

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

Open
Urcra wants to merge 3 commits into CompVis:main
base: main
Choose a base branch
Loading
from Urcra:main

Conversation

@Urcra
Copy link

@Urcra Urcra commented Aug 17, 2022
edited
Loading

Allows for running on the CPU if no CUDA device is detected instead of just giving a runtime error.

This should allow for more people to experiment even without owning an nvidia GPU

Solves:

leszekhanusz, ModeratePrawn, phreeware, jieran233, voidpunk, giovannefeitosa, armen-tractatus, and Nat-Wolflight reacted with thumbs up emoji
Copy link

@leszekhanusz leszekhanusz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it works!

It is my understanding that by default, pytorch puts everything on the cpu and you have to specify .cuda() or .to(torch.device("cuda") to move things to the gpu.

So I think that maybe all the model.cpu() calls are not needed. Same for .to(torch.device("cpu"))

Urcra reacted with thumbs up emoji
Copy link

leszekhanusz commented Aug 18, 2022
edited
Loading

Currently I am using export CUDA_VISIBLE_DEVICES="" to test using the only the cpu with your code.

It would be neat if we could use a --disable-cuda flag as described in pytorch device-agnostic example to use the cpu explicitely without having to mess with environment variables.

This would be useful for example when you have a GPU but not not enough VRAM to put the model on it.

MojoJojo43, DGuzak, choasma, and tianye2856 reacted with heart emoji

Copy link
Author

Urcra commented Aug 18, 2022

Thanks, it works!

It is my understanding that by default, pytorch puts everything on the cpu and you have to specify .cuda() or .to(torch.device("cuda") to move things to the gpu.

So I think that maybe all the model.cpu() calls are not needed. Same for .to(torch.device("cpu"))

👍 Yeah you are right, just didn't think about that when I first made the PR, but I fixed it now, so it's a bit cleaner

Copy link
Author

Urcra commented Aug 18, 2022

Currently I am using export CUDA_VISIBLE_DEVICES="" to test using the only the cpu with your code.

It would be neat if we could use a --disable-cuda flag as described in pytorch device-agnostic example to use the cpu explicitely without having to mess with environment variables.

This would be useful for example when you have a GPU but not not enough VRAM to put the model on it.

Wanted to also do this, but it's pretty annoying to pass new arguments into the classes from encoder/modules.py and I wasn't really sure if I wanted to create a global variable for it or how it could best be solved, open to any ideas though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@leszekhanusz leszekhanusz leszekhanusz left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /