|
@@ -26,26 +26,15 @@ function amdGPUs {
|
|
|
$GPU_LIST -join ';'
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function init_vars {
|
|
|
- if (!$script:SRC_DIR) {
|
|
|
- $script:SRC_DIR = $(resolve-path "..\..\")
|
|
|
- }
|
|
|
- if (!$script:llamacppDir) {
|
|
|
- $script:llamacppDir = "../llama.cpp"
|
|
|
- }
|
|
|
- if (!$script:cmakeTargets) {
|
|
|
- $script:cmakeTargets = @("ollama_llama_server")
|
|
|
- }
|
|
|
+ $script:SRC_DIR = $(resolve-path "..\..\")
|
|
|
+ $script:llamacppDir = "../llama.cpp"
|
|
|
$script:cmakeDefs = @(
|
|
|
"-DBUILD_SHARED_LIBS=on",
|
|
|
- "-DLLAMA_NATIVE=off",
|
|
|
- "-DLLAMA_OPENMP=off"
|
|
|
+ "-DLLAMA_NATIVE=off"
|
|
|
)
|
|
|
- $script:commonCpuDefs = @("-DCMAKE_POSITION_INDEPENDENT_CODE=on")
|
|
|
- $script:ARCH = $Env:PROCESSOR_ARCHITECTURE.ToLower()
|
|
|
- $script:DIST_BASE = "${script:SRC_DIR}\dist\windows-${script:ARCH}\ollama_runners"
|
|
|
- md "$script:DIST_BASE" -ea 0 > $null
|
|
|
+ $script:cmakeTargets = @("ollama_llama_server")
|
|
|
+ $script:ARCH = "amd64" # arm not yet supported.
|
|
|
if ($env:CGO_CFLAGS -contains "-g") {
|
|
|
$script:cmakeDefs += @("-DCMAKE_VERBOSE_MAKEFILE=on", "-DLLAMA_SERVER_VERBOSE=on", "-DCMAKE_BUILD_TYPE=RelWithDebInfo")
|
|
|
$script:config = "RelWithDebInfo"
|
|
@@ -66,6 +55,7 @@ function init_vars {
|
|
|
} else {
|
|
|
$script:CUDA_LIB_DIR=$env:CUDA_LIB_DIR
|
|
|
}
|
|
|
+ $script:GZIP=(get-command -ea 'silentlycontinue' gzip).path
|
|
|
$script:DUMPBIN=(get-command -ea 'silentlycontinue' dumpbin).path
|
|
|
if ($null -eq $env:CMAKE_CUDA_ARCHITECTURES) {
|
|
|
$script:CMAKE_CUDA_ARCHITECTURES="50;52;61;70;75;80"
|
|
@@ -123,13 +113,8 @@ function build {
|
|
|
& cmake --version
|
|
|
& cmake -S "${script:llamacppDir}" -B $script:buildDir $script:cmakeDefs
|
|
|
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
|
|
|
- if ($cmakeDefs -contains "-G") {
|
|
|
- $extra=@("-j8")
|
|
|
- } 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
|
|
|
+ write-host "building with: cmake --build $script:buildDir --config $script:config $($script:cmakeTargets | ForEach-Object { `"--target`", $_ })"
|
|
|
+ & cmake --build $script:buildDir --config $script:config ($script:cmakeTargets | ForEach-Object { "--target", $_ })
|
|
|
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
|
|
|
# Rearrange output to be consistent between different generators
|
|
|
if ($null -ne ${script:config} -And (test-path -path "${script:buildDir}/bin/${script:config}" ) ) {
|
|
@@ -149,18 +134,21 @@ function sign {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function install {
|
|
|
- write-host "Installing binaries to dist dir ${script:distDir}"
|
|
|
- mkdir ${script:distDir} -ErrorAction SilentlyContinue
|
|
|
+function compress {
|
|
|
+ if ($script:GZIP -eq $null) {
|
|
|
+ write-host "gzip not installed, not compressing files"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ write-host "Compressing binaries..."
|
|
|
$binaries = dir "${script:buildDir}/bin/*.exe"
|
|
|
foreach ($file in $binaries) {
|
|
|
- copy-item -Path $file -Destination ${script:distDir} -Force
|
|
|
+ & "$script:GZIP" --best -f $file
|
|
|
}
|
|
|
|
|
|
- write-host "Installing dlls to dist dir ${script:distDir}"
|
|
|
+ write-host "Compressing dlls..."
|
|
|
$dlls = dir "${script:buildDir}/bin/*.dll"
|
|
|
foreach ($file in $dlls) {
|
|
|
- copy-item -Path $file -Destination ${script:distDir} -Force
|
|
|
+ & "$script:GZIP" --best -f $file
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -181,252 +169,132 @@ function cleanup {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+init_vars
|
|
|
+git_module_setup
|
|
|
+apply_patches
|
|
|
|
|
|
# -DLLAMA_AVX -- 2011 Intel Sandy Bridge & AMD Bulldozer
|
|
|
# -DLLAMA_AVX2 -- 2013 Intel Haswell & 2015 AMD Excavator / 2017 AMD Zen
|
|
|
# -DLLAMA_FMA (FMA3) -- 2013 Intel Haswell & 2012 AMD Piledriver
|
|
|
|
|
|
+$script:commonCpuDefs = @("-DCMAKE_POSITION_INDEPENDENT_CODE=on")
|
|
|
|
|
|
-function build_static() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_STATIC_GENERATE}") -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "static"))) {
|
|
|
- # GCC build for direct linking into the Go binary
|
|
|
- init_vars
|
|
|
- # cmake will silently fallback to msvc compilers if mingw isn't in the path, so detect and fail fast
|
|
|
- # as we need this to be compiled by gcc for golang to be able to link with itx
|
|
|
- write-host "Checking for MinGW..."
|
|
|
- # error action ensures we exit on failure
|
|
|
- get-command gcc
|
|
|
- get-command mingw32-make
|
|
|
- $oldTargets = $script:cmakeTargets
|
|
|
- $script:cmakeTargets = @("llama", "ggml")
|
|
|
- $script:cmakeDefs = @(
|
|
|
- "-G", "MinGW Makefiles"
|
|
|
- "-DCMAKE_C_COMPILER=gcc.exe",
|
|
|
- "-DCMAKE_CXX_COMPILER=g++.exe",
|
|
|
- "-DBUILD_SHARED_LIBS=off",
|
|
|
- "-DLLAMA_NATIVE=off",
|
|
|
- "-DLLAMA_AVX=off",
|
|
|
- "-DLLAMA_AVX2=off",
|
|
|
- "-DLLAMA_AVX512=off",
|
|
|
- "-DLLAMA_F16C=off",
|
|
|
- "-DLLAMA_FMA=off",
|
|
|
- "-DLLAMA_OPENMP=off")
|
|
|
- $script:buildDir="../build/windows/${script:ARCH}_static"
|
|
|
- write-host "Building static library"
|
|
|
- build
|
|
|
- $script:cmakeTargets = $oldTargets
|
|
|
- } else {
|
|
|
- write-host "Skipping CPU generation step as requested"
|
|
|
- }
|
|
|
-}
|
|
|
+if ($null -eq ${env:OLLAMA_SKIP_CPU_GENERATE}) {
|
|
|
|
|
|
-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"))) {
|
|
|
- # remaining llama.cpp builds use MSVC
|
|
|
- init_vars
|
|
|
- $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:distDir="$script:DIST_BASE\cpu"
|
|
|
- write-host "Building LCD CPU"
|
|
|
- build
|
|
|
- sign
|
|
|
- install
|
|
|
- } else {
|
|
|
- write-host "Skipping CPU generation step as requested"
|
|
|
- }
|
|
|
-}
|
|
|
+# GCC build for direct linking into the Go binary
|
|
|
+init_vars
|
|
|
+# cmake will silently fallback to msvc compilers if mingw isn't in the path, so detect and fail fast
|
|
|
+# as we need this to be compiled by gcc for golang to be able to link with itx
|
|
|
+write-host "Checking for MinGW..."
|
|
|
+# error action ensures we exit on failure
|
|
|
+get-command gcc
|
|
|
+get-command mingw32-make
|
|
|
+$script:cmakeTargets = @("llama", "ggml")
|
|
|
+$script:cmakeDefs = @(
|
|
|
+ "-G", "MinGW Makefiles"
|
|
|
+ "-DCMAKE_C_COMPILER=gcc.exe",
|
|
|
+ "-DCMAKE_CXX_COMPILER=g++.exe",
|
|
|
+ "-DBUILD_SHARED_LIBS=off",
|
|
|
+ "-DLLAMA_NATIVE=off",
|
|
|
+ "-DLLAMA_AVX=off",
|
|
|
+ "-DLLAMA_AVX2=off",
|
|
|
+ "-DLLAMA_AVX512=off",
|
|
|
+ "-DLLAMA_F16C=off",
|
|
|
+ "-DLLAMA_FMA=off")
|
|
|
+$script:buildDir="../build/windows/${script:ARCH}_static"
|
|
|
+write-host "Building static library"
|
|
|
+build
|
|
|
+
|
|
|
+# remaining llama.cpp builds use MSVC
|
|
|
+ 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:buildDir="../build/windows/${script:ARCH}/cpu"
|
|
|
+ write-host "Building LCD CPU"
|
|
|
+ build
|
|
|
+ sign
|
|
|
+ compress
|
|
|
|
|
|
-function build_cpu_avx() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx"))) {
|
|
|
- init_vars
|
|
|
- $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs
|
|
|
- $script:buildDir="../build/windows/${script:ARCH}/cpu_avx"
|
|
|
- $script:distDir="$script:DIST_BASE\cpu_avx"
|
|
|
- write-host "Building AVX CPU"
|
|
|
- build
|
|
|
- sign
|
|
|
- install
|
|
|
- } else {
|
|
|
- write-host "Skipping CPU AVX generation step as requested"
|
|
|
- }
|
|
|
-}
|
|
|
+ init_vars
|
|
|
+ $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs
|
|
|
+ $script:buildDir="../build/windows/${script:ARCH}/cpu_avx"
|
|
|
+ write-host "Building AVX CPU"
|
|
|
+ build
|
|
|
+ sign
|
|
|
+ compress
|
|
|
|
|
|
-function build_cpu_avx2() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx2"))) {
|
|
|
- init_vars
|
|
|
- $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=on", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=on", "-DLLAMA_F16C=on") + $script:cmakeDefs
|
|
|
- $script:buildDir="../build/windows/${script:ARCH}/cpu_avx2"
|
|
|
- $script:distDir="$script:DIST_BASE\cpu_avx2"
|
|
|
- write-host "Building AVX2 CPU"
|
|
|
- build
|
|
|
- sign
|
|
|
- install
|
|
|
- } else {
|
|
|
- write-host "Skipping CPU AVX2 generation step as requested"
|
|
|
- }
|
|
|
+ init_vars
|
|
|
+ $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=on", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=on", "-DLLAMA_F16C=on") + $script:cmakeDefs
|
|
|
+ $script:buildDir="../build/windows/${script:ARCH}/cpu_avx2"
|
|
|
+ write-host "Building AVX2 CPU"
|
|
|
+ build
|
|
|
+ sign
|
|
|
+ compress
|
|
|
+} else {
|
|
|
+ write-host "Skipping CPU generation step as requested"
|
|
|
}
|
|
|
|
|
|
-function build_cuda() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_CUDA_GENERATE}") -and ("${script:CUDA_LIB_DIR}")) {
|
|
|
- # Then build cuda as a dynamically loaded library
|
|
|
- $nvcc = "$script:CUDA_LIB_DIR\nvcc.exe"
|
|
|
- $script:CUDA_VERSION=(get-item ($nvcc | split-path | split-path)).Basename
|
|
|
- if ($null -ne $script:CUDA_VERSION) {
|
|
|
- $script:CUDA_VARIANT="_"+$script:CUDA_VERSION
|
|
|
- }
|
|
|
- init_vars
|
|
|
- $script:buildDir="../build/windows/${script:ARCH}/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_FLAGS=-t8",
|
|
|
- "-DCMAKE_CUDA_ARCHITECTURES=${script:CMAKE_CUDA_ARCHITECTURES}"
|
|
|
- )
|
|
|
- if ($null -ne $env:OLLAMA_CUSTOM_CUDA_DEFS) {
|
|
|
- write-host "OLLAMA_CUSTOM_CUDA_DEFS=`"${env:OLLAMA_CUSTOM_CUDA_DEFS}`""
|
|
|
- $script:cmakeDefs +=@("${env:OLLAMA_CUSTOM_CUDA_DEFS}")
|
|
|
- write-host "building custom CUDA GPU"
|
|
|
- }
|
|
|
- build
|
|
|
- sign
|
|
|
- install
|
|
|
-
|
|
|
- rm -ea 0 -recurse -force -path "${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\"
|
|
|
- md "${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\" -ea 0 > $null
|
|
|
- write-host "copying CUDA dependencies to ${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\"
|
|
|
- cp "${script:CUDA_LIB_DIR}\cudart64_*.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\"
|
|
|
- cp "${script:CUDA_LIB_DIR}\cublas64_*.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\"
|
|
|
- cp "${script:CUDA_LIB_DIR}\cublasLt64_*.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\cuda\"
|
|
|
- } else {
|
|
|
- write-host "Skipping CUDA generation step"
|
|
|
+if ($null -ne $script:CUDA_LIB_DIR) {
|
|
|
+ # Then build cuda as a dynamically loaded library
|
|
|
+ $nvcc = "$script:CUDA_LIB_DIR\nvcc.exe"
|
|
|
+ $script:CUDA_VERSION=(get-item ($nvcc | split-path | split-path)).Basename
|
|
|
+ if ($null -ne $script:CUDA_VERSION) {
|
|
|
+ $script:CUDA_VARIANT="_"+$script:CUDA_VERSION
|
|
|
+ }
|
|
|
+ init_vars
|
|
|
+ $script:buildDir="../build/windows/${script:ARCH}/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}")
|
|
|
+ if ($null -ne $env:OLLAMA_CUSTOM_CUDA_DEFS) {
|
|
|
+ write-host "OLLAMA_CUSTOM_CUDA_DEFS=`"${env:OLLAMA_CUSTOM_CUDA_DEFS}`""
|
|
|
+ $script:cmakeDefs +=@("${env:OLLAMA_CUSTOM_CUDA_DEFS}")
|
|
|
+ write-host "building custom CUDA GPU"
|
|
|
}
|
|
|
+ build
|
|
|
+ sign
|
|
|
+ compress
|
|
|
}
|
|
|
|
|
|
-function build_oneapi() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_ONEAPI_GENERATE}") -and ("${env:ONEAPI_ROOT}")) {
|
|
|
- # Get oneAPI version
|
|
|
- $script:ONEAPI_VERSION = icpx --version
|
|
|
- $script:ONEAPI_VERSION = [regex]::Match($script:ONEAPI_VERSION, '(?<=oneAPI DPC\+\+/C\+\+ Compiler )(?<version>\d+\.\d+\.\d+)').Value
|
|
|
- if ($null -ne $script:ONEAPI_VERSION) {
|
|
|
- $script:ONEAPI_VARIANT = "_v" + $script:ONEAPI_VERSION
|
|
|
+if ($null -ne $env:HIP_PATH) {
|
|
|
+ $script:ROCM_VERSION=(get-item $env:HIP_PATH).Basename
|
|
|
+ if ($null -ne $script:ROCM_VERSION) {
|
|
|
+ $script:ROCM_VARIANT="_v"+$script:ROCM_VERSION
|
|
|
}
|
|
|
+
|
|
|
init_vars
|
|
|
- $script:buildDir = "../build/windows/${script:ARCH}/oneapi$script:ONEAPI_VARIANT"
|
|
|
- $script:distDir ="$script:DIST_BASE\oneapi$script:ONEAPI_VARIANT"
|
|
|
+ $script:buildDir="../build/windows/${script:ARCH}/rocm$script:ROCM_VARIANT"
|
|
|
$script:cmakeDefs += @(
|
|
|
- "-G", "MinGW Makefiles",
|
|
|
- "-DLLAMA_SYCL=ON",
|
|
|
- "-DCMAKE_C_COMPILER=icx",
|
|
|
- "-DCMAKE_CXX_COMPILER=icx",
|
|
|
- "-DCMAKE_BUILD_TYPE=Release"
|
|
|
- )
|
|
|
+ "-G", "Ninja",
|
|
|
+ "-DCMAKE_C_COMPILER=clang.exe",
|
|
|
+ "-DCMAKE_CXX_COMPILER=clang++.exe",
|
|
|
+ "-DLLAMA_HIPBLAS=on",
|
|
|
+ "-DHIP_PLATFORM=amd",
|
|
|
+ "-DLLAMA_AVX=on",
|
|
|
+ "-DLLAMA_AVX2=off",
|
|
|
+ "-DCMAKE_POSITION_INDEPENDENT_CODE=on",
|
|
|
+ "-DAMDGPU_TARGETS=$(amdGPUs)",
|
|
|
+ "-DGPU_TARGETS=$(amdGPUs)"
|
|
|
+ )
|
|
|
|
|
|
- Write-Host "Building oneAPI"
|
|
|
+ # Make sure the ROCm binary dir is first in the path
|
|
|
+ $env:PATH="$env:HIP_PATH\bin;$env:PATH"
|
|
|
+
|
|
|
+ # We have to clobber the LIB var from the developer shell for clang to work properly
|
|
|
+ $env:LIB=""
|
|
|
+ if ($null -ne $env:OLLAMA_CUSTOM_ROCM_DEFS) {
|
|
|
+ write-host "OLLAMA_CUSTOM_ROCM_DEFS=`"${env:OLLAMA_CUSTOM_ROCM_DEFS}`""
|
|
|
+ $script:cmakeDefs += @("${env:OLLAMA_CUSTOM_ROCM_DEFS}")
|
|
|
+ write-host "building custom ROCM GPU"
|
|
|
+ }
|
|
|
+ write-host "Building ROCm"
|
|
|
build
|
|
|
# Ninja doesn't prefix with config name
|
|
|
+ ${script:config}=""
|
|
|
if ($null -ne $script:DUMPBIN) {
|
|
|
- & "$script:DUMPBIN" /dependents "${script:buildDir}/bin/ollama_llama_server.exe" | Select-String ".dll"
|
|
|
+ & "$script:DUMPBIN" /dependents "${script:buildDir}/bin/ollama_llama_server.exe" | select-string ".dll"
|
|
|
}
|
|
|
sign
|
|
|
- install
|
|
|
-
|
|
|
- rm -ea 0 -recurse -force -path "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- md "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\" -ea 0 > $null
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\libirngmd.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\libmmd.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\pi_level_zero.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\pi_unified_runtime.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\pi_win_proxy_loader.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\svml_dispmd.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\compiler\latest\bin\sycl7.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\mkl\latest\bin\mkl_core.2.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\mkl\latest\bin\mkl_sycl_blas.4.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- cp "${env:ONEAPI_ROOT}\mkl\latest\bin\mkl_tbb_thread.2.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\oneapi\"
|
|
|
- } else {
|
|
|
- Write-Host "Skipping oneAPI generation step"
|
|
|
- }
|
|
|
+ compress
|
|
|
}
|
|
|
|
|
|
-function build_rocm() {
|
|
|
- if ((-not "${env:OLLAMA_SKIP_ROCM_GENERATE}") -and ("${env:HIP_PATH}")) {
|
|
|
- $script:ROCM_VERSION=(get-item $env:HIP_PATH).Basename
|
|
|
- if ($null -ne $script:ROCM_VERSION) {
|
|
|
- $script:ROCM_VARIANT="_v"+$script:ROCM_VERSION
|
|
|
- }
|
|
|
-
|
|
|
- init_vars
|
|
|
- $script:buildDir="../build/windows/${script:ARCH}/rocm$script:ROCM_VARIANT"
|
|
|
- $script:distDir="$script:DIST_BASE\rocm$script:ROCM_VARIANT"
|
|
|
- $script:cmakeDefs += @(
|
|
|
- "-G", "Ninja",
|
|
|
- "-DCMAKE_C_COMPILER=clang.exe",
|
|
|
- "-DCMAKE_CXX_COMPILER=clang++.exe",
|
|
|
- "-DLLAMA_HIPBLAS=on",
|
|
|
- "-DHIP_PLATFORM=amd",
|
|
|
- "-DLLAMA_AVX=on",
|
|
|
- "-DLLAMA_AVX2=off",
|
|
|
- "-DCMAKE_POSITION_INDEPENDENT_CODE=on",
|
|
|
- "-DAMDGPU_TARGETS=$(amdGPUs)",
|
|
|
- "-DGPU_TARGETS=$(amdGPUs)"
|
|
|
- )
|
|
|
-
|
|
|
- # Make sure the ROCm binary dir is first in the path
|
|
|
- $env:PATH="$env:HIP_PATH\bin;$env:PATH"
|
|
|
-
|
|
|
- # We have to clobber the LIB var from the developer shell for clang to work properly
|
|
|
- $env:LIB=""
|
|
|
- if ($null -ne $env:OLLAMA_CUSTOM_ROCM_DEFS) {
|
|
|
- write-host "OLLAMA_CUSTOM_ROCM_DEFS=`"${env:OLLAMA_CUSTOM_ROCM_DEFS}`""
|
|
|
- $script:cmakeDefs += @("${env:OLLAMA_CUSTOM_ROCM_DEFS}")
|
|
|
- write-host "building custom ROCM GPU"
|
|
|
- }
|
|
|
- write-host "Building ROCm"
|
|
|
- build
|
|
|
- # Ninja doesn't prefix with config name
|
|
|
- ${script:config}=""
|
|
|
- if ($null -ne $script:DUMPBIN) {
|
|
|
- & "$script:DUMPBIN" /dependents "${script:buildDir}/bin/ollama_llama_server.exe" | select-string ".dll"
|
|
|
- }
|
|
|
- sign
|
|
|
- install
|
|
|
-
|
|
|
- # Assumes v5.7, may need adjustments for v6
|
|
|
- rm -ea 0 -recurse -force -path "${script:SRC_DIR}\dist\windows-${script:ARCH}\rocm\"
|
|
|
- md "${script:SRC_DIR}\dist\windows-${script:ARCH}\rocm\rocblas\library\" -ea 0 > $null
|
|
|
- cp "${env:HIP_PATH}\bin\hipblas.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\rocm\"
|
|
|
- cp "${env:HIP_PATH}\bin\rocblas.dll" "${script:SRC_DIR}\dist\windows-${script:ARCH}\rocm\"
|
|
|
- # amdhip64.dll dependency comes from the driver and must be installed on the host to use AMD GPUs
|
|
|
- cp "${env:HIP_PATH}\bin\rocblas\library\*" "${script:SRC_DIR}\dist\windows-${script:ARCH}\rocm\rocblas\library\"
|
|
|
- } else {
|
|
|
- write-host "Skipping ROCm generation step"
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
-init_vars
|
|
|
-if ($($args.count) -eq 0) {
|
|
|
- git_module_setup
|
|
|
- apply_patches
|
|
|
- build_static
|
|
|
- if ($script:ARCH -eq "arm64") {
|
|
|
- build_cpu("ARM64")
|
|
|
- } else { # amd64
|
|
|
- build_cpu("x64")
|
|
|
- build_cpu_avx
|
|
|
- build_cpu_avx2
|
|
|
- build_cuda
|
|
|
- build_oneapi
|
|
|
- build_rocm
|
|
|
- }
|
|
|
-
|
|
|
- cleanup
|
|
|
- write-host "`ngo generate completed. LLM runners: $(get-childitem -path $script:DIST_BASE)"
|
|
|
-} else {
|
|
|
- for ( $i = 0; $i -lt $args.count; $i++ ) {
|
|
|
- write-host "performing $($args[$i])"
|
|
|
- & $($args[$i])
|
|
|
- }
|
|
|
-}
|
|
|
+cleanup
|
|
|
+write-host "`code generation completed. LLM runners: $(get-childitem -path ${script:SRC_DIR}\llm\build\windows\${script:ARCH})"
|