From 2b573bbb158c7b99f9c43d85dc39830b5c987d79 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:20:44 +0000 Subject: [PATCH 1/4] feat: Improve robustness of GPU detection The application was failing to detect the GPU if the CUDA Toolkit was not installed in a standard location. This change improves the robustness of the GPU detection by searching for the required CUDA and nvCOMP libraries in additional locations. The library search logic in `NativeLibrary.cs` has been updated to: - Search for `nvcomp.dll` recursively within the CUDA Toolkit's `bin` directory. - Search for both `cudart64_*.dll` and `nvcomp.dll` in the application's current working directory and base directory. These changes allow the application to detect the GPU even if the CUDA Toolkit is not installed, as long as the required DLLs are provided alongside the application executable. This improves the portability and ease of use of the application. --- GDeflateConsole/NativeLibrary.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/GDeflateConsole/NativeLibrary.cs b/GDeflateConsole/NativeLibrary.cs index 13c2912..495a3f8 100644 --- a/GDeflateConsole/NativeLibrary.cs +++ b/GDeflateConsole/NativeLibrary.cs @@ -72,6 +72,17 @@ static NativeLibrary() private static string? FindCudart() { + // Search in common paths first + string[] searchPaths = { Directory.GetCurrentDirectory(), AppContext.BaseDirectory }; + foreach (var path in searchPaths) + { + var dlls = Directory.GetFiles(path, "cudart64_*.dll", SearchOption.AllDirectories) + .Select(p => new { Path = p, Version = GetVersionFromFileName(p) }) + .OrderByDescending(x => x.Version) + .ToList(); + if (dlls.Any()) return dlls.First().Path; + } + if (_cudaToolkitPath == null) return null; string binPath = Path.Combine(_cudaToolkitPath, "bin"); @@ -101,15 +112,25 @@ static NativeLibrary() private static string? FindNvcomp() { + // Search in common paths first + string[] searchPaths = { Directory.GetCurrentDirectory(), AppContext.BaseDirectory }; + foreach (var path in searchPaths) + { + var nvcompPaths = Directory.GetFiles(path, "nvcomp.dll", SearchOption.AllDirectories); + if (nvcompPaths.Any()) return nvcompPaths.First(); + } + if (_cudaToolkitPath == null) return null; string binPath = Path.Combine(_cudaToolkitPath, "bin"); if (Directory.Exists(binPath)) { - string nvcompPath = Path.Combine(binPath, "nvcomp.dll"); - if (File.Exists(nvcompPath)) + // Search recursively for nvcomp.dll + var nvcompPaths = Directory.GetFiles(binPath, "nvcomp.dll", SearchOption.AllDirectories); + if (nvcompPaths.Length > 0) { - return nvcompPath; + // Return the first match + return nvcompPaths[0]; } } return null; From aa128cd3f7725c837dc7f7e840c507b416fe7153 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:26:49 +0000 Subject: [PATCH 2/4] feat: Broaden search path for CUDA Toolkit on Windows This change addresses a pull request comment to broaden the search path for the CUDA Toolkit on Windows. The `FindCudaToolkitPath` method in `NativeLibrary.cs` has been updated to search for the CUDA Toolkit in both the `Program Files` and `Program Files (x86)` directories. This makes the detection logic more robust on Windows systems. --- GDeflateConsole/NativeLibrary.cs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/GDeflateConsole/NativeLibrary.cs b/GDeflateConsole/NativeLibrary.cs index 495a3f8..39bd314 100644 --- a/GDeflateConsole/NativeLibrary.cs +++ b/GDeflateConsole/NativeLibrary.cs @@ -33,16 +33,29 @@ static NativeLibrary() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - string nvidiaGpuComputingToolkit = Path.Combine(programFiles, "NVIDIA GPU Computing Toolkit", "CUDA"); - if (Directory.Exists(nvidiaGpuComputingToolkit)) + string[] programFilesPaths = { + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + }; + + foreach (var programFilesPath in programFilesPaths.Distinct()) { - var versions = Directory.GetDirectories(nvidiaGpuComputingToolkit, "v*.*") - .Select(path => new { Path = path, Version = GetVersionFromPath(path) }) - .OrderByDescending(x => x.Version) - .ToList(); + if (string.IsNullOrEmpty(programFilesPath)) continue; + + string nvidiaGpuComputingToolkit = Path.Combine(programFilesPath, "NVIDIA GPU Computing Toolkit", "CUDA"); + if (Directory.Exists(nvidiaGpuComputingToolkit)) + { + var versions = Directory.GetDirectories(nvidiaGpuComputingToolkit, "v*.*") + .Select(path => new { Path = path, Version = GetVersionFromPath(path) }) + .OrderByDescending(x => x.Version) + .ToList(); - return versions.FirstOrDefault()?.Path; + var latestVersion = versions.FirstOrDefault(); + if (latestVersion != null) + { + return latestVersion.Path; + } + } } } else From da2507c934f19b07e8741980ea982c6b4f12e05f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:30:48 +0000 Subject: [PATCH 3/4] feat: Add search path for standalone nvCOMP installation This change addresses a pull request comment about the location of the nvCOMP library. The `FindNvcomp` method in `NativeLibrary.cs` has been updated to search for a standalone installation of the nvCOMP library in the `Program Files/NVIDIA Corporation/nvCOMP` directory on Windows. This is in addition to the existing search paths (local directories and the CUDA Toolkit directory). This change increases the robustness of the GPU detection by accommodating different installation configurations for the nvCOMP library. --- GDeflateConsole/NativeLibrary.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/GDeflateConsole/NativeLibrary.cs b/GDeflateConsole/NativeLibrary.cs index 39bd314..e680158 100644 --- a/GDeflateConsole/NativeLibrary.cs +++ b/GDeflateConsole/NativeLibrary.cs @@ -133,6 +133,30 @@ static NativeLibrary() if (nvcompPaths.Any()) return nvcompPaths.First(); } + // Search in standard nvCOMP installation path on Windows + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + string[] programFilesPaths = { + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + }; + + foreach (var programFilesPath in programFilesPaths.Distinct()) + { + if (string.IsNullOrEmpty(programFilesPath)) continue; + + string nvcompInstallPath = Path.Combine(programFilesPath, "NVIDIA Corporation", "nvCOMP"); + if (Directory.Exists(nvcompInstallPath)) + { + var nvcompDllPaths = Directory.GetFiles(nvcompInstallPath, "nvcomp.dll", SearchOption.AllDirectories); + if (nvcompDllPaths.Any()) + { + return nvcompDllPaths.First(); + } + } + } + } + if (_cudaToolkitPath == null) return null; string binPath = Path.Combine(_cudaToolkitPath, "bin"); From 44323dc34687624006122a59dd3272b0481410e9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:35:41 +0000 Subject: [PATCH 4/4] feat: Update nvCOMP search path and DLL name pattern This change addresses a pull request comment providing a more specific path and name for the nvCOMP library. The `FindNvcomp` method in `NativeLibrary.cs` has been updated to: - Search for the `NVIDIA nvCOMP` directory in `Program Files` and `Program Files (x86)`. - Use a wildcard pattern `nvcomp*.dll` to find versioned library names like `nvcomp64_5.dll`. This makes the detection logic more accurate and robust for different nvCOMP installation scenarios. --- GDeflateConsole/NativeLibrary.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GDeflateConsole/NativeLibrary.cs b/GDeflateConsole/NativeLibrary.cs index e680158..fccd0c0 100644 --- a/GDeflateConsole/NativeLibrary.cs +++ b/GDeflateConsole/NativeLibrary.cs @@ -129,7 +129,7 @@ static NativeLibrary() string[] searchPaths = { Directory.GetCurrentDirectory(), AppContext.BaseDirectory }; foreach (var path in searchPaths) { - var nvcompPaths = Directory.GetFiles(path, "nvcomp.dll", SearchOption.AllDirectories); + var nvcompPaths = Directory.GetFiles(path, "nvcomp*.dll", SearchOption.AllDirectories); if (nvcompPaths.Any()) return nvcompPaths.First(); } @@ -145,10 +145,10 @@ static NativeLibrary() { if (string.IsNullOrEmpty(programFilesPath)) continue; - string nvcompInstallPath = Path.Combine(programFilesPath, "NVIDIA Corporation", "nvCOMP"); + string nvcompInstallPath = Path.Combine(programFilesPath, "NVIDIA nvCOMP"); if (Directory.Exists(nvcompInstallPath)) { - var nvcompDllPaths = Directory.GetFiles(nvcompInstallPath, "nvcomp.dll", SearchOption.AllDirectories); + var nvcompDllPaths = Directory.GetFiles(nvcompInstallPath, "nvcomp*.dll", SearchOption.AllDirectories); if (nvcompDllPaths.Any()) { return nvcompDllPaths.First(); @@ -163,7 +163,7 @@ static NativeLibrary() if (Directory.Exists(binPath)) { // Search recursively for nvcomp.dll - var nvcompPaths = Directory.GetFiles(binPath, "nvcomp.dll", SearchOption.AllDirectories); + var nvcompPaths = Directory.GetFiles(binPath, "nvcomp*.dll", SearchOption.AllDirectories); if (nvcompPaths.Length > 0) { // Return the first match