Skip to content
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

Fix for Nvidia installed deps detection algorithm in gpu.go #4106

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions gpu/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,50 @@ func FindGPULibs(baseLibName string, patterns []string) []string {
patterns = append(patterns, filepath.Join(d, baseLibName+"*"))
}
slog.Debug("gpu library search", "globs", patterns)
for _, pattern := range patterns {
// Exclude the specific directory (reason: PhysX is installed by default with Nvidia drivers and its folder is listed in Environment Variables, but only has cudart64_*.dll and no cublasLt64_*.dll and cublas64_*.dll)
// Nvidia PhysX known to return bogus results (better, disk letter agnostic version of code based on PR#4135)
if strings.Contains(pattern, "PhysX") {
slog.Debug("skipping PhysX cuda library path", "path", pattern)
}
// Ignore glob discovery errors
matches, _ := filepath.Glob(pattern)
for _, match := range matches {
// Resolve any links so we don't try the same lib multiple times
// and weed out any dups across globs
libPath := match
tmp := match
var err error
for ; err == nil; tmp, err = os.Readlink(libPath) {
if !filepath.IsAbs(tmp) {
tmp = filepath.Join(filepath.Dir(libPath), tmp)
}
libPath = tmp
}
new := true
for _, cmp := range gpuLibPaths {
if cmp == libPath {
new = false
break
}
}
if new {
// Check if the files "cudart64_*.dll", "cublasLt64_*.dll", "cublas64_*.dll" exist in the directory
requiredFiles := []string{"cudart64_*.dll", "cublasLt64_*.dll", "cublas64_*.dll"}
allExist := true
for _, requiredFile := range requiredFiles {
files, _ := filepath.Glob(filepath.Join(filepath.Dir(libPath), requiredFile))
if len(files) == 0 {
allExist = false
break
}
}
if allExist {
gpuLibPaths = append(gpuLibPaths, libPath)
}
}
}
}
for _, pattern := range patterns {
// Ignore glob discovery errors
matches, _ := filepath.Glob(pattern)
Expand Down