build.yml 61 KB

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