From 688925aca9a4747098ee331c3ecb702907fbca23 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 27 Feb 2025 09:02:25 -0800 Subject: [PATCH] Windows ARM build (#9120) * Windows ARM build Skip cmake, and note it's unused in the developer docs. * Win: only check for ninja when we need it On windows ARM, the cim lookup fails, but we don't need ninja anyway. --- docs/development.md | 2 +- scripts/build_windows.ps1 | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/development.md b/docs/development.md index 6e68c9eb9..eb67dbfaf 100644 --- a/docs/development.md +++ b/docs/development.md @@ -69,7 +69,7 @@ go run . serve ## Windows (ARM) -Windows ARM does not support additional acceleration libraries at this time. +Windows ARM does not support additional acceleration libraries at this time. Do not use cmake, simply `go run` or `go build`. ## Linux diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1 index 312c3db54..62930d7f2 100644 --- a/scripts/build_windows.ps1 +++ b/scripts/build_windows.ps1 @@ -26,9 +26,6 @@ function checkEnv() { $MSVC_INSTALL=(Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs)[0].InstallLocation $env:VCToolsRedistDir=(get-item "${MSVC_INSTALL}\VC\Redist\MSVC\*")[0] } - if (-Not (get-command -ErrorAction silent ninja)) { - $script:NINJA_DIR=(gci -path (Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs)[0].InstallLocation -r -fi ninja.exe) | split-path -parent - } # Locate CUDA versions # Note: this assumes every version found will be built $cudaList=(get-item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v*\bin\" -ea 'silentlycontinue') @@ -83,7 +80,7 @@ function checkEnv() { function buildOllama() { - if ($null -eq ${env:OLLAMA_SKIP_GENERATE}) { + if ($script:ARCH -ne "arm64") { Remove-Item -ea 0 -recurse -force -path "${script:SRC_DIR}\dist\windows-${script:ARCH}" New-Item "${script:SRC_DIR}\dist\windows-${script:ARCH}\lib\ollama\" -ItemType Directory -ea 0 @@ -122,8 +119,9 @@ function buildOllama() { } if ($env:HIP_PATH) { write-host "Building ROCm backend libraries" - if ($null -ne $script:NINJA_DIR) { - $env:PATH="$script:NINJA_DIR;$env:PATH" + if (-Not (get-command -ErrorAction silent ninja)) { + $NINJA_DIR=(gci -path (Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs)[0].InstallLocation -r -fi ninja.exe) | split-path -parent + $env:PATH="$NINJA_DIR;$env:PATH" } $env:HIPCXX="${env:HIP_PATH}\bin\clang++.exe" $env:HIP_PLATFORM="amd" @@ -138,8 +136,6 @@ function buildOllama() { & cmake --install build --component "HIP" --strip if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)} } - } else { - write-host "Skipping generate step with OLLAMA_SKIP_GENERATE set" } write-host "Building ollama CLI" & go build -trimpath -ldflags "-s -w -X=github.com/ollama/ollama/version.Version=$script:VERSION -X=github.com/ollama/ollama/server.mode=release" .