Skip to content

Commit

Permalink
fixing module issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nizben committed Nov 6, 2024
1 parent f6cc393 commit 854d8e4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
39 changes: 29 additions & 10 deletions keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions keopscore/keopscore/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
22 changes: 22 additions & 0 deletions keopscore/keopscore/config/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pykeops/pykeops/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 854d8e4

Please sign in to comment.