build.yml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  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. windows-latest-cmake-sycl:
  482. runs-on: windows-latest
  483. defaults:
  484. run:
  485. shell: bash
  486. env:
  487. 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
  488. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  489. steps:
  490. - name: Clone
  491. id: checkout
  492. uses: actions/checkout@v3
  493. with:
  494. fetch-depth: 0
  495. - name: Install
  496. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  497. - name: Build
  498. id: cmake_build
  499. run: examples/sycl/win-build-sycl.bat
  500. ios-xcode-build:
  501. runs-on: macos-latest
  502. steps:
  503. - name: Checkout code
  504. uses: actions/checkout@v3
  505. - name: Build Xcode project
  506. 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
  507. android-build:
  508. runs-on: ubuntu-latest
  509. steps:
  510. - name: Clone
  511. uses: actions/checkout@v3
  512. - name: Set up JDK
  513. uses: actions/setup-java@v3
  514. with:
  515. java-version: 17
  516. distribution: zulu
  517. - name: Setup Android SDK
  518. uses: android-actions/setup-android@v3
  519. with:
  520. log-accepted-android-sdk-licenses: false
  521. - name: Build
  522. run: |
  523. cd examples/llama.android
  524. # Skip armeabi-v7a for now (https://github.com/llvm/llvm-project/issues/65820).
  525. ./gradlew build --no-daemon -Pskip-armeabi-v7a
  526. # freeBSD-latest:
  527. # runs-on: macos-12
  528. # steps:
  529. # - name: Clone
  530. # uses: actions/checkout@v3
  531. #
  532. # - name: Build
  533. # uses: cross-platform-actions/action@v0.19.0
  534. # with:
  535. # operating_system: freebsd
  536. # version: '13.2'
  537. # hypervisor: 'qemu'
  538. # run: |
  539. # sudo pkg update
  540. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 clinfo clover opencl clblast openblas
  541. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  542. release:
  543. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  544. runs-on: ubuntu-latest
  545. needs:
  546. - ubuntu-focal-make
  547. - ubuntu-latest-cmake
  548. - macOS-latest-make
  549. - macOS-latest-cmake
  550. - windows-latest-cmake
  551. - windows-latest-cmake-cublas
  552. steps:
  553. - name: Clone
  554. id: checkout
  555. uses: actions/checkout@v3
  556. with:
  557. fetch-depth: 0
  558. - name: Determine tag name
  559. id: tag
  560. shell: bash
  561. run: |
  562. BUILD_NUMBER="$(git rev-list --count HEAD)"
  563. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  564. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  565. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  566. else
  567. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  568. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  569. fi
  570. - name: Download artifacts
  571. id: download-artifact
  572. uses: actions/download-artifact@v3
  573. - name: Create release
  574. id: create_release
  575. uses: anzz1/action-create-release@v1
  576. env:
  577. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  578. with:
  579. tag_name: ${{ steps.tag.outputs.name }}
  580. - name: Upload release
  581. id: upload_release
  582. uses: actions/github-script@v3
  583. with:
  584. github-token: ${{secrets.GITHUB_TOKEN}}
  585. script: |
  586. const path = require('path');
  587. const fs = require('fs');
  588. const release_id = '${{ steps.create_release.outputs.id }}';
  589. for (let file of await fs.readdirSync('./artifact')) {
  590. if (path.extname(file) === '.zip') {
  591. console.log('uploadReleaseAsset', file);
  592. await github.repos.uploadReleaseAsset({
  593. owner: context.repo.owner,
  594. repo: context.repo.repo,
  595. release_id: release_id,
  596. name: file,
  597. data: await fs.readFileSync(`./artifact/${file}`)
  598. });
  599. }
  600. }
  601. # ubuntu-latest-gcc:
  602. # runs-on: ubuntu-latest
  603. #
  604. # strategy:
  605. # matrix:
  606. # build: [Debug, Release]
  607. #
  608. # steps:
  609. # - name: Clone
  610. # uses: actions/checkout@v3
  611. #
  612. # - name: Dependencies
  613. # run: |
  614. # sudo apt-get update
  615. # sudo apt-get install build-essential
  616. # sudo apt-get install cmake
  617. #
  618. # - name: Configure
  619. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  620. #
  621. # - name: Build
  622. # run: |
  623. # make
  624. #
  625. # ubuntu-latest-clang:
  626. # runs-on: ubuntu-latest
  627. #
  628. # strategy:
  629. # matrix:
  630. # build: [Debug, Release]
  631. #
  632. # steps:
  633. # - name: Clone
  634. # uses: actions/checkout@v3
  635. #
  636. # - name: Dependencies
  637. # run: |
  638. # sudo apt-get update
  639. # sudo apt-get install build-essential
  640. # sudo apt-get install cmake
  641. #
  642. # - name: Configure
  643. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  644. #
  645. # - name: Build
  646. # run: |
  647. # make
  648. #
  649. # ubuntu-latest-gcc-sanitized:
  650. # runs-on: ubuntu-latest
  651. #
  652. # strategy:
  653. # matrix:
  654. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  655. #
  656. # steps:
  657. # - name: Clone
  658. # uses: actions/checkout@v3
  659. #
  660. # - name: Dependencies
  661. # run: |
  662. # sudo apt-get update
  663. # sudo apt-get install build-essential
  664. # sudo apt-get install cmake
  665. #
  666. # - name: Configure
  667. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  668. #
  669. # - name: Build
  670. # run: |
  671. # make
  672. #
  673. # windows:
  674. # runs-on: windows-latest
  675. #
  676. # strategy:
  677. # matrix:
  678. # build: [Release]
  679. # arch: [Win32, x64]
  680. # include:
  681. # - arch: Win32
  682. # s2arc: x86
  683. # - arch: x64
  684. # s2arc: x64
  685. #
  686. # steps:
  687. # - name: Clone
  688. # uses: actions/checkout@v3
  689. #
  690. # - name: Add msbuild to PATH
  691. # uses: microsoft/setup-msbuild@v1
  692. #
  693. # - name: Configure
  694. # run: >
  695. # cmake -S . -B ./build -A ${{ matrix.arch }}
  696. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  697. #
  698. # - name: Build
  699. # run: |
  700. # cd ./build
  701. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  702. #
  703. # - name: Upload binaries
  704. # uses: actions/upload-artifact@v1
  705. # with:
  706. # name: llama-bin-${{ matrix.arch }}
  707. # path: build/bin/${{ matrix.build }}
  708. #
  709. # windows-blas:
  710. # runs-on: windows-latest
  711. #
  712. # strategy:
  713. # matrix:
  714. # build: [Release]
  715. # arch: [Win32, x64]
  716. # blas: [ON]
  717. # include:
  718. # - arch: Win32
  719. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  720. # s2arc: x86
  721. # - arch: x64
  722. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  723. # s2arc: x64
  724. #
  725. # steps:
  726. # - name: Clone
  727. # uses: actions/checkout@v3
  728. #
  729. # - name: Add msbuild to PATH
  730. # uses: microsoft/setup-msbuild@v1
  731. #
  732. # - name: Fetch OpenBLAS
  733. # if: matrix.blas == 'ON'
  734. # run: |
  735. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  736. # 7z x blas.zip -oblas -y
  737. # copy blas/include/cblas.h .
  738. # copy blas/include/openblas_config.h .
  739. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  740. #
  741. # - name: Configure
  742. # run: >
  743. # cmake -S . -B ./build -A ${{ matrix.arch }}
  744. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  745. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  746. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  747. #
  748. # - name: Build
  749. # run: |
  750. # cd ./build
  751. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  752. #
  753. # - name: Copy libopenblas.dll
  754. # if: matrix.blas == 'ON'
  755. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  756. #
  757. # - name: Upload binaries
  758. # if: matrix.blas == 'ON'
  759. # uses: actions/upload-artifact@v1
  760. # with:
  761. # name: llama-blas-bin-${{ matrix.arch }}
  762. # path: build/bin/${{ matrix.build }}
  763. #
  764. # emscripten:
  765. # runs-on: ubuntu-latest
  766. #
  767. # strategy:
  768. # matrix:
  769. # build: [Release]
  770. #
  771. # steps:
  772. # - name: Clone
  773. # uses: actions/checkout@v3
  774. #
  775. # - name: Dependencies
  776. # run: |
  777. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  778. # tar -xvf master.tar.gz
  779. # emsdk-master/emsdk update
  780. # emsdk-master/emsdk install latest
  781. # emsdk-master/emsdk activate latest
  782. #
  783. # - name: Configure
  784. # run: echo "tmp"
  785. #
  786. # - name: Build
  787. # run: |
  788. # pushd emsdk-master
  789. # source ./emsdk_env.sh
  790. # popd
  791. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  792. # make