diff --git a/keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py b/keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py index 3d69648a..3e230d51 100644 --- a/keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py +++ b/keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py @@ -6,16 +6,35 @@ # double check the file with the already available version to check if there is a mistake from keopscore.binders.LinkCompile import LinkCompile import keopscore.config -from keopscore.config.config import ( - cuda_version, - jit_binary, - cxx_compiler, - nvrtc_flags, - nvrtc_include, - jit_source_file, - cuda_available, - get_build_folder, -) +from keopscore.config.base_config import ConfigNew +from keopscore.config.cuda import CUDAConfig +# from keopscore.config.config import ( +# cuda_version, +# jit_binary, +# cxx_compiler, +# nvrtc_flags, +# nvrtc_include, +# jit_source_file, +# cuda_available, +# get_build_folder, +# ) + +base_config = ConfigNew() +cuda_config = CUDAConfig() + +cuda_version = cuda_config.get_cuda_version() +jit_binary = base_config.get_jit_binary() +cxx_compiler = base_config.get_cxx_compiler() +compile_options = " -shared -fPIC -O3 -std=c++11" +nvrtc_flags = ( + compile_options + + f" -fpermissive -L{cuda_config.get_libcuda_folder()} -L{cuda_config.get_libnvrtc_folder()} -lcuda -lnvrtc" + ) +# add nvrtc_include +# add jit_source_file, +# add cuda_available, +# add get_build_folder, + from keopscore.utils.misc_utils import KeOps_Error, KeOps_Message, KeOps_OS_Run from keopscore.utils.gpu_utils import get_gpu_props, custom_cuda_include_fp16_path diff --git a/keopscore/keopscore/config/base_config.py b/keopscore/keopscore/config/base_config.py index f8f5f370..ad2ff39f 100644 --- a/keopscore/keopscore/config/base_config.py +++ b/keopscore/keopscore/config/base_config.py @@ -297,8 +297,8 @@ def set_build_folder( if not os.path.exists(jit_compile_dll()): Gpu_link_compile.compile_jit_compile_dll() - def get_build_folder(self): - return self._build_path + def get_build_folder(self): + return self._build_path # Environment variables printing method def print_environment_variables(self): diff --git a/keopscore/keopscore/config/cuda.py b/keopscore/keopscore/config/cuda.py index b11b113a..209c03f7 100644 --- a/keopscore/keopscore/config/cuda.py +++ b/keopscore/keopscore/config/cuda.py @@ -31,6 +31,8 @@ def __init__(self): super().__init__() self.set_use_cuda() self.set_specific_gpus() + self.set_libcuda_folder() + self.set_libnvrtc_folder() def set_use_cuda(self): """Determine and set whether to use CUDA.""" @@ -72,6 +74,26 @@ def print_specific_gpus(self): else: print("Specific GPUs (CUDA_VISIBLE_DEVICES): Not Set") + def set_libcuda_folder(self): + """Check if CUDA libraries are available, and then set libcuda_folder""" + cuda_lib = find_library("cuda") + nvrtc_lib = find_library("nvrtc") + if cuda_lib and nvrtc_lib: + self.libcuda_folder = os.path.dirname(self.find_library_abspath("cuda")) + + def get_libcuda_folder(self): + return self.libcuda_folder + + def set_libnvrtc_folder(self): + """Check if CUDA libraries are available, and then set libnvrtc_folder""" + cuda_lib = find_library("cuda") + nvrtc_lib = find_library("nvrtc") + if cuda_lib and nvrtc_lib: + self.libnvrtc_folder = os.path.dirname(self.find_library_abspath("nvrtc")) + + def get_libnvrtc_folder(self): + return self.libnvrtc_folder + def _cuda_libraries_available(self): """Check if CUDA libraries are available.""" cuda_lib = find_library("cuda") diff --git a/pykeops/pykeops/config.py b/pykeops/pykeops/config.py index d71a7fcb..43fa102e 100644 --- a/pykeops/pykeops/config.py +++ b/pykeops/pykeops/config.py @@ -13,7 +13,7 @@ from keopscore.config.base_config import ConfigNew gpu_available = CUDAconfig.get_use_cuda() -get_build_folder = ConfigNew.get_default_build_folder_name() +get_build_folder = ConfigNew.get_build_folder() def pykeops_nvrtc_name(type="src"):