-
Notifications
You must be signed in to change notification settings - Fork 219
_decide_nvjitlink_or_driver() bug fix and enhancements [no ci]
#1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
9ad6bcd
9390c85
2ccdc21
6bf421e
9220d58
c9a95c0
7e9fce4
4724769
6630d8e
f1c29f6
0948942
00e6421
b237669
6787ddf
4dc08e7
9721041
c1a767f
5ba11be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| from __future__ import annotations | ||
|
|
||
| import ctypes | ||
| import importlib | ||
| import sys | ||
| import weakref | ||
| from contextlib import contextmanager | ||
| from dataclasses import dataclass | ||
|
|
@@ -37,28 +39,35 @@ def _decide_nvjitlink_or_driver() -> bool: | |
|
|
||
| _driver_ver = handle_return(driver.cuDriverGetVersion()) | ||
| _driver_ver = (_driver_ver // 1000, (_driver_ver % 1000) // 10) | ||
|
|
||
| def libname(): | ||
| return "nvJitLink*.dll" if sys.platform == "win32" else "libnvJitLink.so*" | ||
|
|
||
| therefore_not_usable = ". Therefore cuda.bindings.nvjitlink is not usable and" | ||
rwgk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| try: | ||
| from cuda.bindings import nvjitlink as _nvjitlink | ||
| _nvjitlink = importlib.import_module("cuda.bindings.nvjitlink") | ||
rwgk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| except ModuleNotFoundError: | ||
| problem = "cuda.bindings.nvjitlink is not available, therefore" | ||
| else: | ||
| from cuda.bindings._internal import nvjitlink as inner_nvjitlink | ||
| except ImportError: | ||
| # binding is not available | ||
|
|
||
| try: | ||
| if inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion"): | ||
| return False # Use nvjitlink | ||
| except RuntimeError: | ||
| problem = libname() + " is not available" + therefore_not_usable | ||
| else: | ||
| problem = libname() + " is is too old (<12.3)" + therefore_not_usable | ||
| _nvjitlink = None | ||
| else: | ||
| if inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion") == 0: | ||
| # binding is available, but nvJitLink is not installed | ||
| _nvjitlink = None | ||
|
|
||
| if _nvjitlink is None: | ||
| warn( | ||
| "nvJitLink is not installed or too old (<12.3). Therefore it is not usable " | ||
| "and the culink APIs will be used instead.", | ||
| stacklevel=3, | ||
| category=RuntimeWarning, | ||
| ) | ||
| _driver = driver | ||
| return True | ||
| else: | ||
| return False | ||
|
|
||
| warn( | ||
|
||
| problem + " the culink APIs will be used instead.", | ||
| stacklevel=2, | ||
| category=RuntimeWarning, | ||
| ) | ||
| _driver = driver | ||
| return True | ||
|
|
||
|
|
||
| def _lazy_init(): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.