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
0577af98
"...text-generation-inference.git" did not exist on "f512021e77beb9b780c818b30daba58f1329ac11"
Commit
0577af98
authored
Jun 13, 2024
by
Daniel Hiltgen
Browse files
More parallelism on windows generate
Make the build faster
parent
45cacbaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
21 deletions
+51
-21
llm/generate/gen_windows.ps1
llm/generate/gen_windows.ps1
+51
-21
No files found.
llm/generate/gen_windows.ps1
View file @
0577af98
#!powershell
#!powershell
$Error
ActionPreference
=
"Stop"
function
amdGPUs
{
function
amdGPUs
{
if
(
$
env
:
AMDGPU_TARGETS
)
{
if
(
$
env
:
AMDGPU_TARGETS
)
{
return
$
env
:
AMDGPU_TARGETS
return
$
env
:
AMDGPU_TARGETS
...
@@ -85,9 +83,9 @@ function init_vars {
...
@@ -85,9 +83,9 @@ function init_vars {
function
git_module_setup
{
function
git_module_setup
{
# TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
# TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
&
git
submodule
init
&
git
submodule
init
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
if
(
$LASTEXITCODE
-ne
0
)
{
throw
(
$LASTEXITCODE
)}
&
git
submodule
update
--force
"
${script:llamacppDir}
"
&
git
submodule
update
--force
"
${script:llamacppDir}
"
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
if
(
$LASTEXITCODE
-ne
0
)
{
throw
(
$LASTEXITCODE
)}
}
}
function
apply_patches
{
function
apply_patches
{
...
@@ -121,10 +119,15 @@ function build {
...
@@ -121,10 +119,15 @@ function build {
write-host
"generating config with: cmake -S
${script:llamacppDir}
-B
$
script
:
buildDir
$
script
:
cmakeDefs
"
write-host
"generating config with: cmake -S
${script:llamacppDir}
-B
$
script
:
buildDir
$
script
:
cmakeDefs
"
&
cmake
--version
&
cmake
--version
&
cmake
-S
"
${script:llamacppDir}
"
-B
$
script
:
buildDir
$
script
:
cmakeDefs
&
cmake
-S
"
${script:llamacppDir}
"
-B
$
script
:
buildDir
$
script
:
cmakeDefs
if
(
$LASTEXITCODE
-ne
0
)
{
exit
(
$LASTEXITCODE
)}
if
(
$LASTEXITCODE
-ne
0
)
{
throw
(
$LASTEXITCODE
)}
write-host
"building with: cmake --build
$
script
:
buildDir
--config
$
script
:
config
$(
$
script
:
cmakeTargets
|
ForEach-Object
{
`
"--target
`"
,
$_
})"
if
(
$cmakeDefs
-contains
"-G"
)
{
&
cmake
--build
$
script
:
buildDir
--config
$
script
:
config
(
$
script
:
cmakeTargets
|
ForEach-Object
{
"--target"
,
$_
}
)
$extra
=
@(
"-j8"
)
if (
$LASTEXITCODE
-ne 0) { exit(
$LASTEXITCODE
)}
}
else
{
$extra
=
@(
"--"
,
"/p:CL_MPcount=8"
)
}
write-host
"building with: cmake --build
$
script
:
buildDir
--config
$
script
:
config
$(
$
script
:
cmakeTargets
|
ForEach-Object
{
`
"--target
`"
,
$_
})
$extra
"
&
cmake
--build
$
script
:
buildDir
--config
$
script
:
config
(
$
script
:
cmakeTargets
|
ForEach-Object
{
"--target"
,
$_
}
)
$extra
if (
$LASTEXITCODE
-ne 0) { write-host "
cmake
build
exit
status
$LASTEXITCODE
"; throw(
$LASTEXITCODE
)}
# Rearrange output to be consistent between different generators
# Rearrange output to be consistent between different generators
if (
$null
-ne
${script:config}
-And (test-path -path "
${script:buildDir}
/bin/
${script:config}
" ) ) {
if (
$null
-ne
${script:config}
-And (test-path -path "
${script:buildDir}
/bin/
${script:config}
" ) ) {
mv -force "
${script:buildDir}
/bin/
${script:config}
/
*
" "
${script:buildDir}
/bin/
"
mv -force "
${script:buildDir}
/bin/
${script:config}
/
*
" "
${script:buildDir}
/bin/
"
...
@@ -138,7 +141,7 @@ function sign {
...
@@ -138,7 +141,7 @@ function sign {
foreach (
$file
in @(get-childitem "
${script:buildDir}
/bin/
*.
exe
") + @(get-childitem "
${script:buildDir}
/bin/
*.
dll
")){
foreach (
$file
in @(get-childitem "
${script:buildDir}
/bin/
*.
exe
") + @(get-childitem "
${script:buildDir}
/bin/
*.
dll
")){
& "
${script:SignTool}
" sign /v /fd sha256 /t http://timestamp.digicert.com /f "
${script:OLLAMA_CERT}
"
`
& "
${script:SignTool}
" sign /v /fd sha256 /t http://timestamp.digicert.com /f "
${script:OLLAMA_CERT}
"
`
/csp "
Google
Cloud
KMS
Provider
" /kc "
${env:KEY_CONTAINER}
"
$file
/csp "
Google
Cloud
KMS
Provider
" /kc "
${env:KEY_CONTAINER}
"
$file
if (
$LASTEXITCODE
-ne 0) {
exit
(
$LASTEXITCODE
)}
if (
$LASTEXITCODE
-ne 0) {
throw
(
$LASTEXITCODE
)}
}
}
}
}
}
}
...
@@ -213,7 +216,13 @@ function build_static() {
...
@@ -213,7 +216,13 @@ function build_static() {
}
}
}
}
function build_cpu(
$gen_arch
) {
function build_cpu() {
if (
$
script
:
ARCH
-eq "
arm64
") {
$gen_arch
= "
ARM64
"
} else { # amd64
$gen_arch
= "
x64
"
}
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
...
@@ -270,7 +279,15 @@ function build_cuda() {
...
@@ -270,7 +279,15 @@ function build_cuda() {
init_vars
init_vars
$
script
:
buildDir
="
..
/build/windows/
${script:ARCH}
/cuda
$
script
:
CUDA_VARIANT
"
$
script
:
buildDir
="
..
/build/windows/
${script:ARCH}
/cuda
$
script
:
CUDA_VARIANT
"
$
script
:
distDir
="
$
script
:
DIST_BASE
\cuda
$
script
:
CUDA_VARIANT
"
$
script
:
distDir
="
$
script
:
DIST_BASE
\cuda
$
script
:
CUDA_VARIANT
"
$
script
:
cmakeDefs
+= @("
-A
", "
x64
", "
-DLLAMA_CUDA
=
ON
", "
-DLLAMA_AVX
=
on
", "
-DLLAMA_AVX2
=
off
", "
-DCUDAToolkit_INCLUDE_DIR
=
$
script
:
CUDA_INCLUDE_DIR
", "
-DCMAKE_CUDA_ARCHITECTURES
=
${script:CMAKE_CUDA_ARCHITECTURES}
")
$
script
:
cmakeDefs
+= @(
"
-A
", "
x64
",
"
-DLLAMA_CUDA
=
ON
",
"
-DLLAMA_AVX
=
on
",
"
-DLLAMA_AVX2
=
off
",
"
-DCUDAToolkit_INCLUDE_DIR
=
$
script
:
CUDA_INCLUDE_DIR
",
"
-DCMAKE_CUDA_FLAGS
=
-t8
"
"
-DCMAKE_CUDA_ARCHITECTURES
=
${script:CMAKE_CUDA_ARCHITECTURES}
"
)
if (
$null
-ne
$
env
:
OLLAMA_CUSTOM_CUDA_DEFS
) {
if (
$null
-ne
$
env
:
OLLAMA_CUSTOM_CUDA_DEFS
) {
write-host "
OLLAMA_CUSTOM_CUDA_DEFS
=
`
"
${env:OLLAMA_CUSTOM_CUDA_DEFS}
`"
"
write-host "
OLLAMA_CUSTOM_CUDA_DEFS
=
`
"
${env:OLLAMA_CUSTOM_CUDA_DEFS}
`"
"
$
script
:
cmakeDefs
+=
@(
"
${env:OLLAMA_CUSTOM_CUDA_DEFS}
"
)
$
script
:
cmakeDefs
+=
@(
"
${env:OLLAMA_CUSTOM_CUDA_DEFS}
"
)
...
@@ -391,16 +408,29 @@ init_vars
...
@@ -391,16 +408,29 @@ init_vars
if (
$(
$args
.
count
)
-eq 0) {
if (
$(
$args
.
count
)
-eq 0) {
git_module_setup
git_module_setup
apply_patches
apply_patches
build_static
if (
$
script
:
ARCH
-eq "
arm
64
") {
$tasks
= @("
build_static
", "
build_cpu
")
build_cpu("
ARM
64
")
$jobs
= @()
} else { # amd64
if (
$
script
:
ARCH
-ne "
arm
64
") {
build_cpu("
x
64
")
$tasks
+=
$(
"build_cpu_avx"
,
"build_cpu_avx2"
,
"build_cuda"
,
"build_oneapi"
,
"build_rocm"
)
build_cpu_avx
}
build_cpu_avx2
foreach (
$t
in
$tasks
) {
build_cuda
$jobs
+= @(Start-ThreadJob -ThrottleLimit 12 -FilePath .\gen_windows.ps1 -ArgumentList
$t
-Name
$t
)
build_oneapi
}
build_rocm
get-job
foreach (
$job
in
$jobs
) {
write-host "
----
"
$job
.Name output follows
receive-job -wait -job
$job
write-host "
----
"
$job
.Name
$job
.State
write-host ""
if (
$job
.State -contains 'Failed') {
cleanup
write-host "
Terminating
remaining
jobs
(this
takes
a
while
,
you
can
^C
)
"
# TODO find some way to kill the spawned cmake processes faster
remove-job -force -job
$jobs
exit(-1)
}
get-job
}
}
cleanup
cleanup
...
...
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