Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
4318e35e
Unverified
Commit
4318e35e
authored
Feb 16, 2024
by
Daniel Hiltgen
Committed by
GitHub
Feb 16, 2024
Browse files
Merge pull request #2553 from dhiltgen/amdgpu_version
Harden AMD driver lookup logic
parents
88622847
9754c6d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
gpu/amd.go
gpu/amd.go
+13
-3
gpu/gpu.go
gpu/gpu.go
+3
-0
No files found.
gpu/amd.go
View file @
4318e35e
...
@@ -2,6 +2,7 @@ package gpu
...
@@ -2,6 +2,7 @@ package gpu
import
(
import
(
"bufio"
"bufio"
"errors"
"fmt"
"fmt"
"io"
"io"
"log/slog"
"log/slog"
...
@@ -24,14 +25,23 @@ const (
...
@@ -24,14 +25,23 @@ const (
)
)
func
AMDDetected
()
bool
{
func
AMDDetected
()
bool
{
_
,
err
:=
AMDDriverVersion
()
// Some driver versions (older?) don't have a version file, so just lookup the parent dir
return
err
==
nil
sysfsDir
:=
filepath
.
Dir
(
DriverVersionFile
)
_
,
err
:=
os
.
Stat
(
sysfsDir
)
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
slog
.
Debug
(
"amd driver not detected "
+
sysfsDir
)
return
false
}
else
if
err
!=
nil
{
slog
.
Debug
(
fmt
.
Sprintf
(
"error looking up amd driver %s %s"
,
sysfsDir
,
err
))
return
false
}
return
true
}
}
func
AMDDriverVersion
()
(
string
,
error
)
{
func
AMDDriverVersion
()
(
string
,
error
)
{
_
,
err
:=
os
.
Stat
(
DriverVersionFile
)
_
,
err
:=
os
.
Stat
(
DriverVersionFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
fmt
.
Errorf
(
"amdgpu file stat error: %s %w"
,
DriverVersionFile
,
err
)
}
}
fp
,
err
:=
os
.
Open
(
DriverVersionFile
)
fp
,
err
:=
os
.
Open
(
DriverVersionFile
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
gpu/gpu.go
View file @
4318e35e
...
@@ -153,6 +153,9 @@ func GetGPUInfo() GpuInfo {
...
@@ -153,6 +153,9 @@ func GetGPUInfo() GpuInfo {
ver
,
err
:=
AMDDriverVersion
()
ver
,
err
:=
AMDDriverVersion
()
if
err
==
nil
{
if
err
==
nil
{
slog
.
Info
(
"AMD Driver: "
+
ver
)
slog
.
Info
(
"AMD Driver: "
+
ver
)
}
else
{
// For now this is benign, but we may eventually need to fail compatibility checks
slog
.
Debug
(
"error looking up amd driver version: %s"
,
err
)
}
}
gfx
:=
AMDGFXVersions
()
gfx
:=
AMDGFXVersions
()
tooOld
:=
false
tooOld
:=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment