build.yml 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645
  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/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  18. cancel-in-progress: true
  19. # Fine-grant permission
  20. # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
  21. permissions:
  22. contents: write # for creating release
  23. env:
  24. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  25. GGML_NLOOP: 3
  26. GGML_N_THREADS: 1
  27. LLAMA_LOG_COLORS: 1
  28. LLAMA_LOG_PREFIX: 1
  29. LLAMA_LOG_TIMESTAMPS: 1
  30. jobs:
  31. macOS-latest-cmake-arm64:
  32. runs-on: macos-14
  33. steps:
  34. - name: Clone
  35. id: checkout
  36. uses: actions/checkout@v4
  37. with:
  38. fetch-depth: 0
  39. - name: ccache
  40. uses: hendrikmuhs/ccache-action@v1.2.16
  41. with:
  42. key: macOS-latest-cmake-arm64
  43. evict-old-files: 1d
  44. - name: Dependencies
  45. id: depends
  46. continue-on-error: true
  47. run: |
  48. brew update
  49. - name: Build
  50. id: cmake_build
  51. run: |
  52. sysctl -a
  53. cmake -B build \
  54. -DCMAKE_BUILD_RPATH="@loader_path" \
  55. -DLLAMA_FATAL_WARNINGS=ON \
  56. -DLLAMA_CURL=ON \
  57. -DGGML_METAL_USE_BF16=ON \
  58. -DGGML_METAL_EMBED_LIBRARY=ON \
  59. -DGGML_RPC=ON
  60. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  61. - name: Test
  62. id: cmake_test
  63. run: |
  64. cd build
  65. ctest -L 'main|curl' --verbose --timeout 900
  66. - name: Determine tag name
  67. id: tag
  68. shell: bash
  69. run: |
  70. BUILD_NUMBER="$(git rev-list --count HEAD)"
  71. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  72. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  73. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  74. else
  75. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  76. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  77. fi
  78. - name: Pack artifacts
  79. id: pack_artifacts
  80. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  81. run: |
  82. cp LICENSE ./build/bin/
  83. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  84. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  85. - name: Upload artifacts
  86. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  87. uses: actions/upload-artifact@v4
  88. with:
  89. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  90. name: llama-bin-macos-arm64.zip
  91. macOS-latest-cmake-x64:
  92. runs-on: macos-13
  93. steps:
  94. - name: Clone
  95. id: checkout
  96. uses: actions/checkout@v4
  97. with:
  98. fetch-depth: 0
  99. - name: ccache
  100. uses: hendrikmuhs/ccache-action@v1.2.16
  101. with:
  102. key: macOS-latest-cmake-x64
  103. evict-old-files: 1d
  104. - name: Dependencies
  105. id: depends
  106. continue-on-error: true
  107. run: |
  108. brew update
  109. - name: Build
  110. id: cmake_build
  111. run: |
  112. sysctl -a
  113. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  114. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  115. cmake -B build \
  116. -DCMAKE_BUILD_RPATH="@loader_path" \
  117. -DLLAMA_FATAL_WARNINGS=ON \
  118. -DLLAMA_CURL=ON \
  119. -DGGML_METAL=OFF \
  120. -DGGML_RPC=ON
  121. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  122. - name: Test
  123. id: cmake_test
  124. run: |
  125. cd build
  126. ctest -L main --verbose --timeout 900
  127. - name: Determine tag name
  128. id: tag
  129. shell: bash
  130. run: |
  131. BUILD_NUMBER="$(git rev-list --count HEAD)"
  132. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  133. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  134. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  135. else
  136. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  137. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  138. fi
  139. - name: Pack artifacts
  140. id: pack_artifacts
  141. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  142. run: |
  143. cp LICENSE ./build/bin/
  144. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  145. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  146. - name: Upload artifacts
  147. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  148. uses: actions/upload-artifact@v4
  149. with:
  150. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  151. name: llama-bin-macos-x64.zip
  152. ubuntu-cpu-cmake:
  153. runs-on: ubuntu-22.04
  154. steps:
  155. - name: Clone
  156. id: checkout
  157. uses: actions/checkout@v4
  158. with:
  159. fetch-depth: 0
  160. - name: ccache
  161. uses: hendrikmuhs/ccache-action@v1.2.16
  162. with:
  163. key: ubuntu-cpu-cmake
  164. evict-old-files: 1d
  165. - name: Dependencies
  166. id: depends
  167. run: |
  168. sudo apt-get update
  169. sudo apt-get install build-essential libcurl4-openssl-dev
  170. - name: Build
  171. id: cmake_build
  172. run: |
  173. cmake -B build \
  174. -DLLAMA_FATAL_WARNINGS=ON \
  175. -DLLAMA_CURL=ON \
  176. -DGGML_RPC=ON
  177. cmake --build build --config Release -j $(nproc)
  178. - name: Test
  179. id: cmake_test
  180. run: |
  181. cd build
  182. ctest -L 'main|curl' --verbose --timeout 900
  183. - name: Test llama2c conversion
  184. id: llama2c_test
  185. run: |
  186. cd build
  187. echo "Fetch tokenizer"
  188. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  189. echo "Fetch llama2c model"
  190. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  191. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  192. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  193. - name: Determine tag name
  194. id: tag
  195. shell: bash
  196. run: |
  197. BUILD_NUMBER="$(git rev-list --count HEAD)"
  198. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  199. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  200. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  201. else
  202. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  203. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  204. fi
  205. - name: Pack artifacts
  206. id: pack_artifacts
  207. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  208. run: |
  209. cp LICENSE ./build/bin/
  210. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  211. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  212. - name: Upload artifacts
  213. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  214. uses: actions/upload-artifact@v4
  215. with:
  216. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  217. name: llama-bin-ubuntu-x64.zip
  218. ubuntu-latest-cmake-sanitizer:
  219. runs-on: ubuntu-latest
  220. continue-on-error: true
  221. strategy:
  222. matrix:
  223. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  224. build_type: [Debug]
  225. steps:
  226. - name: Clone
  227. id: checkout
  228. uses: actions/checkout@v4
  229. - name: ccache
  230. uses: hendrikmuhs/ccache-action@v1.2.16
  231. with:
  232. key: ubuntu-latest-cmake-sanitizer-${{ matrix.sanitizer }}
  233. evict-old-files: 1d
  234. - name: Dependencies
  235. id: depends
  236. run: |
  237. sudo apt-get update
  238. sudo apt-get install build-essential
  239. - name: Build
  240. id: cmake_build
  241. if: ${{ matrix.sanitizer != 'THREAD' }}
  242. run: |
  243. cmake -B build \
  244. -DLLAMA_FATAL_WARNINGS=ON \
  245. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  246. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  247. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  248. - name: Build (no OpenMP)
  249. id: cmake_build_no_openmp
  250. if: ${{ matrix.sanitizer == 'THREAD' }}
  251. run: |
  252. cmake -B build \
  253. -DLLAMA_FATAL_WARNINGS=ON \
  254. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  255. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  256. -DGGML_OPENMP=OFF
  257. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  258. - name: Test
  259. id: cmake_test
  260. run: |
  261. cd build
  262. ctest -L main --verbose --timeout 900
  263. ubuntu-latest-llguidance:
  264. runs-on: ubuntu-latest
  265. steps:
  266. - name: Clone
  267. id: checkout
  268. uses: actions/checkout@v4
  269. - name: Dependencies
  270. id: depends
  271. run: |
  272. sudo apt-get update
  273. sudo apt-get install build-essential
  274. - name: Build
  275. id: cmake_build
  276. run: |
  277. mkdir build
  278. cd build
  279. cmake .. \
  280. -DLLAMA_FATAL_WARNINGS=ON \
  281. -DLLAMA_LLGUIDANCE=ON
  282. cmake --build . --config Release -j $(nproc)
  283. - name: Test
  284. id: cmake_test
  285. run: |
  286. cd build
  287. ctest -L main --verbose --timeout 900
  288. ubuntu-latest-cmake-rpc:
  289. runs-on: ubuntu-latest
  290. continue-on-error: true
  291. steps:
  292. - name: Clone
  293. id: checkout
  294. uses: actions/checkout@v4
  295. - name: ccache
  296. uses: hendrikmuhs/ccache-action@v1.2.16
  297. with:
  298. key: ubuntu-latest-cmake-rpc
  299. evict-old-files: 1d
  300. - name: Dependencies
  301. id: depends
  302. run: |
  303. sudo apt-get update
  304. sudo apt-get install build-essential
  305. - name: Build
  306. id: cmake_build
  307. run: |
  308. cmake -B build \
  309. -DGGML_RPC=ON
  310. cmake --build build --config Release -j $(nproc)
  311. - name: Test
  312. id: cmake_test
  313. run: |
  314. cd build
  315. ctest -L main --verbose
  316. ubuntu-22-cmake-vulkan:
  317. runs-on: ubuntu-22.04
  318. steps:
  319. - name: Clone
  320. id: checkout
  321. uses: actions/checkout@v4
  322. - name: ccache
  323. uses: hendrikmuhs/ccache-action@v1.2.16
  324. with:
  325. key: ubuntu-22-cmake-vulkan
  326. evict-old-files: 1d
  327. - name: Dependencies
  328. id: depends
  329. run: |
  330. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  331. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  332. sudo apt-get update -y
  333. sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk
  334. - name: Build
  335. id: cmake_build
  336. run: |
  337. cmake -B build \
  338. -DGGML_VULKAN=ON
  339. cmake --build build --config Release -j $(nproc)
  340. - name: Test
  341. id: cmake_test
  342. run: |
  343. cd build
  344. # This is using llvmpipe and runs slower than other backends
  345. ctest -L main --verbose --timeout 1800
  346. ubuntu-22-cmake-hip:
  347. runs-on: ubuntu-22.04
  348. container: rocm/dev-ubuntu-22.04:6.0.2
  349. steps:
  350. - name: Clone
  351. id: checkout
  352. uses: actions/checkout@v4
  353. - name: Dependencies
  354. id: depends
  355. run: |
  356. sudo apt-get update
  357. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  358. - name: ccache
  359. uses: hendrikmuhs/ccache-action@v1.2.16
  360. with:
  361. key: ubuntu-22-cmake-hip
  362. evict-old-files: 1d
  363. - name: Build with native CMake HIP support
  364. id: cmake_build
  365. run: |
  366. cmake -B build -S . \
  367. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
  368. -DGGML_HIP=ON
  369. cmake --build build --config Release -j $(nproc)
  370. - name: Build with legacy HIP support
  371. id: cmake_build_legacy_hip
  372. run: |
  373. cmake -B build2 -S . \
  374. -DCMAKE_C_COMPILER=hipcc \
  375. -DCMAKE_CXX_COMPILER=hipcc \
  376. -DGGML_HIP=ON
  377. cmake --build build2 --config Release -j $(nproc)
  378. ubuntu-22-cmake-musa:
  379. runs-on: ubuntu-22.04
  380. container: mthreads/musa:rc3.1.0-devel-ubuntu22.04
  381. steps:
  382. - name: Clone
  383. id: checkout
  384. uses: actions/checkout@v4
  385. - name: Dependencies
  386. id: depends
  387. run: |
  388. apt-get update
  389. apt-get install -y build-essential git cmake libcurl4-openssl-dev
  390. - name: ccache
  391. uses: hendrikmuhs/ccache-action@v1.2.16
  392. with:
  393. key: ubuntu-22-cmake-musa
  394. evict-old-files: 1d
  395. - name: Build with native CMake MUSA support
  396. id: cmake_build
  397. run: |
  398. cmake -B build -S . \
  399. -DGGML_MUSA=ON
  400. cmake --build build --config Release -j $(nproc)
  401. ubuntu-22-cmake-sycl:
  402. runs-on: ubuntu-22.04
  403. continue-on-error: true
  404. steps:
  405. - uses: actions/checkout@v4
  406. - name: add oneAPI to apt
  407. shell: bash
  408. run: |
  409. cd /tmp
  410. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  411. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  412. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  413. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  414. - name: install oneAPI dpcpp compiler
  415. shell: bash
  416. run: |
  417. sudo apt update
  418. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  419. - name: install oneAPI MKL library
  420. shell: bash
  421. run: |
  422. sudo apt install intel-oneapi-mkl-devel
  423. - name: Clone
  424. id: checkout
  425. uses: actions/checkout@v4
  426. - name: ccache
  427. uses: hendrikmuhs/ccache-action@v1.2.16
  428. with:
  429. key: ubuntu-22-cmake-sycl
  430. evict-old-files: 1d
  431. - name: Build
  432. id: cmake_build
  433. run: |
  434. source /opt/intel/oneapi/setvars.sh
  435. cmake -B build \
  436. -DGGML_SYCL=ON \
  437. -DCMAKE_C_COMPILER=icx \
  438. -DCMAKE_CXX_COMPILER=icpx
  439. cmake --build build --config Release -j $(nproc)
  440. ubuntu-22-cmake-sycl-fp16:
  441. runs-on: ubuntu-22.04
  442. continue-on-error: true
  443. steps:
  444. - uses: actions/checkout@v4
  445. - name: add oneAPI to apt
  446. shell: bash
  447. run: |
  448. cd /tmp
  449. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  450. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  451. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  452. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  453. - name: install oneAPI dpcpp compiler
  454. shell: bash
  455. run: |
  456. sudo apt update
  457. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  458. - name: install oneAPI MKL library
  459. shell: bash
  460. run: |
  461. sudo apt install intel-oneapi-mkl-devel
  462. - name: Clone
  463. id: checkout
  464. uses: actions/checkout@v4
  465. - name: ccache
  466. uses: hendrikmuhs/ccache-action@v1.2.16
  467. with:
  468. key: ubuntu-22-cmake-sycl-fp16
  469. evict-old-files: 1d
  470. - name: Build
  471. id: cmake_build
  472. run: |
  473. source /opt/intel/oneapi/setvars.sh
  474. cmake -B build \
  475. -DGGML_SYCL=ON \
  476. -DCMAKE_C_COMPILER=icx \
  477. -DCMAKE_CXX_COMPILER=icpx \
  478. -DGGML_SYCL_F16=ON
  479. cmake --build build --config Release -j $(nproc)
  480. macOS-latest-cmake-ios:
  481. runs-on: macos-latest
  482. steps:
  483. - name: Clone
  484. id: checkout
  485. uses: actions/checkout@v4
  486. - name: ccache
  487. uses: hendrikmuhs/ccache-action@v1.2.16
  488. with:
  489. key: macOS-latest-cmake-ios
  490. evict-old-files: 1d
  491. - name: Dependencies
  492. id: depends
  493. continue-on-error: true
  494. run: |
  495. brew update
  496. - name: Build
  497. id: cmake_build
  498. run: |
  499. sysctl -a
  500. cmake -B build -G Xcode \
  501. -DGGML_METAL_USE_BF16=ON \
  502. -DGGML_METAL_EMBED_LIBRARY=ON \
  503. -DLLAMA_BUILD_EXAMPLES=OFF \
  504. -DLLAMA_BUILD_TESTS=OFF \
  505. -DLLAMA_BUILD_SERVER=OFF \
  506. -DCMAKE_SYSTEM_NAME=iOS \
  507. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  508. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  509. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  510. macOS-latest-cmake-tvos:
  511. runs-on: macos-latest
  512. steps:
  513. - name: Clone
  514. id: checkout
  515. uses: actions/checkout@v4
  516. - name: ccache
  517. uses: hendrikmuhs/ccache-action@v1.2.16
  518. with:
  519. key: macOS-latest-cmake-tvos
  520. evict-old-files: 1d
  521. - name: Dependencies
  522. id: depends
  523. continue-on-error: true
  524. run: |
  525. brew update
  526. - name: Build
  527. id: cmake_build
  528. run: |
  529. sysctl -a
  530. cmake -B build -G Xcode \
  531. -DGGML_METAL_USE_BF16=ON \
  532. -DGGML_METAL_EMBED_LIBRARY=ON \
  533. -DLLAMA_BUILD_EXAMPLES=OFF \
  534. -DLLAMA_BUILD_TESTS=OFF \
  535. -DLLAMA_BUILD_SERVER=OFF \
  536. -DCMAKE_SYSTEM_NAME=tvOS \
  537. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  538. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  539. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  540. macOS-latest-swift:
  541. runs-on: macos-latest
  542. strategy:
  543. matrix:
  544. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  545. steps:
  546. - name: Clone
  547. id: checkout
  548. uses: actions/checkout@v4
  549. - name: ccache
  550. uses: hendrikmuhs/ccache-action@v1.2.16
  551. with:
  552. key: macOS-latest-swift
  553. evict-old-files: 1d
  554. - name: Dependencies
  555. id: depends
  556. continue-on-error: true
  557. run: |
  558. brew update
  559. - name: Build llama.cpp with CMake
  560. id: cmake_build
  561. run: |
  562. sysctl -a
  563. cmake -B build -G Xcode \
  564. -DGGML_METAL_USE_BF16=ON \
  565. -DGGML_METAL_EMBED_LIBRARY=ON \
  566. -DLLAMA_BUILD_EXAMPLES=OFF \
  567. -DLLAMA_BUILD_TESTS=OFF \
  568. -DLLAMA_BUILD_SERVER=OFF \
  569. -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
  570. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  571. sudo cmake --install build --config Release
  572. - name: xcodebuild for swift package
  573. id: xcodebuild
  574. run: |
  575. xcodebuild -scheme llama-Package -destination "${{ matrix.destination }}"
  576. windows-msys2:
  577. runs-on: windows-latest
  578. strategy:
  579. fail-fast: false
  580. matrix:
  581. include:
  582. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  583. - { sys: CLANG64, env: clang-x86_64, build: Release }
  584. steps:
  585. - name: Clone
  586. uses: actions/checkout@v4
  587. - name: ccache
  588. uses: hendrikmuhs/ccache-action@v1.2.16
  589. with:
  590. key: windows-msys2
  591. variant: sccache
  592. evict-old-files: 1d
  593. - name: Setup ${{ matrix.sys }}
  594. uses: msys2/setup-msys2@v2
  595. with:
  596. update: true
  597. msystem: ${{matrix.sys}}
  598. install: >-
  599. base-devel
  600. git
  601. mingw-w64-${{matrix.env}}-toolchain
  602. mingw-w64-${{matrix.env}}-cmake
  603. mingw-w64-${{matrix.env}}-openblas
  604. - name: Build using CMake
  605. shell: msys2 {0}
  606. run: |
  607. cmake -B build
  608. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  609. - name: Clean after building using CMake
  610. shell: msys2 {0}
  611. run: |
  612. rm -rf build
  613. - name: Build using CMake w/ OpenBLAS
  614. shell: msys2 {0}
  615. run: |
  616. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  617. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  618. windows-latest-cmake:
  619. runs-on: windows-latest
  620. env:
  621. OPENBLAS_VERSION: 0.3.23
  622. SDE_VERSION: 9.33.0-2024-01-07
  623. VULKAN_VERSION: 1.3.261.1
  624. strategy:
  625. matrix:
  626. include:
  627. - build: 'noavx-x64'
  628. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
  629. - build: 'avx2-x64'
  630. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON'
  631. - build: 'avx-x64'
  632. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF'
  633. - build: 'avx512-x64'
  634. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON'
  635. - build: 'openblas-x64'
  636. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  637. - build: 'kompute-x64'
  638. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON'
  639. - build: 'vulkan-x64'
  640. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON'
  641. - build: 'llvm-arm64'
  642. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  643. - build: 'msvc-arm64'
  644. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  645. - build: 'llvm-arm64-opencl-adreno'
  646. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
  647. steps:
  648. - name: Clone
  649. id: checkout
  650. uses: actions/checkout@v4
  651. with:
  652. fetch-depth: 0
  653. - name: ccache
  654. uses: hendrikmuhs/ccache-action@v1.2.16
  655. with:
  656. key: windows-latest-cmake-${{ matrix.build }}
  657. variant: sccache
  658. evict-old-files: 1d
  659. - name: Clone Kompute submodule
  660. id: clone_kompute
  661. if: ${{ matrix.build == 'kompute-x64' }}
  662. run: |
  663. git submodule update --init ggml/src/ggml-kompute/kompute
  664. - name: Download OpenBLAS
  665. id: get_openblas
  666. if: ${{ matrix.build == 'openblas-x64' }}
  667. run: |
  668. 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"
  669. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  670. mkdir $env:RUNNER_TEMP/openblas
  671. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  672. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  673. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  674. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  675. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  676. - name: Install Vulkan SDK
  677. id: get_vulkan
  678. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  679. run: |
  680. 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"
  681. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  682. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  683. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  684. - name: Install Ninja
  685. id: install_ninja
  686. run: |
  687. choco install ninja
  688. - name: Install OpenCL Headers and Libs
  689. id: install_opencl
  690. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  691. run: |
  692. git clone https://github.com/KhronosGroup/OpenCL-Headers
  693. cd OpenCL-Headers
  694. cmake -B build `
  695. -DBUILD_TESTING=OFF `
  696. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  697. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  698. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  699. cmake --build build --target install
  700. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  701. cd OpenCL-ICD-Loader
  702. cmake -B build-arm64-release `
  703. -A arm64 `
  704. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  705. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  706. cmake --build build-arm64-release --target install --config release
  707. - name: Build
  708. id: cmake_build
  709. run: |
  710. cmake -S . -B build ${{ matrix.defines }}
  711. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  712. - name: Add libopenblas.dll
  713. id: add_libopenblas_dll
  714. if: ${{ matrix.build == 'openblas-x64' }}
  715. run: |
  716. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  717. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  718. - name: Check AVX512F support
  719. id: check_avx512f
  720. if: ${{ matrix.build == 'avx512-x64' }}
  721. continue-on-error: true
  722. run: |
  723. cd build
  724. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  725. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  726. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  727. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  728. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  729. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  730. - name: Test
  731. id: cmake_test
  732. # not all machines have native AVX-512
  733. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'llvm-arm64-opencl-adreno' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  734. run: |
  735. cd build
  736. ctest -L main -C Release --verbose --timeout 900
  737. - name: Test (Intel SDE)
  738. id: cmake_test_sde
  739. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  740. run: |
  741. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  742. # for some weird reason windows tar doesn't like sde tar.xz
  743. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  744. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  745. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  746. cd build
  747. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  748. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  749. - name: Determine tag name
  750. id: tag
  751. shell: bash
  752. run: |
  753. BUILD_NUMBER="$(git rev-list --count HEAD)"
  754. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  755. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  756. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  757. else
  758. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  759. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  760. fi
  761. - name: Pack artifacts
  762. id: pack_artifacts
  763. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  764. run: |
  765. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  766. Copy-Item .\examples\run\linenoise.cpp\LICENSE .\build\bin\Release\linenoise.cpp.txt
  767. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  768. - name: Upload artifacts
  769. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  770. uses: actions/upload-artifact@v4
  771. with:
  772. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  773. name: llama-bin-win-${{ matrix.build }}.zip
  774. ubuntu-latest-cmake-cuda:
  775. runs-on: ubuntu-latest
  776. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  777. steps:
  778. - name: Clone
  779. id: checkout
  780. uses: actions/checkout@v4
  781. with:
  782. fetch-depth: 0
  783. - name: Install dependencies
  784. env:
  785. DEBIAN_FRONTEND: noninteractive
  786. run: |
  787. apt update
  788. apt install -y cmake build-essential ninja-build libgomp1 git
  789. - name: ccache
  790. uses: hendrikmuhs/ccache-action@v1.2.16
  791. with:
  792. key: ubuntu-latest-cmake-cuda
  793. evict-old-files: 1d
  794. - name: Build with CMake
  795. run: |
  796. cmake -S . -B build -G Ninja \
  797. -DCMAKE_BUILD_TYPE=Release \
  798. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  799. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  800. -DLLAMA_FATAL_WARNINGS=ON \
  801. -DGGML_NATIVE=OFF \
  802. -DGGML_CUDA=ON
  803. cmake --build build
  804. windows-2019-cmake-cuda:
  805. runs-on: windows-2019
  806. strategy:
  807. matrix:
  808. cuda: ['12.4', '11.7']
  809. build: ['cuda']
  810. steps:
  811. - name: Clone
  812. id: checkout
  813. uses: actions/checkout@v4
  814. with:
  815. fetch-depth: 0
  816. - name: Install ccache
  817. uses: hendrikmuhs/ccache-action@v1.2.16
  818. with:
  819. key: ${{ github.job }}-${{ matrix.cuda }}-${{ matrix.build }}
  820. variant: sccache
  821. evict-old-files: 1d
  822. - name: Install Cuda Toolkit 11.7
  823. if: ${{ matrix.cuda == '11.7' }}
  824. run: |
  825. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  826. choco install unzip -y
  827. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-11.7.99-archive.zip"
  828. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-11.7.99-archive.zip"
  829. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-11.7.99-archive.zip"
  830. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-11.7.4.6-archive.zip"
  831. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-11.7.91-archive.zip"
  832. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-11.7.91-archive.zip"
  833. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-11.7.101-archive.zip"
  834. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-11.7.91-archive.zip"
  835. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  836. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cudart-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  837. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvcc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  838. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvrtc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  839. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libcublas-windows-x86_64-11.7.4.6-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  840. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvtx-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  841. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\visual_studio_integration-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  842. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvprof-windows-x86_64-11.7.101-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  843. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cccl-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  844. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  845. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  846. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  847. echo "CUDA_PATH_V11_7=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  848. - name: Install Cuda Toolkit 12.4
  849. if: ${{ matrix.cuda == '12.4' }}
  850. run: |
  851. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  852. choco install unzip -y
  853. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.4.127-archive.zip"
  854. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.4.131-archive.zip"
  855. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.4.127-archive.zip"
  856. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.5.8-archive.zip"
  857. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.4.127-archive.zip"
  858. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.4.127-archive.zip"
  859. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.4.127-archive.zip"
  860. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.4.127-archive.zip"
  861. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.4.127-archive.zip"
  862. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  863. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cudart-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  864. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvcc-windows-x86_64-12.4.131-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  865. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvrtc-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  866. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libcublas-windows-x86_64-12.4.5.8-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  867. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvtx-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  868. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_profiler_api-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  869. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\visual_studio_integration-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  870. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvprof-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  871. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cccl-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  872. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  873. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  874. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  875. echo "CUDA_PATH_V12_4=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  876. - name: Install Ninja
  877. id: install_ninja
  878. run: |
  879. choco install ninja
  880. - name: Build
  881. id: cmake_build
  882. shell: cmd
  883. run: |
  884. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  885. cmake -S . -B build -G "Ninja Multi-Config" ^
  886. -DLLAMA_BUILD_SERVER=ON ^
  887. -DGGML_NATIVE=OFF ^
  888. -DGGML_CUDA=ON ^
  889. -DGGML_RPC=ON
  890. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  891. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  892. cmake --build build --config Release
  893. - name: Determine tag name
  894. id: tag
  895. shell: bash
  896. run: |
  897. BUILD_NUMBER="$(git rev-list --count HEAD)"
  898. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  899. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  900. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  901. else
  902. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  903. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  904. fi
  905. - name: Pack artifacts
  906. id: pack_artifacts
  907. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  908. run: |
  909. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  910. - name: Upload artifacts
  911. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  912. uses: actions/upload-artifact@v4
  913. with:
  914. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  915. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  916. - name: Copy and pack Cuda runtime
  917. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
  918. run: |
  919. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  920. $dst='.\build\bin\cudart\'
  921. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  922. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  923. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  924. - name: Upload Cuda runtime
  925. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  926. uses: actions/upload-artifact@v4
  927. with:
  928. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  929. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  930. windows-latest-cmake-sycl:
  931. runs-on: windows-latest
  932. defaults:
  933. run:
  934. shell: bash
  935. env:
  936. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b380d914-366b-4b77-a74a-05e3c38b3514/intel-oneapi-base-toolkit-2025.0.0.882_offline.exe
  937. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  938. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  939. steps:
  940. - name: Clone
  941. id: checkout
  942. uses: actions/checkout@v4
  943. with:
  944. fetch-depth: 0
  945. - name: ccache
  946. uses: hendrikmuhs/ccache-action@v1.2.16
  947. with:
  948. key: windows-latest-cmake-sycl
  949. variant: sccache
  950. evict-old-files: 1d
  951. - name: Install
  952. run: |
  953. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  954. - name: Build
  955. id: cmake_build
  956. run: examples/sycl/win-build-sycl.bat
  957. - name: Determine tag name
  958. id: tag
  959. shell: bash
  960. run: |
  961. BUILD_NUMBER="$(git rev-list --count HEAD)"
  962. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  963. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  964. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  965. else
  966. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  967. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  968. fi
  969. - name: Build the release package
  970. id: pack_artifacts
  971. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  972. run: |
  973. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  974. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
  975. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  976. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  977. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
  978. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
  979. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
  980. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
  981. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
  982. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  983. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  984. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  985. cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
  986. cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
  987. echo "cp oneAPI running time dll files to ./build/bin done"
  988. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  989. - name: Upload the release package
  990. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  991. uses: actions/upload-artifact@v4
  992. with:
  993. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  994. name: llama-bin-win-sycl-x64.zip
  995. windows-latest-cmake-hip:
  996. if: ${{ github.event.inputs.create_release != 'true' }}
  997. runs-on: windows-latest
  998. steps:
  999. - name: Clone
  1000. id: checkout
  1001. uses: actions/checkout@v4
  1002. - name: Install
  1003. id: depends
  1004. run: |
  1005. $ErrorActionPreference = "Stop"
  1006. write-host "Downloading AMD HIP SDK Installer"
  1007. Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
  1008. write-host "Installing AMD HIP SDK"
  1009. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1010. write-host "Completed AMD HIP SDK installation"
  1011. - name: Verify ROCm
  1012. id: verify
  1013. run: |
  1014. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1015. - name: Install ccache
  1016. uses: hendrikmuhs/ccache-action@v1.2.16
  1017. with:
  1018. key: ${{ github.job }}
  1019. evict-old-files: 1d
  1020. - name: Build
  1021. id: cmake_build
  1022. run: |
  1023. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1024. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1025. cmake -G "Unix Makefiles" -B build -S . `
  1026. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1027. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1028. -DCMAKE_BUILD_TYPE=Release `
  1029. -DGGML_HIP=ON `
  1030. -DGGML_RPC=ON
  1031. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1032. windows-latest-cmake-hip-release:
  1033. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1034. runs-on: windows-latest
  1035. strategy:
  1036. matrix:
  1037. gpu_target: [gfx1100, gfx1101, gfx1030]
  1038. steps:
  1039. - name: Clone
  1040. id: checkout
  1041. uses: actions/checkout@v4
  1042. with:
  1043. fetch-depth: 0
  1044. - name: ccache
  1045. uses: hendrikmuhs/ccache-action@v1.2.16
  1046. with:
  1047. key: windows-latest-cmake-hip-release
  1048. evict-old-files: 1d
  1049. - name: Install
  1050. id: depends
  1051. run: |
  1052. $ErrorActionPreference = "Stop"
  1053. write-host "Downloading AMD HIP SDK Installer"
  1054. Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
  1055. write-host "Installing AMD HIP SDK"
  1056. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1057. write-host "Completed AMD HIP SDK installation"
  1058. - name: Verify ROCm
  1059. id: verify
  1060. run: |
  1061. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1062. - name: Build
  1063. id: cmake_build
  1064. run: |
  1065. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1066. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1067. cmake -G "Unix Makefiles" -B build -S . `
  1068. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1069. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1070. -DCMAKE_BUILD_TYPE=Release `
  1071. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  1072. -DGGML_HIP=ON `
  1073. -DGGML_RPC=ON
  1074. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1075. md "build\bin\rocblas\library\"
  1076. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  1077. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  1078. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  1079. - name: Determine tag name
  1080. id: tag
  1081. shell: bash
  1082. run: |
  1083. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1084. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1085. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1086. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1087. else
  1088. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1089. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1090. fi
  1091. - name: Pack artifacts
  1092. id: pack_artifacts
  1093. run: |
  1094. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  1095. - name: Upload artifacts
  1096. uses: actions/upload-artifact@v4
  1097. with:
  1098. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1099. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1100. ios-xcode-build:
  1101. runs-on: macos-latest
  1102. steps:
  1103. - name: Checkout code
  1104. uses: actions/checkout@v4
  1105. - name: Build
  1106. id: cmake_build
  1107. run: |
  1108. sysctl -a
  1109. cmake -B build -G Xcode \
  1110. -DGGML_METAL_USE_BF16=ON \
  1111. -DGGML_METAL_EMBED_LIBRARY=ON \
  1112. -DLLAMA_BUILD_EXAMPLES=OFF \
  1113. -DLLAMA_BUILD_TESTS=OFF \
  1114. -DLLAMA_BUILD_SERVER=OFF \
  1115. -DCMAKE_SYSTEM_NAME=iOS \
  1116. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  1117. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  1118. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  1119. sudo cmake --install build --config Release
  1120. - name: xcodebuild for swift package
  1121. id: xcodebuild
  1122. run: |
  1123. xcodebuild -scheme llama-Package -destination 'generic/platform=iOS'
  1124. - name: Build Xcode project
  1125. 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
  1126. android-build:
  1127. runs-on: ubuntu-latest
  1128. steps:
  1129. - name: Clone
  1130. uses: actions/checkout@v4
  1131. - name: ccache
  1132. uses: hendrikmuhs/ccache-action@v1.2.16
  1133. with:
  1134. key: android-build
  1135. evict-old-files: 1d
  1136. - name: Set up JDK
  1137. uses: actions/setup-java@v3
  1138. with:
  1139. java-version: 17
  1140. distribution: zulu
  1141. - name: Setup Android SDK
  1142. uses: android-actions/setup-android@v3
  1143. with:
  1144. log-accepted-android-sdk-licenses: false
  1145. - name: Build
  1146. run: |
  1147. cd examples/llama.android
  1148. ./gradlew build --no-daemon
  1149. release:
  1150. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1151. runs-on: ubuntu-latest
  1152. needs:
  1153. - ubuntu-cpu-cmake
  1154. - windows-latest-cmake
  1155. - windows-2019-cmake-cuda
  1156. - windows-latest-cmake-hip-release
  1157. - macOS-latest-cmake-arm64
  1158. - macOS-latest-cmake-x64
  1159. steps:
  1160. - name: Clone
  1161. id: checkout
  1162. uses: actions/checkout@v4
  1163. with:
  1164. fetch-depth: 0
  1165. - name: ccache
  1166. uses: hendrikmuhs/ccache-action@v1.2.16
  1167. with:
  1168. key: release
  1169. evict-old-files: 1d
  1170. - name: Determine tag name
  1171. id: tag
  1172. shell: bash
  1173. run: |
  1174. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1175. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1176. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1177. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1178. else
  1179. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1180. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1181. fi
  1182. - name: Download artifacts
  1183. id: download-artifact
  1184. uses: actions/download-artifact@v4
  1185. with:
  1186. path: ./artifact
  1187. - name: Move artifacts
  1188. id: move_artifacts
  1189. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  1190. - name: Create release
  1191. id: create_release
  1192. uses: ggml-org/action-create-release@v1
  1193. env:
  1194. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1195. with:
  1196. tag_name: ${{ steps.tag.outputs.name }}
  1197. - name: Upload release
  1198. id: upload_release
  1199. uses: actions/github-script@v3
  1200. with:
  1201. github-token: ${{secrets.GITHUB_TOKEN}}
  1202. script: |
  1203. const path = require('path');
  1204. const fs = require('fs');
  1205. const release_id = '${{ steps.create_release.outputs.id }}';
  1206. for (let file of await fs.readdirSync('./artifact/release')) {
  1207. if (path.extname(file) === '.zip') {
  1208. console.log('uploadReleaseAsset', file);
  1209. await github.repos.uploadReleaseAsset({
  1210. owner: context.repo.owner,
  1211. repo: context.repo.repo,
  1212. release_id: release_id,
  1213. name: file,
  1214. data: await fs.readFileSync(`./artifact/release/${file}`)
  1215. });
  1216. }
  1217. }
  1218. # ubuntu-latest-gcc:
  1219. # runs-on: ubuntu-latest
  1220. #
  1221. # strategy:
  1222. # matrix:
  1223. # build: [Debug, Release]
  1224. #
  1225. # steps:
  1226. # - name: Clone
  1227. # uses: actions/checkout@v4
  1228. #
  1229. # - name: Dependencies
  1230. # run: |
  1231. # sudo apt-get update
  1232. # sudo apt-get install build-essential
  1233. # sudo apt-get install cmake
  1234. #
  1235. # - name: Configure
  1236. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1237. #
  1238. # - name: Build
  1239. # run: |
  1240. # make
  1241. #
  1242. # ubuntu-latest-clang:
  1243. # runs-on: ubuntu-latest
  1244. #
  1245. # strategy:
  1246. # matrix:
  1247. # build: [Debug, Release]
  1248. #
  1249. # steps:
  1250. # - name: Clone
  1251. # uses: actions/checkout@v4
  1252. #
  1253. # - name: Dependencies
  1254. # run: |
  1255. # sudo apt-get update
  1256. # sudo apt-get install build-essential
  1257. # sudo apt-get install cmake
  1258. #
  1259. # - name: Configure
  1260. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1261. #
  1262. # - name: Build
  1263. # run: |
  1264. # make
  1265. #
  1266. # ubuntu-latest-gcc-sanitized:
  1267. # runs-on: ubuntu-latest
  1268. #
  1269. # strategy:
  1270. # matrix:
  1271. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1272. #
  1273. # steps:
  1274. # - name: Clone
  1275. # uses: actions/checkout@v4
  1276. #
  1277. # - name: Dependencies
  1278. # run: |
  1279. # sudo apt-get update
  1280. # sudo apt-get install build-essential
  1281. # sudo apt-get install cmake
  1282. #
  1283. # - name: Configure
  1284. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1285. #
  1286. # - name: Build
  1287. # run: |
  1288. # make
  1289. #
  1290. # windows:
  1291. # runs-on: windows-latest
  1292. #
  1293. # strategy:
  1294. # matrix:
  1295. # build: [Release]
  1296. # arch: [Win32, x64]
  1297. # include:
  1298. # - arch: Win32
  1299. # s2arc: x86
  1300. # - arch: x64
  1301. # s2arc: x64
  1302. #
  1303. # steps:
  1304. # - name: Clone
  1305. # uses: actions/checkout@v4
  1306. #
  1307. # - name: Add msbuild to PATH
  1308. # uses: microsoft/setup-msbuild@v1
  1309. #
  1310. # - name: Configure
  1311. # run: >
  1312. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1313. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1314. #
  1315. # - name: Build
  1316. # run: |
  1317. # cd ./build
  1318. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1319. #
  1320. # - name: Upload binaries
  1321. # uses: actions/upload-artifact@v4
  1322. # with:
  1323. # name: llama-bin-${{ matrix.arch }}
  1324. # path: build/bin/${{ matrix.build }}
  1325. #
  1326. # windows-blas:
  1327. # runs-on: windows-latest
  1328. #
  1329. # strategy:
  1330. # matrix:
  1331. # build: [Release]
  1332. # arch: [Win32, x64]
  1333. # blas: [ON]
  1334. # include:
  1335. # - arch: Win32
  1336. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1337. # s2arc: x86
  1338. # - arch: x64
  1339. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1340. # s2arc: x64
  1341. #
  1342. # steps:
  1343. # - name: Clone
  1344. # uses: actions/checkout@v4
  1345. #
  1346. # - name: Add msbuild to PATH
  1347. # uses: microsoft/setup-msbuild@v1
  1348. #
  1349. # - name: Fetch OpenBLAS
  1350. # if: matrix.blas == 'ON'
  1351. # run: |
  1352. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1353. # 7z x blas.zip -oblas -y
  1354. # copy blas/include/cblas.h .
  1355. # copy blas/include/openblas_config.h .
  1356. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1357. #
  1358. # - name: Configure
  1359. # run: >
  1360. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1361. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1362. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1363. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1364. #
  1365. # - name: Build
  1366. # run: |
  1367. # cd ./build
  1368. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1369. #
  1370. # - name: Copy libopenblas.dll
  1371. # if: matrix.blas == 'ON'
  1372. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1373. #
  1374. # - name: Upload binaries
  1375. # if: matrix.blas == 'ON'
  1376. # uses: actions/upload-artifact@v4
  1377. # with:
  1378. # name: llama-blas-bin-${{ matrix.arch }}
  1379. # path: build/bin/${{ matrix.build }}
  1380. #
  1381. # emscripten:
  1382. # runs-on: ubuntu-latest
  1383. #
  1384. # strategy:
  1385. # matrix:
  1386. # build: [Release]
  1387. #
  1388. # steps:
  1389. # - name: Clone
  1390. # uses: actions/checkout@v4
  1391. #
  1392. # - name: Dependencies
  1393. # run: |
  1394. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1395. # tar -xvf master.tar.gz
  1396. # emsdk-master/emsdk update
  1397. # emsdk-master/emsdk install latest
  1398. # emsdk-master/emsdk activate latest
  1399. #
  1400. # - name: Configure
  1401. # run: echo "tmp"
  1402. #
  1403. # - name: Build
  1404. # run: |
  1405. # pushd emsdk-master
  1406. # source ./emsdk_env.sh
  1407. # popd
  1408. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1409. # make
  1410. openEuler-latest-cmake-cann:
  1411. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  1412. defaults:
  1413. run:
  1414. shell: bash -el {0}
  1415. runs-on: ubuntu-24.04-arm
  1416. strategy:
  1417. matrix:
  1418. cann:
  1419. - '8.0.rc3.beta1-910b-openeuler22.03-py3.10'
  1420. device:
  1421. - 'ascend910b3'
  1422. build:
  1423. - 'Release'
  1424. container: ascendai/cann:${{ matrix.cann }}
  1425. steps:
  1426. - name: Checkout
  1427. uses: actions/checkout@v4
  1428. - name: Dependencies
  1429. run: |
  1430. yum update -y
  1431. yum install -y git gcc gcc-c++ make cmake
  1432. - name: Build
  1433. run: |
  1434. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  1435. cmake -S . -B build \
  1436. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  1437. -DGGML_CANN=on \
  1438. -DSOC_TYPE=${{ matrix.device }}
  1439. cmake --build build -j $(nproc)