build.yml 28 KB

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