getkeops / keops

KErnel OPerationS, on CPUs and GPUs, with autodiff and without memory overflows
https://www.kernel-operations.io
MIT License
1.02k stars 65 forks source link

pykeops.config.gpu_available is broken if PyTorch is available with GPU support, but without nvcc #336

Open jeanfeydy opened 9 months ago

jeanfeydy commented 9 months ago

Hi @joanglaunes,

I hope that you are doing well! With @Louis-Pujol, we just realized that KeOps is currently broken on configurations where:

This is due to this line in pykeops.torch.__init__.py, that overrides pykeops.config.gpu_available (that is False) with torch.cuda.is_available() (that is True). KeOps then tries to compile formulas using the GPU, which doesn't work since nvrtc.h is not available.

As far as I can tell, a simple fix would just be to remove this line... But since you wrote it back in 2022, I assume that it is there for a reason. What do you think?

Best regards, Jean

joanglaunes commented 9 months ago

Hi @jeanfeydy , I think you are right ; this torch.cuda.is_available() command probably comes from before we implemented keopscore. Maybe I left it because I was thinking that we need torch.cuda.is_available() to be True in any case, but I don't think it is the case : we may be able to use the Gpu in the "from host" mode when cuda is detected as available by keops, but not by PyTorch for some extra reason. So I am just testing your fix now ; we will see if it runs ok.