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
5bca2e60
Commit
5bca2e60
authored
Aug 09, 2024
by
Daniel Hiltgen
Browse files
Harden intel boostrap for nil pointers
parent
e9aa5117
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
29 deletions
+32
-29
gpu/gpu.go
gpu/gpu.go
+32
-29
No files found.
gpu/gpu.go
View file @
5bca2e60
...
@@ -305,38 +305,41 @@ func GetGPUInfo() GpuInfoList {
...
@@ -305,38 +305,41 @@ func GetGPUInfo() GpuInfoList {
// Intel
// Intel
if
envconfig
.
IntelGPU
()
{
if
envconfig
.
IntelGPU
()
{
oHandles
=
initOneAPIHandles
()
oHandles
=
initOneAPIHandles
()
// On windows we bundle the oneapi library one level above the runner dir
if
oHandles
!=
nil
&&
oHandles
.
oneapi
!=
nil
{
depPath
=
""
if
runtime
.
GOOS
==
"windows"
&&
envconfig
.
RunnersDir
()
!=
""
{
depPath
=
filepath
.
Join
(
filepath
.
Dir
(
envconfig
.
RunnersDir
()),
"oneapi"
)
}
for
d
:=
range
oHandles
.
oneapi
.
num_drivers
{
// On windows we bundle the oneapi library one level above the runner dir
if
oHandles
.
oneapi
==
nil
{
depPath
=
""
// shouldn't happen
if
runtime
.
GOOS
==
"windows"
&&
envconfig
.
RunnersDir
()
!=
""
{
slog
.
Warn
(
"nil oneapi handle with driver count"
,
"count"
,
int
(
oHandles
.
oneapi
.
num_drivers
))
depPath
=
filepath
.
Join
(
filepath
.
Dir
(
envconfig
.
RunnersDir
()),
"oneapi"
)
continue
}
}
devCount
:=
C
.
oneapi_get_device_count
(
*
oHandles
.
oneapi
,
C
.
int
(
d
))
for
i
:=
range
devCount
{
for
d
:=
range
oHandles
.
oneapi
.
num_drivers
{
gpuInfo
:=
OneapiGPUInfo
{
if
oHandles
.
oneapi
==
nil
{
GpuInfo
:
GpuInfo
{
// shouldn't happen
Library
:
"oneapi"
,
slog
.
Warn
(
"nil oneapi handle with driver count"
,
"count"
,
int
(
oHandles
.
oneapi
.
num_drivers
))
},
continue
driverIndex
:
int
(
d
),
}
gpuIndex
:
int
(
i
),
devCount
:=
C
.
oneapi_get_device_count
(
*
oHandles
.
oneapi
,
C
.
int
(
d
))
for
i
:=
range
devCount
{
gpuInfo
:=
OneapiGPUInfo
{
GpuInfo
:
GpuInfo
{
Library
:
"oneapi"
,
},
driverIndex
:
int
(
d
),
gpuIndex
:
int
(
i
),
}
// TODO - split bootstrapping from updating free memory
C
.
oneapi_check_vram
(
*
oHandles
.
oneapi
,
C
.
int
(
d
),
i
,
&
memInfo
)
// TODO - convert this to MinimumMemory based on testing...
var
totalFreeMem
float64
=
float64
(
memInfo
.
free
)
*
0.95
// work-around: leave some reserve vram for mkl lib used in ggml-sycl backend.
memInfo
.
free
=
C
.
uint64_t
(
totalFreeMem
)
gpuInfo
.
TotalMemory
=
uint64
(
memInfo
.
total
)
gpuInfo
.
FreeMemory
=
uint64
(
memInfo
.
free
)
gpuInfo
.
ID
=
C
.
GoString
(
&
memInfo
.
gpu_id
[
0
])
gpuInfo
.
Name
=
C
.
GoString
(
&
memInfo
.
gpu_name
[
0
])
gpuInfo
.
DependencyPath
=
depPath
oneapiGPUs
=
append
(
oneapiGPUs
,
gpuInfo
)
}
}
// TODO - split bootstrapping from updating free memory
C
.
oneapi_check_vram
(
*
oHandles
.
oneapi
,
C
.
int
(
d
),
i
,
&
memInfo
)
// TODO - convert this to MinimumMemory based on testing...
var
totalFreeMem
float64
=
float64
(
memInfo
.
free
)
*
0.95
// work-around: leave some reserve vram for mkl lib used in ggml-sycl backend.
memInfo
.
free
=
C
.
uint64_t
(
totalFreeMem
)
gpuInfo
.
TotalMemory
=
uint64
(
memInfo
.
total
)
gpuInfo
.
FreeMemory
=
uint64
(
memInfo
.
free
)
gpuInfo
.
ID
=
C
.
GoString
(
&
memInfo
.
gpu_id
[
0
])
gpuInfo
.
Name
=
C
.
GoString
(
&
memInfo
.
gpu_name
[
0
])
gpuInfo
.
DependencyPath
=
depPath
oneapiGPUs
=
append
(
oneapiGPUs
,
gpuInfo
)
}
}
}
}
}
}
...
...
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