build.yml 25 KB

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