|
@@ -5,6 +5,8 @@ import (
|
|
|
"log"
|
|
|
"os"
|
|
|
|
|
|
+ "github.com/pbnjay/memory"
|
|
|
+
|
|
|
"github.com/jmorganca/ollama/api"
|
|
|
)
|
|
|
|
|
@@ -42,6 +44,26 @@ func New(model string, opts api.Options) (LLM, error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ totalResidentMemory := memory.TotalMemory()
|
|
|
+ switch ggml.ModelType {
|
|
|
+ case ModelType3B, ModelType7B:
|
|
|
+ if totalResidentMemory < 8*1024*1024 {
|
|
|
+ return nil, fmt.Errorf("model requires at least 8GB of memory")
|
|
|
+ }
|
|
|
+ case ModelType13B:
|
|
|
+ if totalResidentMemory < 16*1024*1024 {
|
|
|
+ return nil, fmt.Errorf("model requires at least 16GB of memory")
|
|
|
+ }
|
|
|
+ case ModelType30B:
|
|
|
+ if totalResidentMemory < 32*1024*1024 {
|
|
|
+ return nil, fmt.Errorf("model requires at least 32GB of memory")
|
|
|
+ }
|
|
|
+ case ModelType65B:
|
|
|
+ if totalResidentMemory < 64*1024*1024 {
|
|
|
+ return nil, fmt.Errorf("model requires at least 64GB of memory")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
switch ggml.ModelFamily {
|
|
|
case ModelFamilyLlama:
|
|
|
return newLlama(model, opts)
|