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
b03408de
Unverified
Commit
b03408de
authored
Apr 28, 2024
by
Daniel Hiltgen
Committed by
GitHub
Apr 28, 2024
Browse files
Merge pull request #3972 from hmartinez82/win_arm64
Add support for building on Windows ARM64
parents
1e6a28bf
8a65717f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
17 deletions
+24
-17
app/ollama.iss
app/ollama.iss
+2
-2
llm/generate/gen_windows.ps1
llm/generate/gen_windows.ps1
+12
-8
llm/llm.go
llm/llm.go
+1
-0
scripts/build_windows.ps1
scripts/build_windows.ps1
+9
-7
No files found.
app/ollama.iss
View file @
b03408de
...
@@ -88,8 +88,8 @@ DialogFontSize=12
...
@@ -88,8 +88,8 @@ DialogFontSize=12
[Files]
[Files]
Source: ".\app.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ; Flags: ignoreversion 64bit
Source: ".\app.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ; Flags: ignoreversion 64bit
Source: "..\ollama.exe"; DestDir: "{app}"; Flags: ignoreversion 64bit
Source: "..\ollama.exe"; DestDir: "{app}"; Flags: ignoreversion 64bit
Source: "..\dist\windows-
amd64
\*.dll"; DestDir: "{app}"; Flags: ignoreversion 64bit
Source: "..\dist\windows-
{#ARCH}
\*.dll"; DestDir: "{app}"; Flags: ignoreversion 64bit
Source: "..\dist\windows-
amd64
\ollama_runners\*"; DestDir: "{app}\ollama_runners"; Flags: ignoreversion 64bit recursesubdirs
Source: "..\dist\windows-
{#ARCH}
\ollama_runners\*"; DestDir: "{app}\ollama_runners"; Flags: ignoreversion 64bit recursesubdirs
Source: "..\dist\ollama_welcome.ps1"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\dist\ollama_welcome.ps1"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\assets\app.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\assets\app.ico"; DestDir: "{app}"; Flags: ignoreversion
#if DirExists("..\dist\windows-amd64\rocm")
#if DirExists("..\dist\windows-amd64\rocm")
...
...
llm/generate/gen_windows.ps1
View file @
b03408de
...
@@ -42,7 +42,7 @@ function init_vars {
...
@@ -42,7 +42,7 @@ function init_vars {
"-DLLAMA_NATIVE=off"
"-DLLAMA_NATIVE=off"
)
)
$
script
:
commonCpuDefs
=
@(
"-DCMAKE_POSITION_INDEPENDENT_CODE=on"
)
$
script
:
commonCpuDefs
=
@(
"-DCMAKE_POSITION_INDEPENDENT_CODE=on"
)
$
script
:
ARCH
=
"amd64"
# arm not yet supported.
$
script
:
ARCH
=
$
Env
:
PROCESSOR_ARCHITECTURE
.
ToLower
()
$
script
:
DIST_BASE
=
"
${script:SRC_DIR}
\dist\windows-
${script:ARCH}
\ollama_runners"
$
script
:
DIST_BASE
=
"
${script:SRC_DIR}
\dist\windows-
${script:ARCH}
\ollama_runners"
md
"
$
script
:
DIST_BASE
"
-ea
0
>
$null
md
"
$
script
:
DIST_BASE
"
-ea
0
>
$null
if
(
$
env
:
CGO_CFLAGS
-contains
"-g"
)
{
if
(
$
env
:
CGO_CFLAGS
-contains
"-g"
)
{
...
@@ -213,11 +213,11 @@ function build_static() {
...
@@ -213,11 +213,11 @@ function build_static() {
}
}
}
}
function build_cpu() {
function build_cpu(
$gen_arch
) {
if ((-not "
${env:OLLAMA_SKIP_CPU_GENERATE}
" ) -and ((-not "
${env:OLLAMA_CPU_TARGET}
") -or ("
${env:OLLAMA_CPU_TARGET}
" -eq "
cpu
"))) {
if ((-not "
${env:OLLAMA_SKIP_CPU_GENERATE}
" ) -and ((-not "
${env:OLLAMA_CPU_TARGET}
") -or ("
${env:OLLAMA_CPU_TARGET}
" -eq "
cpu
"))) {
# remaining llama.cpp builds use MSVC
# remaining llama.cpp builds use MSVC
init_vars
init_vars
$
script
:
cmakeDefs
=
$
script
:
commonCpuDefs
+ @("
-A
",
"
x64
"
, "
-DLLAMA_AVX
=
off
", "
-DLLAMA_AVX2
=
off
", "
-DLLAMA_AVX512
=
off
", "
-DLLAMA_FMA
=
off
", "
-DLLAMA_F16C
=
off
") +
$
script
:
cmakeDefs
$
script
:
cmakeDefs
=
$
script
:
commonCpuDefs
+ @("
-A
",
$gen_arch
, "
-DLLAMA_AVX
=
off
", "
-DLLAMA_AVX2
=
off
", "
-DLLAMA_AVX512
=
off
", "
-DLLAMA_FMA
=
off
", "
-DLLAMA_F16C
=
off
") +
$
script
:
cmakeDefs
$
script
:
buildDir
="
..
/build/windows/
${script:ARCH}
/cpu
"
$
script
:
buildDir
="
..
/build/windows/
${script:ARCH}
/cpu
"
$
script
:
distDir
="
$
script
:
DIST_BASE
\cpu
"
$
script
:
distDir
="
$
script
:
DIST_BASE
\cpu
"
write-host "
Building
LCD
CPU
"
write-host "
Building
LCD
CPU
"
...
@@ -349,11 +349,15 @@ if ($($args.count) -eq 0) {
...
@@ -349,11 +349,15 @@ if ($($args.count) -eq 0) {
git_module_setup
git_module_setup
apply_patches
apply_patches
build_static
build_static
build_cpu
if (
$
script
:
ARCH
-eq "
arm
64
") {
build_cpu("
ARM
64
")
} else { # amd64
build_cpu("
x
64
")
build_cpu_avx
build_cpu_avx
build_cpu_avx2
build_cpu_avx2
build_cuda
build_cuda
build_rocm
build_rocm
}
cleanup
cleanup
write-host "
`ngo
generate
completed.
LLM
runners:
$(get-childitem
-path
$
script
:
DIST_BASE
)
"
write-host "
`ngo
generate
completed.
LLM
runners:
$(get-childitem
-path
$
script
:
DIST_BASE
)
"
...
...
llm/llm.go
View file @
b03408de
...
@@ -4,6 +4,7 @@ package llm
...
@@ -4,6 +4,7 @@ package llm
// #cgo darwin,arm64 LDFLAGS: ${SRCDIR}/build/darwin/arm64_static/libllama.a -lstdc++
// #cgo darwin,arm64 LDFLAGS: ${SRCDIR}/build/darwin/arm64_static/libllama.a -lstdc++
// #cgo darwin,amd64 LDFLAGS: ${SRCDIR}/build/darwin/x86_64_static/libllama.a -lstdc++
// #cgo darwin,amd64 LDFLAGS: ${SRCDIR}/build/darwin/x86_64_static/libllama.a -lstdc++
// #cgo windows,amd64 LDFLAGS: ${SRCDIR}/build/windows/amd64_static/libllama.a -static -lstdc++
// #cgo windows,amd64 LDFLAGS: ${SRCDIR}/build/windows/amd64_static/libllama.a -static -lstdc++
// #cgo windows,arm64 LDFLAGS: ${SRCDIR}/build/windows/arm64_static/libllama.a -static -lstdc++
// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/build/linux/x86_64_static/libllama.a -lstdc++
// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/build/linux/x86_64_static/libllama.a -lstdc++
// #cgo linux,arm64 LDFLAGS: ${SRCDIR}/build/linux/arm64_static/libllama.a -lstdc++
// #cgo linux,arm64 LDFLAGS: ${SRCDIR}/build/linux/arm64_static/libllama.a -lstdc++
// #include <stdlib.h>
// #include <stdlib.h>
...
...
scripts/build_windows.ps1
View file @
b03408de
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
$Error
ActionPreference
=
"Stop"
$Error
ActionPreference
=
"Stop"
function
checkEnv
()
{
function
checkEnv
()
{
$
script
:
TARGET_ARCH
=
$
Env
:
PROCESSOR_ARCHITECTURE
.
ToLower
()
Write-host
"Building for
${script:TARGET_ARCH}
"
write-host
"Locating required tools and paths"
write-host
"Locating required tools and paths"
$
script
:
SRC_DIR
=
$PWD
$
script
:
SRC_DIR
=
$PWD
if
(
!
$
env
:
VCToolsRedistDir
)
{
if
(
!
$
env
:
VCToolsRedistDir
)
{
...
@@ -30,7 +32,7 @@ function checkEnv() {
...
@@ -30,7 +32,7 @@ function checkEnv() {
$
script
:
INNO_SETUP_DIR
=
(
get-item
"C:\Program Files*\Inno Setup*\"
)[
0
]
$
script
:
INNO_SETUP_DIR
=
(
get-item
"C:\Program Files*\Inno Setup*\"
)[
0
]
$
script
:
DEPS_DIR
=
"
${script:SRC_DIR}
\dist\windows-
amd64
"
$
script
:
DEPS_DIR
=
"
${script:SRC_DIR}
\dist\windows-
${script:TARGET_ARCH}
"
$
env
:
CGO_ENABLED
=
"1"
$
env
:
CGO_ENABLED
=
"1"
echo
"Checking version"
echo
"Checking version"
if
(
!
$
env
:
VERSION
)
{
if
(
!
$
env
:
VERSION
)
{
...
@@ -81,8 +83,8 @@ function buildOllama() {
...
@@ -81,8 +83,8 @@ function buildOllama() {
/csp
"Google Cloud KMS Provider"
/kc
${env:KEY_CONTAINER}
ollama.exe
/csp
"Google Cloud KMS Provider"
/kc
${env:KEY_CONTAINER}
ollama.exe
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
}
}
New-Item
-ItemType
Directory
-Path
.
\dist\windows-
amd64
\
-Force
New-Item
-ItemType
Directory
-Path
.
\dist\windows-
${script:TARGET_ARCH}
\
-Force
cp
.
\ollama.exe
.
\dist\windows-
amd64
\
cp
.
\ollama.exe
.
\dist\windows-
${script:TARGET_ARCH}
\
}
}
function
buildApp
()
{
function
buildApp
()
{
...
@@ -127,16 +129,16 @@ function buildInstaller() {
...
@@ -127,16 +129,16 @@ function buildInstaller() {
cd
"
${script:SRC_DIR}
\app"
cd
"
${script:SRC_DIR}
\app"
$
env
:
PKG_VERSION
=
$
script
:
PKG_VERSION
$
env
:
PKG_VERSION
=
$
script
:
PKG_VERSION
if
(
"
${env:KEY_CONTAINER}
"
)
{
if
(
"
${env:KEY_CONTAINER}
"
)
{
&
"
${script:INNO_SETUP_DIR}
\ISCC.exe"
/SMySignTool
=
"
${script:SignTool}
sign /fd sha256 /t http://timestamp.digicert.com /f
${script:OLLAMA_CERT}
/csp
`$
qGoogle Cloud KMS Provider
`$
q /kc
${env:KEY_CONTAINER}
`$
f"
.
\ollama.iss
&
"
${script:INNO_SETUP_DIR}
\ISCC.exe"
/DARCH
=
$
script
:
TARGET_ARCH
/SMySignTool
=
"
${script:SignTool}
sign /fd sha256 /t http://timestamp.digicert.com /f
${script:OLLAMA_CERT}
/csp
`$
qGoogle Cloud KMS Provider
`$
q /kc
${env:KEY_CONTAINER}
`$
f"
.
\ollama.iss
}
else
{
}
else
{
&
"
${script:INNO_SETUP_DIR}
\ISCC.exe"
.
\ollama.iss
&
"
${script:INNO_SETUP_DIR}
\ISCC.exe"
/DARCH
=
$
script
:
TARGET_ARCH
.
\ollama.iss
}
}
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
}
}
function
distZip
()
{
function
distZip
()
{
write-host
"Generating stand-alone distribution zip file
${script:SRC_DIR}
\dist\ollama-windows-
amd64
.zip"
write-host
"Generating stand-alone distribution zip file
${script:SRC_DIR}
\dist\ollama-windows-
${script:TARGET_ARCH}
.zip"
Compress-Archive
-Path
"
${script:SRC_DIR}
\dist\windows-
amd64
\*"
-DestinationPath
"
${script:SRC_DIR}
\dist\ollama-windows-
amd64
.zip"
-Force
Compress-Archive
-Path
"
${script:SRC_DIR}
\dist\windows-
${script:TARGET_ARCH}
\*"
-DestinationPath
"
${script:SRC_DIR}
\dist\ollama-windows-
${script:TARGET_ARCH}
.zip"
-Force
}
}
try
{
try
{
...
...
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