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
63269668
Unverified
Commit
63269668
authored
Dec 10, 2024
by
frob
Committed by
GitHub
Dec 10, 2024
Browse files
Prevent underflow when FreeMemory < overhead (#8014)
Co-authored-by:
Richard Lyons
<
frob@cloudstaff.com
>
parent
900f64e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
llm/memory.go
llm/memory.go
+3
-3
No files found.
llm/memory.go
View file @
63269668
...
...
@@ -182,7 +182,7 @@ func EstimateGPULayers(gpus []discover.GpuInfo, ggml *GGML, projectors []string,
gzo
=
gpuZeroOverhead
}
// Only include GPUs that can fit the graph, gpu minimum, the layer buffer and at least more layer
if
(
gpus
[
i
]
.
FreeMemory
-
overhead
)
<
gzo
+
max
(
graphPartialOffload
,
graphFullOffload
)
+
gpus
[
i
]
.
MinimumMemory
+
2
*
layerSize
{
if
gpus
[
i
]
.
FreeMemory
<
overhead
+
gzo
+
max
(
graphPartialOffload
,
graphFullOffload
)
+
gpus
[
i
]
.
MinimumMemory
+
2
*
layerSize
{
slog
.
Debug
(
"gpu has too little memory to allocate any layers"
,
"id"
,
gpus
[
i
]
.
ID
,
"library"
,
gpus
[
i
]
.
Library
,
...
...
@@ -228,7 +228,7 @@ func EstimateGPULayers(gpus []discover.GpuInfo, ggml *GGML, projectors []string,
for
j
:=
len
(
gpusWithSpace
);
j
>
0
;
j
--
{
g
:=
gpusWithSpace
[
i
%
j
]
used
:=
gpuAllocations
[
g
.
i
]
+
max
(
graphPartialOffload
,
graphFullOffload
)
if
(
g
.
g
.
FreeMemory
-
overhead
)
>
used
+
layerSize
{
if
g
.
g
.
FreeMemory
>
overhead
+
used
+
layerSize
{
gpuAllocations
[
g
.
i
]
+=
layerSize
layerCounts
[
g
.
i
]
++
layerCount
++
...
...
@@ -251,7 +251,7 @@ func EstimateGPULayers(gpus []discover.GpuInfo, ggml *GGML, projectors []string,
for
j
:=
len
(
gpusWithSpace
);
j
>
0
;
j
--
{
g
:=
gpusWithSpace
[
layerCount
%
j
]
used
:=
gpuAllocations
[
g
.
i
]
+
max
(
graphPartialOffload
,
graphFullOffload
)
if
(
g
.
g
.
FreeMemory
-
overhead
)
>
used
+
memoryLayerOutput
{
if
g
.
g
.
FreeMemory
>
overhead
+
used
+
memoryLayerOutput
{
gpuAllocations
[
g
.
i
]
+=
memoryLayerOutput
layerCounts
[
g
.
i
]
++
layerCount
++
...
...
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