build.yml 59 KB

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