@@ -46,21 +46,18 @@ public static SystemInfo Get()
46
46
{
47
47
// Get Vulkan Summary
48
48
string ? vulkanSummary = GetVulkanSummary ( ) ;
49
-
50
49
// If we have a Vulkan summary
51
50
if ( vulkanSummary != null )
52
51
{
53
52
// Extract Vulkan version from summary
54
53
string ? vulkanVersion = ExtractVulkanVersionFromSummary ( vulkanSummary ) ;
55
-
56
54
// If we have a Vulkan version
57
55
if ( vulkanVersion != null )
58
56
{
59
57
// Return the Vulkan version
60
58
return vulkanVersion ;
61
59
}
62
60
}
63
-
64
61
// Return null if we failed to get the Vulkan version
65
62
return null ;
66
63
}
@@ -83,7 +80,6 @@ public static SystemInfo Get()
83
80
}
84
81
} ;
85
82
var ( exitCode , output , error , ok ) = process . SafeRun ( TimeSpan . FromSeconds ( 12 ) ) ;
86
-
87
83
// If ok return the output else return null
88
84
return ok ? output :
89
85
null ;
@@ -99,32 +95,25 @@ public static SystemInfo Get()
99
95
// We have three ways of parsing the Vulkan version from the summary (output is a different between Windows and Linux)
100
96
// For now, I have decided to go with the full version number, and leave it up to the user to parse it further if needed
101
97
// I have left the other patterns in, in case we need them in the future
102
-
103
98
// Output on linux : 4206847 (1.3.255)
104
99
// Output on windows : 1.3.255
105
100
string pattern = @"apiVersion\s*=\s*([^\r\n]+)" ;
106
-
107
101
// Output on linux : 4206847
108
102
// Output on windows : 1.3.255
109
103
//string pattern = @"apiVersion\s*=\s*([\d\.]+)";
110
-
111
104
// Output on linux : 1.3.255
112
105
// Output on windows : 1.3.255
113
106
//string pattern = @"apiVersion\s*=\s*(?:\d+\s*)?(?:\(\s*)?([\d]+\.[\d]+\.[\d]+)(?:\s*\))?";
114
-
115
107
// Create a Regex object to match the pattern
116
108
Regex regex = new Regex ( pattern ) ;
117
-
118
109
// Match the pattern in the input string
119
110
Match match = regex . Match ( vulkanSummary ) ;
120
-
121
111
// If a match is found
122
112
if ( match . Success )
123
113
{
124
114
// Return the version number
125
115
return match . Groups [ 1 ] . Value ;
126
116
}
127
-
128
117
// Return null if no match is found
129
118
return null ;
130
119
}
@@ -142,15 +131,12 @@ private static int GetCudaMajorVersion()
142
131
{
143
132
return - 1 ;
144
133
}
145
-
146
134
//Ensuring cuda bin path is reachable. Especially for MAUI environment.
147
135
string cudaBinPath = Path . Combine ( cudaPath , "bin" ) ;
148
-
149
136
if ( Directory . Exists ( cudaBinPath ) )
150
137
{
151
138
AddDllDirectory ( cudaBinPath ) ;
152
139
}
153
-
154
140
version = GetCudaVersionFromPath ( cudaPath ) ;
155
141
}
156
142
else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
@@ -160,14 +146,12 @@ private static int GetCudaMajorVersion()
160
146
{
161
147
return ExtractMajorVersion ( ref env_version ) ;
162
148
}
163
-
164
149
// List of default cuda paths
165
150
string [ ] defaultCudaPaths =
166
151
[
167
152
"/usr/local/bin/cuda" ,
168
153
"/usr/local/cuda" ,
169
154
] ;
170
-
171
155
// Loop through every default path to find the version
172
156
foreach ( var path in defaultCudaPaths )
173
157
{
@@ -178,7 +162,6 @@ private static int GetCudaMajorVersion()
178
162
if ( ! string . IsNullOrEmpty ( version ) )
179
163
break ;
180
164
}
181
-
182
165
if ( string . IsNullOrEmpty ( version ) )
183
166
{
184
167
cudaPath = Environment . GetEnvironmentVariable ( "LD_LIBRARY_PATH" ) ;
@@ -233,7 +216,6 @@ private static string GetCudaVersionFromPath(string cudaPath)
233
216
// Put it here to avoid calling NativeApi when getting the cuda version.
234
217
[ DllImport ( "kernel32.dll" , CharSet = CharSet . Unicode , SetLastError = true ) ]
235
218
internal static extern int AddDllDirectory ( string NewDirectory ) ;
236
-
237
219
private const string cudaVersionFile = "version.json" ;
238
220
#endregion
239
221
}
0 commit comments