build.yml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. branches:
  11. - master
  12. paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  16. env:
  17. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  18. GGML_NLOOP: 3
  19. GGML_N_THREADS: 1
  20. jobs:
  21. ubuntu-focal-make:
  22. runs-on: ubuntu-20.04
  23. steps:
  24. - name: Clone
  25. id: checkout
  26. uses: actions/checkout@v3
  27. - name: Dependencies
  28. id: depends
  29. run: |
  30. sudo apt-get update
  31. sudo apt-get install build-essential gcc-8
  32. - name: Build
  33. id: make_build
  34. env:
  35. LLAMA_FATAL_WARNINGS: 1
  36. run: |
  37. CC=gcc-8 make -j $(nproc)
  38. - name: Test
  39. id: make_test
  40. run: |
  41. CC=gcc-8 make tests -j $(nproc)
  42. make test -j $(nproc)
  43. ubuntu-latest-cmake:
  44. runs-on: ubuntu-latest
  45. steps:
  46. - name: Clone
  47. id: checkout
  48. uses: actions/checkout@v3
  49. - name: Dependencies
  50. id: depends
  51. run: |
  52. sudo apt-get update
  53. sudo apt-get install build-essential
  54. - name: Build
  55. id: cmake_build
  56. run: |
  57. mkdir build
  58. cd build
  59. cmake .. -DLLAMA_FATAL_WARNINGS=ON
  60. cmake --build . --config Release -j $(nproc)
  61. - name: Test
  62. id: cmake_test
  63. run: |
  64. cd build
  65. ctest -L main --verbose --timeout 900
  66. ubuntu-latest-cmake-sanitizer:
  67. runs-on: ubuntu-latest
  68. continue-on-error: true
  69. strategy:
  70. matrix:
  71. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  72. build_type: [Debug, Release]
  73. steps:
  74. - name: Clone
  75. id: checkout
  76. uses: actions/checkout@v3
  77. - name: Dependencies
  78. id: depends
  79. run: |
  80. sudo apt-get update
  81. sudo apt-get install build-essential
  82. - name: Build
  83. id: cmake_build
  84. run: |
  85. mkdir build
  86. cd build
  87. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  88. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  89. - name: Test
  90. id: cmake_test
  91. run: |
  92. cd build
  93. ctest -L main --verbose --timeout 900
  94. ubuntu-latest-cmake-mpi:
  95. runs-on: ubuntu-latest
  96. continue-on-error: true
  97. strategy:
  98. matrix:
  99. mpi_library: [mpich, libopenmpi-dev]
  100. steps:
  101. - name: Clone
  102. id: checkout
  103. uses: actions/checkout@v3
  104. - name: Dependencies
  105. id: depends
  106. run: |
  107. sudo apt-get update
  108. sudo apt-get install build-essential ${{ matrix.mpi_library }}
  109. - name: Build
  110. id: cmake_build
  111. run: |
  112. mkdir build
  113. cd build
  114. cmake -DLLAMA_MPI=ON ..
  115. cmake --build . --config Release -j $(nproc)
  116. - name: Test
  117. id: cmake_test
  118. run: |
  119. cd build
  120. ctest -L main --verbose
  121. ubuntu-22-cmake-vulkan:
  122. runs-on: ubuntu-22.04
  123. steps:
  124. - name: Clone
  125. id: checkout
  126. uses: actions/checkout@v3
  127. - name: Dependencies
  128. id: depends
  129. run: |
  130. sudo apt-get update
  131. sudo apt-get install build-essential libvulkan-dev
  132. - name: Build
  133. id: cmake_build
  134. run: |
  135. mkdir build
  136. cd build
  137. cmake -DLLAMA_VULKAN=ON ..
  138. cmake --build . --config Release -j $(nproc)
  139. ubuntu-22-cmake-sycl:
  140. runs-on: ubuntu-22.04
  141. continue-on-error: true
  142. steps:
  143. - uses: actions/checkout@v2
  144. - name: add oneAPI to apt
  145. shell: bash
  146. run: |
  147. cd /tmp
  148. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  149. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  150. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  151. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  152. - name: install oneAPI dpcpp compiler
  153. shell: bash
  154. run: |
  155. sudo apt update
  156. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  157. - name: install oneAPI MKL library
  158. shell: bash
  159. run: |
  160. sudo apt install intel-oneapi-mkl-devel
  161. - name: Clone
  162. id: checkout
  163. uses: actions/checkout@v3
  164. - name: Build
  165. id: cmake_build
  166. run: |
  167. source /opt/intel/oneapi/setvars.sh
  168. mkdir build
  169. cd build
  170. cmake -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  171. cmake --build . --config Release -j $(nproc)
  172. ubuntu-22-cmake-sycl-fp16:
  173. runs-on: ubuntu-22.04
  174. continue-on-error: true
  175. steps:
  176. - uses: actions/checkout@v2
  177. - name: add oneAPI to apt
  178. shell: bash
  179. run: |
  180. cd /tmp
  181. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  182. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  183. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  184. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  185. - name: install oneAPI dpcpp compiler
  186. shell: bash
  187. run: |
  188. sudo apt update
  189. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  190. - name: install oneAPI MKL library
  191. shell: bash
  192. run: |
  193. sudo apt install intel-oneapi-mkl-devel
  194. - name: Clone
  195. id: checkout
  196. uses: actions/checkout@v3
  197. - name: Build
  198. id: cmake_build
  199. run: |
  200. source /opt/intel/oneapi/setvars.sh
  201. mkdir build
  202. cd build
  203. cmake -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_SYCL_F16=ON ..
  204. cmake --build . --config Release -j $(nproc)
  205. # TODO: build with LLAMA_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  206. # how to debug it.
  207. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  208. macOS-latest-make:
  209. runs-on: macos-latest
  210. steps:
  211. - name: Clone
  212. id: checkout
  213. uses: actions/checkout@v3
  214. - name: Dependencies
  215. id: depends
  216. continue-on-error: true
  217. run: |
  218. brew update
  219. - name: Build
  220. id: make_build
  221. env:
  222. LLAMA_FATAL_WARNINGS: 1
  223. run: |
  224. LLAMA_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  225. - name: Test
  226. id: make_test
  227. run: |
  228. LLAMA_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  229. LLAMA_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  230. # TODO: build with LLAMA_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  231. # how to debug it.
  232. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  233. # would be great if we fix these
  234. macOS-latest-cmake:
  235. runs-on: macos-latest
  236. steps:
  237. - name: Clone
  238. id: checkout
  239. uses: actions/checkout@v3
  240. - name: Dependencies
  241. id: depends
  242. continue-on-error: true
  243. run: |
  244. brew update
  245. - name: Build
  246. id: cmake_build
  247. run: |
  248. sysctl -a
  249. mkdir build
  250. cd build
  251. cmake -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_METAL=OFF ..
  252. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  253. - name: Test
  254. id: cmake_test
  255. run: |
  256. cd build
  257. ctest -L main --verbose --timeout 900
  258. macOS-latest-cmake-ios:
  259. runs-on: macos-latest
  260. steps:
  261. - name: Clone
  262. id: checkout
  263. uses: actions/checkout@v1
  264. - name: Dependencies
  265. id: depends
  266. continue-on-error: true
  267. run: |
  268. brew update
  269. - name: Build
  270. id: cmake_build
  271. run: |
  272. sysctl -a
  273. mkdir build
  274. cd build
  275. cmake -G Xcode .. \
  276. -DLLAMA_BUILD_EXAMPLES=OFF \
  277. -DLLAMA_BUILD_TESTS=OFF \
  278. -DLLAMA_BUILD_SERVER=OFF \
  279. -DCMAKE_SYSTEM_NAME=iOS \
  280. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  281. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  282. macOS-latest-cmake-tvos:
  283. runs-on: macos-latest
  284. steps:
  285. - name: Clone
  286. id: checkout
  287. uses: actions/checkout@v1
  288. - name: Dependencies
  289. id: depends
  290. continue-on-error: true
  291. run: |
  292. brew update
  293. - name: Build
  294. id: cmake_build
  295. run: |
  296. sysctl -a
  297. mkdir build
  298. cd build
  299. cmake -G Xcode .. \
  300. -DLLAMA_BUILD_EXAMPLES=OFF \
  301. -DLLAMA_BUILD_TESTS=OFF \
  302. -DLLAMA_BUILD_SERVER=OFF \
  303. -DCMAKE_SYSTEM_NAME=tvOS \
  304. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  305. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  306. macOS-latest-swift:
  307. runs-on: macos-latest
  308. strategy:
  309. matrix:
  310. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  311. steps:
  312. - name: Clone
  313. id: checkout
  314. uses: actions/checkout@v1
  315. - name: Dependencies
  316. id: depends
  317. continue-on-error: true
  318. run: |
  319. brew update
  320. - name: xcodebuild for swift package
  321. id: xcodebuild
  322. run: |
  323. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  324. - name: Build Swift Example
  325. id: make_build_swift_example
  326. run: |
  327. make swift
  328. windows-latest-cmake:
  329. runs-on: windows-latest
  330. env:
  331. OPENBLAS_VERSION: 0.3.23
  332. OPENCL_VERSION: 2023.04.17
  333. CLBLAST_VERSION: 1.6.0
  334. SDE_VERSION: 9.33.0-2024-01-07
  335. VULKAN_VERSION: 1.3.261.1
  336. strategy:
  337. matrix:
  338. include:
  339. - build: 'noavx'
  340. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  341. - build: 'avx2'
  342. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  343. - build: 'avx'
  344. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  345. - build: 'avx512'
  346. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  347. - build: 'clblast'
  348. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CLBLAST=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/clblast"'
  349. - build: 'openblas'
  350. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  351. - build: 'kompute'
  352. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  353. - build: 'vulkan'
  354. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  355. steps:
  356. - name: Clone
  357. id: checkout
  358. uses: actions/checkout@v3
  359. with:
  360. fetch-depth: 0
  361. - name: Clone Kompute submodule
  362. id: clone_kompute
  363. if: ${{ matrix.build == 'kompute' }}
  364. run: |
  365. git submodule update --init kompute
  366. - name: Download OpenCL SDK
  367. id: get_opencl
  368. if: ${{ matrix.build == 'clblast' }}
  369. run: |
  370. curl.exe -o $env:RUNNER_TEMP/opencl.zip -L "https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v${env:OPENCL_VERSION}/OpenCL-SDK-v${env:OPENCL_VERSION}-Win-x64.zip"
  371. mkdir $env:RUNNER_TEMP/opencl
  372. tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl
  373. - name: Download CLBlast
  374. id: get_clblast
  375. if: ${{ matrix.build == 'clblast' }}
  376. run: |
  377. curl.exe -o $env:RUNNER_TEMP/clblast.7z -L "https://github.com/CNugteren/CLBlast/releases/download/${env:CLBLAST_VERSION}/CLBlast-${env:CLBLAST_VERSION}-windows-x64.7z"
  378. curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE"
  379. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z
  380. rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast
  381. foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) {
  382. $txt = Get-Content -Path $f -Raw
  383. $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8
  384. }
  385. - name: Download OpenBLAS
  386. id: get_openblas
  387. if: ${{ matrix.build == 'openblas' }}
  388. run: |
  389. curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
  390. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  391. mkdir $env:RUNNER_TEMP/openblas
  392. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  393. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  394. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  395. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  396. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  397. - name: Install Vulkan SDK
  398. id: get_vulkan
  399. if: ${{ matrix.build == 'kompute' || matrix.build == 'vulkan' }}
  400. run: |
  401. curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe"
  402. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  403. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  404. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  405. - name: Build
  406. id: cmake_build
  407. run: |
  408. mkdir build
  409. cd build
  410. cmake .. ${{ matrix.defines }}
  411. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  412. - name: Add clblast.dll
  413. id: add_clblast_dll
  414. if: ${{ matrix.build == 'clblast' }}
  415. run: |
  416. cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release
  417. cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt
  418. - name: Add libopenblas.dll
  419. id: add_libopenblas_dll
  420. if: ${{ matrix.build == 'openblas' }}
  421. run: |
  422. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  423. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  424. - name: Check AVX512F support
  425. id: check_avx512f
  426. if: ${{ matrix.build == 'avx512' }}
  427. continue-on-error: true
  428. run: |
  429. cd build
  430. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  431. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  432. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  433. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  434. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  435. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  436. - name: Test
  437. id: cmake_test
  438. # not all machines have native AVX-512
  439. if: ${{ matrix.build != 'clblast' && matrix.build != 'kompute' && matrix.build != 'vulkan' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }}
  440. run: |
  441. cd build
  442. ctest -L main -C Release --verbose --timeout 900
  443. - name: Test (Intel SDE)
  444. id: cmake_test_sde
  445. if: ${{ matrix.build == 'avx512' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  446. run: |
  447. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  448. # for some weird reason windows tar doesn't like sde tar.xz
  449. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  450. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  451. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  452. cd build
  453. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  454. - name: Determine tag name
  455. id: tag
  456. shell: bash
  457. run: |
  458. BUILD_NUMBER="$(git rev-list --count HEAD)"
  459. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  460. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  461. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  462. else
  463. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  464. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  465. fi
  466. - name: Pack artifacts
  467. id: pack_artifacts
  468. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  469. run: |
  470. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  471. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\*
  472. - name: Upload artifacts
  473. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  474. uses: actions/upload-artifact@v3
  475. with:
  476. path: |
  477. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip
  478. windows-latest-cmake-cublas:
  479. runs-on: windows-latest
  480. strategy:
  481. matrix:
  482. cuda: ['12.2.0', '11.7.1']
  483. build: ['cublas']
  484. steps:
  485. - name: Clone
  486. id: checkout
  487. uses: actions/checkout@v3
  488. with:
  489. fetch-depth: 0
  490. - uses: Jimver/cuda-toolkit@v0.2.11
  491. id: cuda-toolkit
  492. with:
  493. cuda: ${{ matrix.cuda }}
  494. method: 'network'
  495. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  496. - name: Build
  497. id: cmake_build
  498. run: |
  499. mkdir build
  500. cd build
  501. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON
  502. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  503. - name: Determine tag name
  504. id: tag
  505. shell: bash
  506. run: |
  507. BUILD_NUMBER="$(git rev-list --count HEAD)"
  508. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  509. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  510. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  511. else
  512. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  513. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  514. fi
  515. - name: Pack artifacts
  516. id: pack_artifacts
  517. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  518. run: |
  519. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  520. - name: Upload artifacts
  521. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  522. uses: actions/upload-artifact@v3
  523. with:
  524. path: |
  525. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  526. - name: Copy and pack Cuda runtime
  527. run: |
  528. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  529. $dst='.\build\bin\cudart\'
  530. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  531. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  532. - name: Upload Cuda runtime
  533. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  534. uses: actions/upload-artifact@v3
  535. with:
  536. path: |
  537. cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  538. windows-latest-cmake-sycl:
  539. runs-on: windows-latest
  540. defaults:
  541. run:
  542. shell: bash
  543. env:
  544. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/62641e01-1e8d-4ace-91d6-ae03f7f8a71f/w_BaseKit_p_2024.0.0.49563_offline.exe
  545. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  546. steps:
  547. - name: Clone
  548. id: checkout
  549. uses: actions/checkout@v3
  550. with:
  551. fetch-depth: 0
  552. - name: Install
  553. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  554. - name: Build
  555. id: cmake_build
  556. run: examples/sycl/win-build-sycl.bat
  557. ios-xcode-build:
  558. runs-on: macos-latest
  559. steps:
  560. - name: Checkout code
  561. uses: actions/checkout@v3
  562. - name: Build Xcode project
  563. run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
  564. android-build:
  565. runs-on: ubuntu-latest
  566. steps:
  567. - name: Clone
  568. uses: actions/checkout@v3
  569. - name: Set up JDK
  570. uses: actions/setup-java@v3
  571. with:
  572. java-version: 17
  573. distribution: zulu
  574. - name: Setup Android SDK
  575. uses: android-actions/setup-android@v3
  576. with:
  577. log-accepted-android-sdk-licenses: false
  578. - name: Build
  579. run: |
  580. cd examples/llama.android
  581. ./gradlew build --no-daemon
  582. # freeBSD-latest:
  583. # runs-on: macos-12
  584. # steps:
  585. # - name: Clone
  586. # uses: actions/checkout@v3
  587. #
  588. # - name: Build
  589. # uses: cross-platform-actions/action@v0.19.0
  590. # with:
  591. # operating_system: freebsd
  592. # version: '13.2'
  593. # hypervisor: 'qemu'
  594. # run: |
  595. # sudo pkg update
  596. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 clinfo clover opencl clblast openblas
  597. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  598. release:
  599. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  600. runs-on: ubuntu-latest
  601. needs:
  602. - ubuntu-focal-make
  603. - ubuntu-latest-cmake
  604. - macOS-latest-make
  605. - macOS-latest-cmake
  606. - windows-latest-cmake
  607. - windows-latest-cmake-cublas
  608. steps:
  609. - name: Clone
  610. id: checkout
  611. uses: actions/checkout@v3
  612. with:
  613. fetch-depth: 0
  614. - name: Determine tag name
  615. id: tag
  616. shell: bash
  617. run: |
  618. BUILD_NUMBER="$(git rev-list --count HEAD)"
  619. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  620. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  621. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  622. else
  623. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  624. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  625. fi
  626. - name: Download artifacts
  627. id: download-artifact
  628. uses: actions/download-artifact@v3
  629. - name: Create release
  630. id: create_release
  631. uses: anzz1/action-create-release@v1
  632. env:
  633. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  634. with:
  635. tag_name: ${{ steps.tag.outputs.name }}
  636. - name: Upload release
  637. id: upload_release
  638. uses: actions/github-script@v3
  639. with:
  640. github-token: ${{secrets.GITHUB_TOKEN}}
  641. script: |
  642. const path = require('path');
  643. const fs = require('fs');
  644. const release_id = '${{ steps.create_release.outputs.id }}';
  645. for (let file of await fs.readdirSync('./artifact')) {
  646. if (path.extname(file) === '.zip') {
  647. console.log('uploadReleaseAsset', file);
  648. await github.repos.uploadReleaseAsset({
  649. owner: context.repo.owner,
  650. repo: context.repo.repo,
  651. release_id: release_id,
  652. name: file,
  653. data: await fs.readFileSync(`./artifact/${file}`)
  654. });
  655. }
  656. }
  657. # ubuntu-latest-gcc:
  658. # runs-on: ubuntu-latest
  659. #
  660. # strategy:
  661. # matrix:
  662. # build: [Debug, Release]
  663. #
  664. # steps:
  665. # - name: Clone
  666. # uses: actions/checkout@v3
  667. #
  668. # - name: Dependencies
  669. # run: |
  670. # sudo apt-get update
  671. # sudo apt-get install build-essential
  672. # sudo apt-get install cmake
  673. #
  674. # - name: Configure
  675. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  676. #
  677. # - name: Build
  678. # run: |
  679. # make
  680. #
  681. # ubuntu-latest-clang:
  682. # runs-on: ubuntu-latest
  683. #
  684. # strategy:
  685. # matrix:
  686. # build: [Debug, Release]
  687. #
  688. # steps:
  689. # - name: Clone
  690. # uses: actions/checkout@v3
  691. #
  692. # - name: Dependencies
  693. # run: |
  694. # sudo apt-get update
  695. # sudo apt-get install build-essential
  696. # sudo apt-get install cmake
  697. #
  698. # - name: Configure
  699. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  700. #
  701. # - name: Build
  702. # run: |
  703. # make
  704. #
  705. # ubuntu-latest-gcc-sanitized:
  706. # runs-on: ubuntu-latest
  707. #
  708. # strategy:
  709. # matrix:
  710. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  711. #
  712. # steps:
  713. # - name: Clone
  714. # uses: actions/checkout@v3
  715. #
  716. # - name: Dependencies
  717. # run: |
  718. # sudo apt-get update
  719. # sudo apt-get install build-essential
  720. # sudo apt-get install cmake
  721. #
  722. # - name: Configure
  723. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  724. #
  725. # - name: Build
  726. # run: |
  727. # make
  728. #
  729. # windows:
  730. # runs-on: windows-latest
  731. #
  732. # strategy:
  733. # matrix:
  734. # build: [Release]
  735. # arch: [Win32, x64]
  736. # include:
  737. # - arch: Win32
  738. # s2arc: x86
  739. # - arch: x64
  740. # s2arc: x64
  741. #
  742. # steps:
  743. # - name: Clone
  744. # uses: actions/checkout@v3
  745. #
  746. # - name: Add msbuild to PATH
  747. # uses: microsoft/setup-msbuild@v1
  748. #
  749. # - name: Configure
  750. # run: >
  751. # cmake -S . -B ./build -A ${{ matrix.arch }}
  752. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  753. #
  754. # - name: Build
  755. # run: |
  756. # cd ./build
  757. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  758. #
  759. # - name: Upload binaries
  760. # uses: actions/upload-artifact@v1
  761. # with:
  762. # name: llama-bin-${{ matrix.arch }}
  763. # path: build/bin/${{ matrix.build }}
  764. #
  765. # windows-blas:
  766. # runs-on: windows-latest
  767. #
  768. # strategy:
  769. # matrix:
  770. # build: [Release]
  771. # arch: [Win32, x64]
  772. # blas: [ON]
  773. # include:
  774. # - arch: Win32
  775. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  776. # s2arc: x86
  777. # - arch: x64
  778. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  779. # s2arc: x64
  780. #
  781. # steps:
  782. # - name: Clone
  783. # uses: actions/checkout@v3
  784. #
  785. # - name: Add msbuild to PATH
  786. # uses: microsoft/setup-msbuild@v1
  787. #
  788. # - name: Fetch OpenBLAS
  789. # if: matrix.blas == 'ON'
  790. # run: |
  791. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  792. # 7z x blas.zip -oblas -y
  793. # copy blas/include/cblas.h .
  794. # copy blas/include/openblas_config.h .
  795. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  796. #
  797. # - name: Configure
  798. # run: >
  799. # cmake -S . -B ./build -A ${{ matrix.arch }}
  800. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  801. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  802. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  803. #
  804. # - name: Build
  805. # run: |
  806. # cd ./build
  807. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  808. #
  809. # - name: Copy libopenblas.dll
  810. # if: matrix.blas == 'ON'
  811. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  812. #
  813. # - name: Upload binaries
  814. # if: matrix.blas == 'ON'
  815. # uses: actions/upload-artifact@v1
  816. # with:
  817. # name: llama-blas-bin-${{ matrix.arch }}
  818. # path: build/bin/${{ matrix.build }}
  819. #
  820. # emscripten:
  821. # runs-on: ubuntu-latest
  822. #
  823. # strategy:
  824. # matrix:
  825. # build: [Release]
  826. #
  827. # steps:
  828. # - name: Clone
  829. # uses: actions/checkout@v3
  830. #
  831. # - name: Dependencies
  832. # run: |
  833. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  834. # tar -xvf master.tar.gz
  835. # emsdk-master/emsdk update
  836. # emsdk-master/emsdk install latest
  837. # emsdk-master/emsdk activate latest
  838. #
  839. # - name: Configure
  840. # run: echo "tmp"
  841. #
  842. # - name: Build
  843. # run: |
  844. # pushd emsdk-master
  845. # source ./emsdk_env.sh
  846. # popd
  847. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  848. # make