build.yml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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. strategy:
  281. matrix:
  282. include:
  283. - build: 'noavx'
  284. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  285. - build: 'avx2'
  286. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  287. - build: 'avx'
  288. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  289. - build: 'avx512'
  290. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  291. - build: 'clblast'
  292. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CLBLAST=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/clblast"'
  293. - build: 'openblas'
  294. 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"'
  295. steps:
  296. - name: Clone
  297. id: checkout
  298. uses: actions/checkout@v3
  299. with:
  300. fetch-depth: 0
  301. - name: Download OpenCL SDK
  302. id: get_opencl
  303. if: ${{ matrix.build == 'clblast' }}
  304. run: |
  305. 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"
  306. mkdir $env:RUNNER_TEMP/opencl
  307. tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl
  308. - name: Download CLBlast
  309. id: get_clblast
  310. if: ${{ matrix.build == 'clblast' }}
  311. run: |
  312. 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"
  313. curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE"
  314. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z
  315. rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast
  316. foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) {
  317. $txt = Get-Content -Path $f -Raw
  318. $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8
  319. }
  320. - name: Download OpenBLAS
  321. id: get_openblas
  322. if: ${{ matrix.build == 'openblas' }}
  323. run: |
  324. 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"
  325. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  326. mkdir $env:RUNNER_TEMP/openblas
  327. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  328. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  329. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  330. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  331. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  332. - name: Build
  333. id: cmake_build
  334. run: |
  335. mkdir build
  336. cd build
  337. cmake .. ${{ matrix.defines }}
  338. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  339. - name: Add clblast.dll
  340. id: add_clblast_dll
  341. if: ${{ matrix.build == 'clblast' }}
  342. run: |
  343. cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release
  344. cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt
  345. - name: Add libopenblas.dll
  346. id: add_libopenblas_dll
  347. if: ${{ matrix.build == 'openblas' }}
  348. run: |
  349. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  350. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  351. - name: Check AVX512F support
  352. id: check_avx512f
  353. if: ${{ matrix.build == 'avx512' }}
  354. continue-on-error: true
  355. run: |
  356. cd build
  357. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  358. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  359. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  360. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  361. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  362. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  363. - name: Test
  364. id: cmake_test
  365. if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # not all machines have native AVX-512
  366. run: |
  367. cd build
  368. ctest -L main -C Release --verbose --timeout 900
  369. - name: Test (Intel SDE)
  370. id: cmake_test_sde
  371. if: ${{ matrix.build == 'avx512' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  372. run: |
  373. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  374. # for some weird reason windows tar doesn't like sde tar.xz
  375. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  376. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  377. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  378. cd build
  379. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  380. - name: Determine tag name
  381. id: tag
  382. shell: bash
  383. run: |
  384. BUILD_NUMBER="$(git rev-list --count HEAD)"
  385. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  386. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  387. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  388. else
  389. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  390. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  391. fi
  392. - name: Pack artifacts
  393. id: pack_artifacts
  394. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  395. run: |
  396. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  397. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\*
  398. - name: Upload artifacts
  399. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  400. uses: actions/upload-artifact@v3
  401. with:
  402. path: |
  403. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip
  404. windows-latest-cmake-cublas:
  405. runs-on: windows-latest
  406. strategy:
  407. matrix:
  408. cuda: ['12.2.0', '11.7.1']
  409. build: ['cublas']
  410. steps:
  411. - name: Clone
  412. id: checkout
  413. uses: actions/checkout@v3
  414. with:
  415. fetch-depth: 0
  416. - uses: Jimver/cuda-toolkit@v0.2.11
  417. id: cuda-toolkit
  418. with:
  419. cuda: ${{ matrix.cuda }}
  420. method: 'network'
  421. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  422. - name: Build
  423. id: cmake_build
  424. run: |
  425. mkdir build
  426. cd build
  427. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON
  428. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  429. - name: Determine tag name
  430. id: tag
  431. shell: bash
  432. run: |
  433. BUILD_NUMBER="$(git rev-list --count HEAD)"
  434. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  435. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  436. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  437. else
  438. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  439. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  440. fi
  441. - name: Pack artifacts
  442. id: pack_artifacts
  443. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  444. run: |
  445. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  446. - name: Upload artifacts
  447. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  448. uses: actions/upload-artifact@v3
  449. with:
  450. path: |
  451. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  452. - name: Copy and pack Cuda runtime
  453. run: |
  454. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  455. $dst='.\build\bin\cudart\'
  456. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  457. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  458. - name: Upload Cuda runtime
  459. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  460. uses: actions/upload-artifact@v3
  461. with:
  462. path: |
  463. cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  464. ios-xcode-build:
  465. runs-on: macos-latest
  466. steps:
  467. - name: Checkout code
  468. uses: actions/checkout@v3
  469. - name: Build Xcode project
  470. 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
  471. android-build:
  472. runs-on: ubuntu-latest
  473. steps:
  474. - name: Clone
  475. uses: actions/checkout@v3
  476. - name: Set up JDK
  477. uses: actions/setup-java@v3
  478. with:
  479. java-version: 17
  480. distribution: zulu
  481. - name: Setup Android SDK
  482. uses: android-actions/setup-android@v3
  483. with:
  484. log-accepted-android-sdk-licenses: false
  485. - name: Build
  486. run: |
  487. cd examples/llama.android
  488. # Skip armeabi-v7a for now (https://github.com/llvm/llvm-project/issues/65820).
  489. ./gradlew build --no-daemon -Pskip-armeabi-v7a
  490. # freeBSD-latest:
  491. # runs-on: macos-12
  492. # steps:
  493. # - name: Clone
  494. # uses: actions/checkout@v3
  495. #
  496. # - name: Build
  497. # uses: cross-platform-actions/action@v0.19.0
  498. # with:
  499. # operating_system: freebsd
  500. # version: '13.2'
  501. # hypervisor: 'qemu'
  502. # run: |
  503. # sudo pkg update
  504. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 clinfo clover opencl clblast openblas
  505. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  506. release:
  507. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  508. runs-on: ubuntu-latest
  509. needs:
  510. - ubuntu-focal-make
  511. - ubuntu-latest-cmake
  512. - macOS-latest-make
  513. - macOS-latest-cmake
  514. - windows-latest-cmake
  515. - windows-latest-cmake-cublas
  516. steps:
  517. - name: Clone
  518. id: checkout
  519. uses: actions/checkout@v3
  520. with:
  521. fetch-depth: 0
  522. - name: Determine tag name
  523. id: tag
  524. shell: bash
  525. run: |
  526. BUILD_NUMBER="$(git rev-list --count HEAD)"
  527. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  528. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  529. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  530. else
  531. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  532. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  533. fi
  534. - name: Download artifacts
  535. id: download-artifact
  536. uses: actions/download-artifact@v3
  537. - name: Create release
  538. id: create_release
  539. uses: anzz1/action-create-release@v1
  540. env:
  541. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  542. with:
  543. tag_name: ${{ steps.tag.outputs.name }}
  544. - name: Upload release
  545. id: upload_release
  546. uses: actions/github-script@v3
  547. with:
  548. github-token: ${{secrets.GITHUB_TOKEN}}
  549. script: |
  550. const path = require('path');
  551. const fs = require('fs');
  552. const release_id = '${{ steps.create_release.outputs.id }}';
  553. for (let file of await fs.readdirSync('./artifact')) {
  554. if (path.extname(file) === '.zip') {
  555. console.log('uploadReleaseAsset', file);
  556. await github.repos.uploadReleaseAsset({
  557. owner: context.repo.owner,
  558. repo: context.repo.repo,
  559. release_id: release_id,
  560. name: file,
  561. data: await fs.readFileSync(`./artifact/${file}`)
  562. });
  563. }
  564. }
  565. # ubuntu-latest-gcc:
  566. # runs-on: ubuntu-latest
  567. #
  568. # strategy:
  569. # matrix:
  570. # build: [Debug, Release]
  571. #
  572. # steps:
  573. # - name: Clone
  574. # uses: actions/checkout@v3
  575. #
  576. # - name: Dependencies
  577. # run: |
  578. # sudo apt-get update
  579. # sudo apt-get install build-essential
  580. # sudo apt-get install cmake
  581. #
  582. # - name: Configure
  583. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  584. #
  585. # - name: Build
  586. # run: |
  587. # make
  588. #
  589. # ubuntu-latest-clang:
  590. # runs-on: ubuntu-latest
  591. #
  592. # strategy:
  593. # matrix:
  594. # build: [Debug, Release]
  595. #
  596. # steps:
  597. # - name: Clone
  598. # uses: actions/checkout@v3
  599. #
  600. # - name: Dependencies
  601. # run: |
  602. # sudo apt-get update
  603. # sudo apt-get install build-essential
  604. # sudo apt-get install cmake
  605. #
  606. # - name: Configure
  607. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  608. #
  609. # - name: Build
  610. # run: |
  611. # make
  612. #
  613. # ubuntu-latest-gcc-sanitized:
  614. # runs-on: ubuntu-latest
  615. #
  616. # strategy:
  617. # matrix:
  618. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  619. #
  620. # steps:
  621. # - name: Clone
  622. # uses: actions/checkout@v3
  623. #
  624. # - name: Dependencies
  625. # run: |
  626. # sudo apt-get update
  627. # sudo apt-get install build-essential
  628. # sudo apt-get install cmake
  629. #
  630. # - name: Configure
  631. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  632. #
  633. # - name: Build
  634. # run: |
  635. # make
  636. #
  637. # windows:
  638. # runs-on: windows-latest
  639. #
  640. # strategy:
  641. # matrix:
  642. # build: [Release]
  643. # arch: [Win32, x64]
  644. # include:
  645. # - arch: Win32
  646. # s2arc: x86
  647. # - arch: x64
  648. # s2arc: x64
  649. #
  650. # steps:
  651. # - name: Clone
  652. # uses: actions/checkout@v3
  653. #
  654. # - name: Add msbuild to PATH
  655. # uses: microsoft/setup-msbuild@v1
  656. #
  657. # - name: Configure
  658. # run: >
  659. # cmake -S . -B ./build -A ${{ matrix.arch }}
  660. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  661. #
  662. # - name: Build
  663. # run: |
  664. # cd ./build
  665. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  666. #
  667. # - name: Upload binaries
  668. # uses: actions/upload-artifact@v1
  669. # with:
  670. # name: llama-bin-${{ matrix.arch }}
  671. # path: build/bin/${{ matrix.build }}
  672. #
  673. # windows-blas:
  674. # runs-on: windows-latest
  675. #
  676. # strategy:
  677. # matrix:
  678. # build: [Release]
  679. # arch: [Win32, x64]
  680. # blas: [ON]
  681. # include:
  682. # - arch: Win32
  683. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  684. # s2arc: x86
  685. # - arch: x64
  686. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  687. # s2arc: x64
  688. #
  689. # steps:
  690. # - name: Clone
  691. # uses: actions/checkout@v3
  692. #
  693. # - name: Add msbuild to PATH
  694. # uses: microsoft/setup-msbuild@v1
  695. #
  696. # - name: Fetch OpenBLAS
  697. # if: matrix.blas == 'ON'
  698. # run: |
  699. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  700. # 7z x blas.zip -oblas -y
  701. # copy blas/include/cblas.h .
  702. # copy blas/include/openblas_config.h .
  703. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  704. #
  705. # - name: Configure
  706. # run: >
  707. # cmake -S . -B ./build -A ${{ matrix.arch }}
  708. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  709. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  710. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  711. #
  712. # - name: Build
  713. # run: |
  714. # cd ./build
  715. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  716. #
  717. # - name: Copy libopenblas.dll
  718. # if: matrix.blas == 'ON'
  719. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  720. #
  721. # - name: Upload binaries
  722. # if: matrix.blas == 'ON'
  723. # uses: actions/upload-artifact@v1
  724. # with:
  725. # name: llama-blas-bin-${{ matrix.arch }}
  726. # path: build/bin/${{ matrix.build }}
  727. #
  728. # emscripten:
  729. # runs-on: ubuntu-latest
  730. #
  731. # strategy:
  732. # matrix:
  733. # build: [Release]
  734. #
  735. # steps:
  736. # - name: Clone
  737. # uses: actions/checkout@v3
  738. #
  739. # - name: Dependencies
  740. # run: |
  741. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  742. # tar -xvf master.tar.gz
  743. # emsdk-master/emsdk update
  744. # emsdk-master/emsdk install latest
  745. # emsdk-master/emsdk activate latest
  746. #
  747. # - name: Configure
  748. # run: echo "tmp"
  749. #
  750. # - name: Build
  751. # run: |
  752. # pushd emsdk-master
  753. # source ./emsdk_env.sh
  754. # popd
  755. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  756. # make