@@ -55,54 +55,60 @@ cdef int cuPythonInit() except -1 nogil:
55
55
except:
56
56
handle = None
57
57
58
- # Else try default search
59
- if not handle:
60
- LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
61
- try:
62
- handle = win32api.LoadLibraryEx("nvrtc64_112_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
63
- except:
64
- try:
65
- handle = win32api.LoadLibraryEx("nvrtc64_111_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
66
- except:
67
- try:
68
- handle = win32api.LoadLibraryEx("nvrtc64_110_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
69
- except:
70
- pass
71
-
72
- # Final check if DLLs can be found within pip installations
58
+ # Next check if DLLs can be found within pip installations
73
59
if not handle:
60
+ LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000
61
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100
74
62
site_packages = [site.getusersitepackages()] + site.getsitepackages()
75
63
for sp in site_packages:
76
64
mod_path = os.path.join(sp, "nvidia", "cuda_nvrtc", "bin")
77
65
if not os.path.isdir(mod_path):
78
66
continue
79
67
os.add_dll_directory(mod_path)
80
- LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000
81
- LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100
82
- try:
83
- handle = win32api.LoadLibraryEx(
84
- # Note: LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR needs an abs path...
85
- os.path.join(mod_path, "nvrtc64_112_0.dll"),
86
- 0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
87
-
88
- # Note: nvrtc64_120_0.dll calls into nvrtc-builtins64_*.dll which is
89
- # located in the same mod_path.
90
- # Update PATH environ so that the two dlls can find each other
91
- os.environ["PATH"] = os.pathsep.join((os.environ.get("PATH", ""), mod_path))
92
- except:
93
68
try:
94
69
handle = win32api.LoadLibraryEx(
95
- os.path.join(mod_path, "nvrtc64_111_0.dll"),
70
+ # Note: LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR needs an abs path...
71
+ os.path.join(mod_path, "nvrtc64_112_0.dll"),
96
72
0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
73
+
74
+ # Note: nvrtc64_120_0.dll calls into nvrtc-builtins64_*.dll which is
75
+ # located in the same mod_path.
76
+ # Update PATH environ so that the two dlls can find each other
97
77
os.environ["PATH"] = os.pathsep.join((os.environ.get("PATH", ""), mod_path))
98
78
except:
99
79
try:
100
80
handle = win32api.LoadLibraryEx(
101
- os.path.join(mod_path, "nvrtc64_110_0 .dll"),
81
+ os.path.join(mod_path, "nvrtc64_111_0 .dll"),
102
82
0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
103
83
os.environ["PATH"] = os.pathsep.join((os.environ.get("PATH", ""), mod_path))
104
84
except:
105
- pass
85
+ try:
86
+ handle = win32api.LoadLibraryEx(
87
+ os.path.join(mod_path, "nvrtc64_110_0.dll"),
88
+ 0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
89
+ os.environ["PATH"] = os.pathsep.join((os.environ.get("PATH", ""), mod_path))
90
+ except:
91
+ pass
92
+ else:
93
+ break
94
+ else:
95
+ break
96
+ else:
97
+ break
98
+ else:
99
+ # Else try default search
100
+ # Only reached if DLL wasn't found in any site-package path
101
+ LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
102
+ try:
103
+ handle = win32api.LoadLibraryEx("nvrtc64_112_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
104
+ except:
105
+ try:
106
+ handle = win32api.LoadLibraryEx("nvrtc64_111_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
107
+ except:
108
+ try:
109
+ handle = win32api.LoadLibraryEx("nvrtc64_110_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
110
+ except:
111
+ pass
106
112
107
113
if not handle:
108
114
raise RuntimeError('Failed to LoadLibraryEx nvrtc64_112_0.dll, or nvrtc64_111_0.dll, or nvrtc64_110_0.dll')
0 commit comments