build.yml 27 KB

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