getkeops / keops

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

[KeOps] Error when compiling formula. #213

Open GangLiTarheel opened 2 years ago

GangLiTarheel commented 2 years ago

Hi, I am currently using pykeops-1.6 to avoid the error “RuntimeError: [KeOps] This KeOps shared object has been compiled without cuda support”, via the code pip install git+https://github.com/getkeops/keops.git@python_engine from this issue.

For 1.6 version, It works for torch-bindings example but fails with numpy-bindings example with the error “[KeOps] Error when compiling formula.“. The error message is too short for me to debug. May I ask how should fix this error? See the output below:

_[KeOps] /net/noble/vol1/home/gangliuw/.cache/keops/build has been cleaned. [KeOps] Compiling main dll ... OK [KeOps] Compiling formula SumReduction((Var(0,3,0)-Var(1,3,1))|(Var(0,3,0)-Var(1,3,1)),1) ... [KeOps] Error when compiling formula.

Thank you for your time and efforts! Best, Gang

bcharlier commented 2 years ago

Dear @GangLiTarheel ,

can you try to install the beta test version of PyKeops from pypi. In a shell

pip install pykeops==2.0b0
python -c 'import pykeops; pykeops.test_torch_bindings()'

should return

[KeOps] Compiling cuda jit compiler engine ... OK
[pyKeOps] Compiling nvrtc binder for python ... OK
[KeOps] Generating code for formula Sum_Reduction((Var(0,3,0)-Var(1,3,1))|(Var(0,3,0)-Var(1,3,1)),1) ... OK
pyKeOps with torch bindings is working!
GangLiTarheel commented 2 years ago

Thanks! It works well. You can closed it now. Best, Gang

justram commented 2 years ago

Hello, when I use the beta version in my env, this error happened:

<path-to-conda-env>/keops/utils/gpu_utils.py", line 87, in get_include_file_abspath
    tmp_file = join(keops.config.config.build_path, "tmp.txt")
AttributeError: module 'keops.config' has no attribute 'config'

I can manually modify the gpu_utils.py to make it work, but I think it may worth a note for you.

6  from keops.config.config import cxx_compiler, build_path
86 def get_include_file_abspath(filename):
87     tmp_file = join(build_path, "tmp.txt")

Minimal example to create such env using conda:

conda create --name keops python=3.8
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch -c nvidia
conda install -c anaconda cmake
conda install -c conda-forge cudatoolkit-dev
pip install pykeops==2.0b0
export CUDA_PATH=<path-to-conda-env>/keops/pkgs/cuda-toolkit

python -c 'import pykeops; pykeops.test_torch_bindings()'
joanglaunes commented 2 years ago

Hello @justram , Thank you for notifying us about it. I do not really understand why it was not working for you since there is the import keops.config.config statement at the beginning of the file. However I just did a commit that should fix the problem. Can you tell us if it works for you now using the master branch ? You can install it via pip using pip install git+https://github.com/getkeops/keops.git@master I have not used your suggestion for the correction because the location of the build folder may change during the session, with the use of set_build_folder command. So I replaced it with a getter function instead.

justram commented 2 years ago

Hey @joanglaunes, Thanks for your prompt reply. The latest commit b9fa31b works in my test env 😊, and your solution works better than my awkward fix.