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
8ea50044
Unverified
Commit
8ea50044
authored
Jul 10, 2024
by
Daniel Hiltgen
Committed by
GitHub
Jul 10, 2024
Browse files
Merge pull request #5580 from dhiltgen/cuda_overhead
Detect CUDA OS overhead
parents
b50c8186
f6f759fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
gpu/gpu.go
gpu/gpu.go
+27
-0
gpu/types.go
gpu/types.go
+2
-1
No files found.
gpu/gpu.go
View file @
8ea50044
...
@@ -274,6 +274,28 @@ func GetGPUInfo() GpuInfoList {
...
@@ -274,6 +274,28 @@ func GetGPUInfo() GpuInfoList {
gpuInfo
.
DriverMajor
=
driverMajor
gpuInfo
.
DriverMajor
=
driverMajor
gpuInfo
.
DriverMinor
=
driverMinor
gpuInfo
.
DriverMinor
=
driverMinor
// query the management library as well so we can record any skew between the two
// which represents overhead on the GPU we must set aside on subsequent updates
if
cHandles
.
nvml
!=
nil
{
C
.
nvml_get_free
(
*
cHandles
.
nvml
,
C
.
int
(
gpuInfo
.
index
),
&
memInfo
.
free
,
&
memInfo
.
total
,
&
memInfo
.
used
)
if
memInfo
.
err
!=
nil
{
slog
.
Warn
(
"error looking up nvidia GPU memory"
,
"error"
,
C
.
GoString
(
memInfo
.
err
))
C
.
free
(
unsafe
.
Pointer
(
memInfo
.
err
))
}
else
{
if
memInfo
.
free
!=
0
&&
uint64
(
memInfo
.
free
)
>
gpuInfo
.
FreeMemory
{
gpuInfo
.
OSOverhead
=
uint64
(
memInfo
.
free
)
-
gpuInfo
.
FreeMemory
slog
.
Info
(
"detected OS VRAM overhead"
,
"id"
,
gpuInfo
.
ID
,
"library"
,
gpuInfo
.
Library
,
"compute"
,
gpuInfo
.
Compute
,
"driver"
,
fmt
.
Sprintf
(
"%d.%d"
,
gpuInfo
.
DriverMajor
,
gpuInfo
.
DriverMinor
),
"name"
,
gpuInfo
.
Name
,
"overhead"
,
format
.
HumanBytes2
(
gpuInfo
.
OSOverhead
),
)
}
}
}
// TODO potentially sort on our own algorithm instead of what the underlying GPU library does...
// TODO potentially sort on our own algorithm instead of what the underlying GPU library does...
cudaGPUs
=
append
(
cudaGPUs
,
gpuInfo
)
cudaGPUs
=
append
(
cudaGPUs
,
gpuInfo
)
}
}
...
@@ -374,9 +396,14 @@ func GetGPUInfo() GpuInfoList {
...
@@ -374,9 +396,14 @@ func GetGPUInfo() GpuInfoList {
slog
.
Warn
(
"error looking up nvidia GPU memory"
)
slog
.
Warn
(
"error looking up nvidia GPU memory"
)
continue
continue
}
}
if
cHandles
.
nvml
!=
nil
&&
gpu
.
OSOverhead
>
0
{
// When using the management library update based on recorded overhead
memInfo
.
free
-=
C
.
uint64_t
(
gpu
.
OSOverhead
)
}
slog
.
Debug
(
"updating cuda memory data"
,
slog
.
Debug
(
"updating cuda memory data"
,
"gpu"
,
gpu
.
ID
,
"gpu"
,
gpu
.
ID
,
"name"
,
gpu
.
Name
,
"name"
,
gpu
.
Name
,
"overhead"
,
format
.
HumanBytes2
(
gpu
.
OSOverhead
),
slog
.
Group
(
slog
.
Group
(
"before"
,
"before"
,
"total"
,
format
.
HumanBytes2
(
gpu
.
TotalMemory
),
"total"
,
format
.
HumanBytes2
(
gpu
.
TotalMemory
),
...
...
gpu/types.go
View file @
8ea50044
...
@@ -52,6 +52,7 @@ type CPUInfo struct {
...
@@ -52,6 +52,7 @@ type CPUInfo struct {
type
CudaGPUInfo
struct
{
type
CudaGPUInfo
struct
{
GpuInfo
GpuInfo
OSOverhead
uint64
// Memory overhead between the driver library and management library
index
int
//nolint:unused,nolintlint
index
int
//nolint:unused,nolintlint
}
}
type
CudaGPUInfoList
[]
CudaGPUInfo
type
CudaGPUInfoList
[]
CudaGPUInfo
...
...
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