build.yml 62 KB

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