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
b5939008
Unverified
Commit
b5939008
authored
Jan 04, 2024
by
Daniel Hiltgen
Committed by
GitHub
Jan 04, 2024
Browse files
Merge pull request #1785 from dhiltgen/win_native_cli
Load dynamic cpu lib on windows
parents
4ad6c9b1
e9ce91e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
8 deletions
+16
-8
llm/ext_server_windows.go
llm/ext_server_windows.go
+1
-4
llm/llama.cpp/gen_windows.ps1
llm/llama.cpp/gen_windows.ps1
+3
-0
llm/llm.go
llm/llm.go
+2
-1
llm/shim_ext_server_windows.go
llm/shim_ext_server_windows.go
+10
-3
No files found.
llm/ext_server_windows.go
View file @
b5939008
package
llm
package
llm
import
(
import
(
"fmt"
"github.com/jmorganca/ollama/api"
"github.com/jmorganca/ollama/api"
)
)
...
@@ -10,6 +8,5 @@ func newDefaultExtServer(model string, adapters, projectors []string, numLayers
...
@@ -10,6 +8,5 @@ func newDefaultExtServer(model string, adapters, projectors []string, numLayers
// On windows we always load the llama.cpp libraries dynamically to avoid startup DLL dependencies
// On windows we always load the llama.cpp libraries dynamically to avoid startup DLL dependencies
// This ensures we can update the PATH at runtime to get everything loaded
// This ensures we can update the PATH at runtime to get everything loaded
// Should not happen
return
newDynamicShimExtServer
(
AvailableShims
[
"cpu"
],
model
,
adapters
,
projectors
,
numLayers
,
opts
)
return
nil
,
fmt
.
Errorf
(
"no default impl on windows - all dynamic"
)
}
}
llm/llama.cpp/gen_windows.ps1
View file @
b5939008
...
@@ -49,6 +49,9 @@ function install {
...
@@ -49,6 +49,9 @@ function install {
md
"
${script:buildDir}
/lib"
-ea
0
>
$null
md
"
${script:buildDir}
/lib"
-ea
0
>
$null
cp
"
${script:buildDir}
/bin/
${script:config}
/ext_server_shared.dll"
"
${script:buildDir}
/lib"
cp
"
${script:buildDir}
/bin/
${script:config}
/ext_server_shared.dll"
"
${script:buildDir}
/lib"
cp
"
${script:buildDir}
/bin/
${script:config}
/llama.dll"
"
${script:buildDir}
/lib"
cp
"
${script:buildDir}
/bin/
${script:config}
/llama.dll"
"
${script:buildDir}
/lib"
# Display the dll dependencies in the build log
dumpbin
/dependents
"
${script:buildDir}
/bin/
${script:config}
/ext_server_shared.dll"
|
select-string
".dll"
}
}
function
cleanup
{
function
cleanup
{
...
...
llm/llm.go
View file @
b5939008
...
@@ -87,7 +87,8 @@ func newLlmServer(library, model string, adapters, projectors []string, numLayer
...
@@ -87,7 +87,8 @@ func newLlmServer(library, model string, adapters, projectors []string, numLayer
if
err
==
nil
{
if
err
==
nil
{
return
srv
,
nil
return
srv
,
nil
}
}
log
.
Printf
(
"Failed to load dynamic library - falling back to CPU mode %s"
,
err
)
log
.
Printf
(
"Failed to load dynamic library %s - falling back to CPU mode %s"
,
library
,
err
)
// TODO - update some state to indicate we were unable to load the GPU library for future "info" ux
}
}
return
newDefaultExtServer
(
model
,
adapters
,
projectors
,
numLayers
,
opts
)
return
newDefaultExtServer
(
model
,
adapters
,
projectors
,
numLayers
,
opts
)
...
...
llm/shim_ext_server_windows.go
View file @
b5939008
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"embed"
"embed"
"log"
"log"
"os"
"os"
"path/filepath"
"strings"
"strings"
)
)
...
@@ -11,14 +12,20 @@ import (
...
@@ -11,14 +12,20 @@ import (
var
libEmbed
embed
.
FS
var
libEmbed
embed
.
FS
func
updatePath
(
dir
string
)
{
func
updatePath
(
dir
string
)
{
tmpDir
:=
filepath
.
Dir
(
dir
)
pathComponents
:=
strings
.
Split
(
os
.
Getenv
(
"PATH"
),
";"
)
pathComponents
:=
strings
.
Split
(
os
.
Getenv
(
"PATH"
),
";"
)
i
:=
0
for
_
,
comp
:=
range
pathComponents
{
for
_
,
comp
:=
range
pathComponents
{
// Case incensitive
if
strings
.
EqualFold
(
comp
,
dir
)
{
if
strings
.
ToLower
(
comp
)
==
strings
.
ToLower
(
dir
)
{
return
return
}
}
// Remove any other prior paths to our temp dir
if
!
strings
.
HasPrefix
(
strings
.
ToLower
(
comp
),
strings
.
ToLower
(
tmpDir
))
{
pathComponents
[
i
]
=
comp
i
++
}
}
}
newPath
:=
strings
.
Join
(
append
(
pathComponents
,
dir
),
";"
)
newPath
:=
strings
.
Join
(
append
(
[]
string
{
dir
},
pathComponents
...
),
";"
)
log
.
Printf
(
"Updating PATH to %s"
,
newPath
)
log
.
Printf
(
"Updating PATH to %s"
,
newPath
)
os
.
Setenv
(
"PATH"
,
newPath
)
os
.
Setenv
(
"PATH"
,
newPath
)
}
}
...
...
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