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
36fe2dee
Commit
36fe2dee
authored
Oct 13, 2023
by
Michael Yang
Browse files
only check system memory on macos
parent
4a8931f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
28 deletions
+21
-28
llm/llm.go
llm/llm.go
+21
-28
No files found.
llm/llm.go
View file @
36fe2dee
...
@@ -56,38 +56,31 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
...
@@ -56,38 +56,31 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
opts
.
NumGPU
=
0
opts
.
NumGPU
=
0
}
}
}
}
}
var
requiredMemory
int64
var
f16Multiplier
int64
=
2
switch
ggml
.
ModelType
()
{
case
"3B"
,
"7B"
:
requiredMemory
=
8
*
format
.
GigaByte
case
"13B"
:
requiredMemory
=
16
*
format
.
GigaByte
case
"30B"
,
"34B"
,
"40B"
:
requiredMemory
=
32
*
format
.
GigaByte
case
"65B"
,
"70B"
:
requiredMemory
=
64
*
format
.
GigaByte
case
"180B"
:
requiredMemory
=
128
*
format
.
GigaByte
f16Multiplier
=
4
}
systemMemory
:=
int64
(
memory
.
TotalMemory
())
var
requiredMemory
int64
var
f16Multiplier
int64
=
2
videoMemory
,
err
:=
CheckVRAM
()
switch
ggml
.
ModelType
()
{
if
err
!=
nil
{
case
"3B"
,
"7B"
:
videoMemory
=
0
requiredMemory
=
8
*
format
.
GigaByte
}
case
"13B"
:
requiredMemory
=
16
*
format
.
GigaByte
case
"30B"
,
"34B"
,
"40B"
:
requiredMemory
=
32
*
format
.
GigaByte
case
"65B"
,
"70B"
:
requiredMemory
=
64
*
format
.
GigaByte
case
"180B"
:
requiredMemory
=
128
*
format
.
GigaByte
f16Multiplier
=
4
}
total
Memory
:=
systemMemory
+
video
Memory
system
Memory
:=
int64
(
memory
.
Total
Memory
())
if
ggml
.
FileType
()
==
"F16"
&&
requiredMemory
*
f16Multiplier
>
totalMemory
{
if
ggml
.
FileType
()
==
"F16"
&&
requiredMemory
*
f16Multiplier
>
systemMemory
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least %s of total memory"
,
format
.
HumanBytes
(
requiredMemory
))
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least %s of total memory"
,
format
.
HumanBytes
(
requiredMemory
))
}
else
if
requiredMemory
>
totalMemory
{
}
else
if
requiredMemory
>
systemMemory
{
return
nil
,
fmt
.
Errorf
(
"model requires at least %s of total memory"
,
format
.
HumanBytes
(
requiredMemory
))
return
nil
,
fmt
.
Errorf
(
"model requires at least %s of total memory"
,
format
.
HumanBytes
(
requiredMemory
))
}
}
}
switch
ggml
.
Name
()
{
switch
ggml
.
Name
()
{
...
...
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