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

Imports on CPU-only machine fail #18

Closed
Tomiinek opened this issue Aug 3, 2022 · 2 comments
Closed

Imports on CPU-only machine fail #18

Tomiinek opened this issue Aug 3, 2022 · 2 comments

Comments

@Tomiinek
Copy link

Tomiinek commented Aug 3, 2022

Hello,

I am trying to run your awesome CUDA-powered k-means. For testing purposes, I would like to make it runnable also on CPU, but I am getting errors during importing because of this:

__device = cp.cuda.Device().id

which results in:

CUDARuntimeError: cudaErrorNoDevice: no CUDA-capable device is detected

Would you mind changing it to something like:

if torch.cuda.is_available():
  __device = cp.cuda.Device().id
else:
  __device = None

or hiding the imports of get_default_device and set_default_device (they seem to be imported after checking torch.cuda.is_available() anyway, so it should be possible)?

And also getting rid / hiding this:

topk = fn.Topk()

@DeMoriarty
Copy link
Owner

Hi, thanks for trying TorchPQ out!

Unfortunately, currently there's no cpu version of kmeans, since major parts of the code is written in cuda. The changes you suggested could make it possible to import TorchPQ in cpu only environment, but you will not be able to run any of the modules.

You can take a look at fast-pytorch-kmeans, it's implemented purely in python & pytorch, you can run it on both cpu and cuda, and it's pretty fast. The only issue you might face is out-of-memory errors when your dataset or the number of desired clusters is large.

@Tomiinek
Copy link
Author

Tomiinek commented Aug 3, 2022

Thank you for your prompt reply 🙂

Unfortunately, currently there's no cpu version of kmeans, since major parts of the code is written in cuda.

Yeah that is exatcly what I had in mind 😄 But I probably changed my mind, the current version is fine.

You can take a look at fast-pytorch-kmeans, it's implemented purely in python & pytorch, you can run it on both cpu and cuda, and it's pretty fast. The only issue you might face is out-of-memory errors when your dataset or the number of desired clusters is large.

You made my day, thanks 👍

@Tomiinek Tomiinek closed this as completed Aug 3, 2022
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

2 participants