Skip to content

Commit 37f7e40

Browse files
committed
Add initial version
1 parent ad5288b commit 37f7e40

File tree

3 files changed

+70
-17
lines changed

3 files changed

+70
-17
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.0.0] - 2023-06-28
8+
9+
### Added
10+
- OpenBLAS workaround for Windows
11+
- Rebuild script

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Windows llama.cpp
22

3-
Some PowerShell automation to rebuild [llama.cpp](https://github.com/ggerganov/llama.cpp) for a Windows environment.
3+
A PowerShell automation to rebuild [llama.cpp](https://github.com/ggerganov/llama.cpp) for a Windows environment. It automates the following steps:
4+
5+
1. Fetching and extracting a specific release of [OpenBLAS](https://github.com/xianyi/OpenBLAS/releases)
6+
2. Fetching the latest version of [llama.cpp](https://github.com/ggerganov/llama.cpp)
7+
3. Fixing OpenBLAS binding in the `CMakeLists.txt`
8+
4. Rebuilding the binaries with CMake
9+
5. Updating the Python dependencies
10+
11+
## BLAS support
12+
13+
This script currently supports `OpenBLAS` for CPU BLAS acceleration and `cuBLAS` for NVIDIA GPU BLAS acceleration.
414

515
## Installation
616

@@ -11,7 +21,7 @@ Download and install the latest versions:
1121
* [CMake](https://cmake.org/download/)
1222
* [Cuda](https://developer.nvidia.com/cuda-downloads)
1323
* [Git Large File Storage](https://git-lfs.com)
14-
* [Git](https://git-scm.com/download^^)
24+
* [Git](https://git-scm.com/download)
1525
* [Miniconda](https://conda.io/projects/conda/en/stable/user-guide/install)
1626
* [Visual Studio 2022 - Community](https://visualstudio.microsoft.com/downloads/)
1727

@@ -60,10 +70,10 @@ conda init
6070

6171
### 6. Execute the build script
6272

63-
To build llama.cpp binaries for a Windows environment with CUDA support execute the script:
73+
To build llama.cpp binaries for a Windows environment with CUDA BLAS acceleration execute the script:
6474

6575
```PowerShell
66-
./rebuild_llama.cpp.ps1
76+
./rebuild_llama.cpp.ps1 -blasAccelerator "cuBLAS"
6777
```
6878

6979
### 7. Download a large language model
@@ -95,12 +105,10 @@ You can now chat with the model:
95105

96106
### Rebuild llama.cpp
97107

98-
Every time there is a new release of [llama.cpp](https://github.com/ggerganov/llama.cpp) you can simply execute the script to automatically:
108+
Every time there is a new release of [llama.cpp](https://github.com/ggerganov/llama.cpp) you can simply execute the script to automatically rebuild everything:
99109

100-
1. fetch the latest changes
101-
2. rebuild the binaries
102-
3. update the Python dependencies
103-
104-
```PowerShell
105-
./rebuild_llama.cpp.ps1
106-
```
110+
| Command | Description |
111+
| ----------------------------------------------------- | -------------------------- |
112+
| `./rebuild_llama.cpp.ps1` | Without BLAS acceleration |
113+
| `./rebuild_llama.cpp.ps1 -blasAccelerator "OpenBLAS"` | With CPU BLAS acceleration |
114+
| `./rebuild_llama.cpp.ps1 -blasAccelerator "cuBLAS"` | With GPU BLAS acceleration |

rebuild_llama.cpp.ps1

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
#Requires -Version 5.0
2+
3+
<#
4+
.SYNOPSIS
5+
Automatically rebuild llama.cpp for a Windows environment.
6+
7+
.DESCRIPTION
8+
This script automatically rebuilds llama.cpp for a Windows environment.
9+
10+
.PARAMETER blasAccelerator
11+
Specifies the BLAS accelerator, supported values are: "OpenBLAS", "cuBLAS"
12+
13+
.EXAMPLE
14+
.\rebuild_llama.ps1 -blasAccelerator "OpenBLAS"
15+
16+
.EXAMPLE
17+
.\rebuild_llama.ps1 -blasAccelerator "cuBLAS"
18+
#>
19+
20+
Param (
21+
[ValidateSet("OpenBLAS", "cuBLAS")]
22+
[String]
23+
$blasAccelerator
24+
)
25+
126
$openBLASVersion = "0.3.23"
227

328
if (-not(Test-Path -Path "./vendor/OpenBLAS/OpenBLAS-${openBLASVersion}-x64.zip")) {
@@ -48,11 +73,20 @@ New-Item -Path "./vendor/llama.cpp" -Name "build" -ItemType "directory"
4873

4974
Set-Location -Path "./vendor/llama.cpp/build"
5075

51-
cmake `
52-
-DLLAMA_CUBLAS=OFF `
53-
-DLLAMA_BLAS=ON `
54-
-DLLAMA_BLAS_VENDOR=OpenBLAS `
55-
..
76+
switch ($blasAccelerator) {
77+
78+
"OpenBLAS" {
79+
cmake -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS ..
80+
}
81+
82+
"cuBLAS" {
83+
cmake -DLLAMA_CUBLAS=ON ..
84+
}
85+
86+
default {
87+
cmake ..
88+
}
89+
}
5690

5791
cmake --build . --config Release
5892

0 commit comments

Comments
 (0)