Skip to content

Commit

Permalink
add additional checks for cuda library
Browse files Browse the repository at this point in the history
  • Loading branch information
g1y5x3 committed Dec 17, 2023
1 parent 3d402bb commit fa9a98b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions gpuctypes/check_cuda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ctypes

def is_libnvrtc_available():
try:
ctypes.CDLL("libnvrtc.so")
return True
except OSError:
return False

def is_libcuda_available():
try:
ctypes.CDLL("libcuda.so")
return True
except OSError:
return False

def is_cuda_available():
if is_libcuda_available() and is_libnvrtc_available():
pass
else:
raise ImportError("libcuda.so or libnvrtc.so is not available. Please check your CUDA installation!")

3 changes: 2 additions & 1 deletion gpuctypes/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# LONGDOUBLE_SIZE is: 16
#
import ctypes, ctypes.util

from gpuctypes.check_cuda import is_cuda_available
is_cuda_available()

class AsDictMixin:
@classmethod
Expand Down

0 comments on commit fa9a98b

Please sign in to comment.