-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
53 lines (43 loc) · 1.71 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Use BuildTools 2022 path
$VcVarsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
if (-not (Test-Path $VcVarsPath)) {
Write-Host "Error: Could not find vcvars64.bat at $VcVarsPath" -ForegroundColor Red
exit 1
}
Write-Host "Found BuildTools at: $VcVarsPath" -ForegroundColor Green
Write-Host "Initializing Visual Studio BuildTools environment..." -ForegroundColor Cyan
# Initialize VS environment
$VsVars = cmd /c "`"$VcVarsPath`" && set"
foreach ($VsVar in $VsVars) {
if ($VsVar -match "^([^=]+)=(.*)$") {
$Name = $Matches[1]
$Value = $Matches[2]
Set-Item -Path "env:$Name" -Value $Value
}
}
Write-Host "Building llama.cpp..." -ForegroundColor Cyan
# Make sure we're in the correct directory
$llamaPath = Join-Path $PSScriptRoot "llama.cpp"
Set-Location $llamaPath
Remove-Item -Recurse -Force build -ErrorAction SilentlyContinue
mkdir build
Set-Location build
Write-Host "Running CMake with CUDA support..." -ForegroundColor Cyan
$env:CC = "cl.exe"
$env:CXX = "cl.exe"
# Updated to use GGML_CUDA instead of LLAMA_CUBLAS
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON
if ($LASTEXITCODE -eq 0) {
Write-Host "CMake configuration successful. Building..." -ForegroundColor Green
cmake --build .
} else {
Write-Host "CMake configuration failed!" -ForegroundColor Red
Write-Host "Please ensure CUDA toolkit is installed." -ForegroundColor Yellow
exit 1
}
if ($LASTEXITCODE -eq 0) {
Write-Host "Build completed successfully!" -ForegroundColor Green
Write-Host "You can find the built executables in the 'build' directory." -ForegroundColor Cyan
} else {
Write-Host "Build failed!" -ForegroundColor Red
}