build.yml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  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. env:
  20. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  21. GGML_NLOOP: 3
  22. GGML_N_THREADS: 1
  23. LLAMA_LOG_COLORS: 1
  24. LLAMA_LOG_PREFIX: 1
  25. LLAMA_LOG_TIMESTAMPS: 1
  26. jobs:
  27. macOS-latest-cmake-arm64:
  28. runs-on: macos-14
  29. steps:
  30. - name: Clone
  31. id: checkout
  32. uses: actions/checkout@v4
  33. with:
  34. fetch-depth: 0
  35. - name: Dependencies
  36. id: depends
  37. continue-on-error: true
  38. run: |
  39. brew update
  40. - name: Build
  41. id: cmake_build
  42. run: |
  43. sysctl -a
  44. mkdir build
  45. cd build
  46. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL_EMBED_LIBRARY=ON -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF ..
  47. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  48. - name: Test
  49. id: cmake_test
  50. run: |
  51. cd build
  52. ctest -L 'main|curl' --verbose --timeout 900
  53. - name: Determine tag name
  54. id: tag
  55. shell: bash
  56. run: |
  57. BUILD_NUMBER="$(git rev-list --count HEAD)"
  58. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  59. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  60. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  61. else
  62. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  63. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  64. fi
  65. - name: Pack artifacts
  66. id: pack_artifacts
  67. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  68. run: |
  69. cp LICENSE ./build/bin/
  70. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  71. - name: Upload artifacts
  72. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  73. uses: actions/upload-artifact@v4
  74. with:
  75. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  76. name: llama-bin-macos-arm64.zip
  77. macOS-latest-cmake-x64:
  78. runs-on: macos-12
  79. steps:
  80. - name: Clone
  81. id: checkout
  82. uses: actions/checkout@v4
  83. with:
  84. fetch-depth: 0
  85. - name: Dependencies
  86. id: depends
  87. continue-on-error: true
  88. run: |
  89. brew update
  90. - name: Build
  91. id: cmake_build
  92. run: |
  93. sysctl -a
  94. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  95. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  96. cmake -B build -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF
  97. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  98. - name: Test
  99. id: cmake_test
  100. run: |
  101. cd build
  102. ctest -L main --verbose --timeout 900
  103. - name: Determine tag name
  104. id: tag
  105. shell: bash
  106. run: |
  107. BUILD_NUMBER="$(git rev-list --count HEAD)"
  108. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  109. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  110. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  111. else
  112. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  113. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  114. fi
  115. - name: Pack artifacts
  116. id: pack_artifacts
  117. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  118. run: |
  119. cp LICENSE ./build/bin/
  120. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  121. - name: Upload artifacts
  122. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  123. uses: actions/upload-artifact@v4
  124. with:
  125. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  126. name: llama-bin-macos-x64.zip
  127. ubuntu-focal-make:
  128. runs-on: ubuntu-20.04
  129. env:
  130. LLAMA_NODE_AVAILABLE: true
  131. LLAMA_PYTHON_AVAILABLE: true
  132. steps:
  133. - name: Clone
  134. id: checkout
  135. uses: actions/checkout@v4
  136. - name: Dependencies
  137. id: depends
  138. run: |
  139. sudo apt-get update
  140. sudo apt-get install build-essential gcc-8
  141. - uses: actions/setup-node@v4
  142. with:
  143. node-version: "20"
  144. - uses: actions/setup-python@v5
  145. with:
  146. python-version: "3.11"
  147. - name: Build
  148. id: make_build
  149. env:
  150. LLAMA_FATAL_WARNINGS: 1
  151. run: |
  152. CC=gcc-8 make -j $(nproc)
  153. - name: Test
  154. id: make_test
  155. run: |
  156. CC=gcc-8 make tests -j $(nproc)
  157. make test -j $(nproc)
  158. ubuntu-focal-make-curl:
  159. runs-on: ubuntu-20.04
  160. steps:
  161. - name: Clone
  162. id: checkout
  163. uses: actions/checkout@v4
  164. - name: Dependencies
  165. id: depends
  166. run: |
  167. sudo apt-get update
  168. sudo apt-get install build-essential gcc-8 libcurl4-openssl-dev
  169. - name: Build
  170. id: make_build
  171. env:
  172. LLAMA_FATAL_WARNINGS: 1
  173. LLAMA_CURL: 1
  174. run: |
  175. CC=gcc-8 make -j $(nproc)
  176. ubuntu-latest-cmake:
  177. runs-on: ubuntu-latest
  178. steps:
  179. - name: Clone
  180. id: checkout
  181. uses: actions/checkout@v4
  182. with:
  183. fetch-depth: 0
  184. - name: Dependencies
  185. id: depends
  186. run: |
  187. sudo apt-get update
  188. sudo apt-get install build-essential libcurl4-openssl-dev
  189. - name: Build
  190. id: cmake_build
  191. run: |
  192. mkdir build
  193. cd build
  194. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF
  195. cmake --build . --config Release -j $(nproc)
  196. - name: Test
  197. id: cmake_test
  198. run: |
  199. cd build
  200. ctest -L 'main|curl' --verbose --timeout 900
  201. - name: Test llama2c conversion
  202. id: llama2c_test
  203. run: |
  204. cd build
  205. echo "Fetch tokenizer"
  206. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  207. echo "Fetch llama2c model"
  208. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  209. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  210. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  211. - name: Determine tag name
  212. id: tag
  213. shell: bash
  214. run: |
  215. BUILD_NUMBER="$(git rev-list --count HEAD)"
  216. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  217. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  218. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  219. else
  220. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  221. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  222. fi
  223. - name: Pack artifacts
  224. id: pack_artifacts
  225. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  226. run: |
  227. cp LICENSE ./build/bin/
  228. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  229. - name: Upload artifacts
  230. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  231. uses: actions/upload-artifact@v4
  232. with:
  233. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  234. name: llama-bin-ubuntu-x64.zip
  235. ubuntu-latest-cmake-sanitizer:
  236. runs-on: ubuntu-latest
  237. continue-on-error: true
  238. strategy:
  239. matrix:
  240. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  241. build_type: [Debug, Release]
  242. steps:
  243. - name: Clone
  244. id: checkout
  245. uses: actions/checkout@v4
  246. - name: Dependencies
  247. id: depends
  248. run: |
  249. sudo apt-get update
  250. sudo apt-get install build-essential
  251. - name: Build
  252. id: cmake_build
  253. if: ${{ matrix.sanitizer != 'THREAD' }}
  254. run: |
  255. mkdir build
  256. cd build
  257. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  258. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  259. - name: Build (no OpenMP)
  260. id: cmake_build_no_openmp
  261. if: ${{ matrix.sanitizer == 'THREAD' }}
  262. run: |
  263. mkdir build
  264. cd build
  265. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGGML_OPENMP=OFF
  266. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  267. - name: Test
  268. id: cmake_test
  269. run: |
  270. cd build
  271. ctest -L main --verbose --timeout 900
  272. ubuntu-latest-cmake-rpc:
  273. runs-on: ubuntu-latest
  274. continue-on-error: true
  275. steps:
  276. - name: Clone
  277. id: checkout
  278. uses: actions/checkout@v4
  279. - name: Dependencies
  280. id: depends
  281. run: |
  282. sudo apt-get update
  283. sudo apt-get install build-essential
  284. - name: Build
  285. id: cmake_build
  286. run: |
  287. mkdir build
  288. cd build
  289. cmake -DGGML_RPC=ON ..
  290. cmake --build . --config Release -j $(nproc)
  291. - name: Test
  292. id: cmake_test
  293. run: |
  294. cd build
  295. ctest -L main --verbose
  296. ubuntu-22-cmake-vulkan:
  297. runs-on: ubuntu-22.04
  298. steps:
  299. - name: Clone
  300. id: checkout
  301. uses: actions/checkout@v4
  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 vulkan-sdk
  309. - name: Build
  310. id: cmake_build
  311. run: |
  312. mkdir build
  313. cd build
  314. cmake -DGGML_VULKAN=ON ..
  315. cmake --build . --config Release -j $(nproc)
  316. ubuntu-22-cmake-hip:
  317. runs-on: ubuntu-22.04
  318. container: rocm/dev-ubuntu-22.04:6.0.2
  319. steps:
  320. - name: Clone
  321. id: checkout
  322. uses: actions/checkout@v4
  323. - name: Dependencies
  324. id: depends
  325. run: |
  326. sudo apt-get update
  327. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  328. - name: Build with native CMake HIP support
  329. id: cmake_build
  330. run: |
  331. cmake -B build -S . -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIPBLAS=ON
  332. cmake --build build --config Release -j $(nproc)
  333. - name: Build with legacy HIP support
  334. id: cmake_build_legacy_hip
  335. run: |
  336. cmake -B build2 -S . -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DGGML_HIPBLAS=ON
  337. cmake --build build2 --config Release -j $(nproc)
  338. ubuntu-22-cmake-sycl:
  339. runs-on: ubuntu-22.04
  340. continue-on-error: true
  341. steps:
  342. - uses: actions/checkout@v4
  343. - name: add oneAPI to apt
  344. shell: bash
  345. run: |
  346. cd /tmp
  347. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  348. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  349. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  350. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  351. - name: install oneAPI dpcpp compiler
  352. shell: bash
  353. run: |
  354. sudo apt update
  355. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  356. - name: install oneAPI MKL library
  357. shell: bash
  358. run: |
  359. sudo apt install intel-oneapi-mkl-devel
  360. - name: Clone
  361. id: checkout
  362. uses: actions/checkout@v4
  363. - name: Build
  364. id: cmake_build
  365. run: |
  366. source /opt/intel/oneapi/setvars.sh
  367. mkdir build
  368. cd build
  369. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  370. cmake --build . --config Release -j $(nproc)
  371. ubuntu-22-cmake-sycl-fp16:
  372. runs-on: ubuntu-22.04
  373. continue-on-error: true
  374. steps:
  375. - uses: actions/checkout@v4
  376. - name: add oneAPI to apt
  377. shell: bash
  378. run: |
  379. cd /tmp
  380. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  381. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  382. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  383. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  384. - name: install oneAPI dpcpp compiler
  385. shell: bash
  386. run: |
  387. sudo apt update
  388. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  389. - name: install oneAPI MKL library
  390. shell: bash
  391. run: |
  392. sudo apt install intel-oneapi-mkl-devel
  393. - name: Clone
  394. id: checkout
  395. uses: actions/checkout@v4
  396. - name: Build
  397. id: cmake_build
  398. run: |
  399. source /opt/intel/oneapi/setvars.sh
  400. mkdir build
  401. cd build
  402. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
  403. cmake --build . --config Release -j $(nproc)
  404. # TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  405. # how to debug it.
  406. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  407. macOS-latest-make:
  408. runs-on: macos-latest
  409. steps:
  410. - name: Clone
  411. id: checkout
  412. uses: actions/checkout@v4
  413. - name: Dependencies
  414. id: depends
  415. continue-on-error: true
  416. run: |
  417. brew update
  418. - name: Build
  419. id: make_build
  420. env:
  421. LLAMA_FATAL_WARNINGS: 1
  422. run: |
  423. GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  424. - name: Test
  425. id: make_test
  426. run: |
  427. GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  428. GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  429. # TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  430. # how to debug it.
  431. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  432. # would be great if we fix these
  433. macOS-latest-cmake:
  434. runs-on: macos-latest
  435. steps:
  436. - name: Clone
  437. id: checkout
  438. uses: actions/checkout@v4
  439. - name: Dependencies
  440. id: depends
  441. continue-on-error: true
  442. run: |
  443. brew update
  444. - name: Build
  445. id: cmake_build
  446. run: |
  447. sysctl -a
  448. mkdir build
  449. cd build
  450. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF ..
  451. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  452. - name: Test
  453. id: cmake_test
  454. run: |
  455. cd build
  456. ctest -L main --verbose --timeout 900
  457. macOS-latest-cmake-ios:
  458. runs-on: macos-latest
  459. steps:
  460. - name: Clone
  461. id: checkout
  462. uses: actions/checkout@v4
  463. - name: Dependencies
  464. id: depends
  465. continue-on-error: true
  466. run: |
  467. brew update
  468. - name: Build
  469. id: cmake_build
  470. run: |
  471. sysctl -a
  472. mkdir build
  473. cd build
  474. cmake -G Xcode .. \
  475. -DGGML_METAL_EMBED_LIBRARY=ON \
  476. -DLLAMA_BUILD_EXAMPLES=OFF \
  477. -DLLAMA_BUILD_TESTS=OFF \
  478. -DLLAMA_BUILD_SERVER=OFF \
  479. -DCMAKE_SYSTEM_NAME=iOS \
  480. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  481. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  482. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  483. macOS-latest-cmake-tvos:
  484. runs-on: macos-latest
  485. steps:
  486. - name: Clone
  487. id: checkout
  488. uses: actions/checkout@v4
  489. - name: Dependencies
  490. id: depends
  491. continue-on-error: true
  492. run: |
  493. brew update
  494. - name: Build
  495. id: cmake_build
  496. run: |
  497. sysctl -a
  498. mkdir build
  499. cd build
  500. cmake -G Xcode .. \
  501. -DGGML_METAL_EMBED_LIBRARY=ON \
  502. -DLLAMA_BUILD_EXAMPLES=OFF \
  503. -DLLAMA_BUILD_TESTS=OFF \
  504. -DLLAMA_BUILD_SERVER=OFF \
  505. -DCMAKE_SYSTEM_NAME=tvOS \
  506. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  507. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  508. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  509. macOS-latest-swift:
  510. runs-on: macos-latest
  511. strategy:
  512. matrix:
  513. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  514. steps:
  515. - name: Clone
  516. id: checkout
  517. uses: actions/checkout@v4
  518. - name: Dependencies
  519. id: depends
  520. continue-on-error: true
  521. run: |
  522. brew update
  523. - name: xcodebuild for swift package
  524. id: xcodebuild
  525. run: |
  526. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  527. - name: Build Swift Example
  528. id: make_build_swift_example
  529. run: |
  530. make swift
  531. windows-msys2:
  532. runs-on: windows-latest
  533. strategy:
  534. fail-fast: false
  535. matrix:
  536. include:
  537. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  538. - { sys: CLANG64, env: clang-x86_64, build: Release }
  539. steps:
  540. - name: Clone
  541. uses: actions/checkout@v4
  542. - name: Setup ${{ matrix.sys }}
  543. uses: msys2/setup-msys2@v2
  544. with:
  545. update: true
  546. msystem: ${{matrix.sys}}
  547. install: >-
  548. base-devel
  549. mingw-w64-${{matrix.env}}-toolchain
  550. mingw-w64-${{matrix.env}}-cmake
  551. mingw-w64-${{matrix.env}}-openblas
  552. - name: Build using make
  553. shell: msys2 {0}
  554. run: |
  555. make -j $(nproc)
  556. - name: Clean after building using make
  557. shell: msys2 {0}
  558. run: |
  559. make clean
  560. - name: Build using make w/ OpenBLAS
  561. shell: msys2 {0}
  562. run: |
  563. make GGML_OPENBLAS=1 -j $(nproc)
  564. - name: Build using CMake
  565. shell: msys2 {0}
  566. run: |
  567. cmake -B build
  568. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  569. - name: Clean after building using CMake
  570. shell: msys2 {0}
  571. run: |
  572. rm -rf build
  573. - name: Build using CMake w/ OpenBLAS
  574. shell: msys2 {0}
  575. run: |
  576. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  577. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  578. windows-latest-cmake:
  579. runs-on: windows-2019
  580. env:
  581. OPENBLAS_VERSION: 0.3.23
  582. SDE_VERSION: 9.33.0-2024-01-07
  583. VULKAN_VERSION: 1.3.261.1
  584. strategy:
  585. matrix:
  586. include:
  587. - build: 'noavx-x64'
  588. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  589. - build: 'avx2-x64'
  590. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON'
  591. - build: 'avx-x64'
  592. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  593. - build: 'avx512-x64'
  594. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  595. - build: 'openblas-x64'
  596. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BLAS=ON -DBUILD_SHARED_LIBS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  597. - build: 'kompute-x64'
  598. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  599. - build: 'vulkan-x64'
  600. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  601. - build: 'llvm-arm64'
  602. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  603. - build: 'msvc-arm64'
  604. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  605. steps:
  606. - name: Clone
  607. id: checkout
  608. uses: actions/checkout@v4
  609. with:
  610. fetch-depth: 0
  611. - name: Clone Kompute submodule
  612. id: clone_kompute
  613. if: ${{ matrix.build == 'kompute-x64' }}
  614. run: |
  615. git submodule update --init ggml/src/kompute
  616. - name: Download OpenBLAS
  617. id: get_openblas
  618. if: ${{ matrix.build == 'openblas-x64' }}
  619. run: |
  620. 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"
  621. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  622. mkdir $env:RUNNER_TEMP/openblas
  623. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  624. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  625. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  626. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  627. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  628. - name: Install Vulkan SDK
  629. id: get_vulkan
  630. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  631. run: |
  632. 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"
  633. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  634. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  635. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  636. - name: Install Ninja
  637. id: install_ninja
  638. run: |
  639. choco install ninja
  640. - name: Build
  641. id: cmake_build
  642. run: |
  643. cmake -S . -B build ${{ matrix.defines }}
  644. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  645. - name: Add libopenblas.dll
  646. id: add_libopenblas_dll
  647. if: ${{ matrix.build == 'openblas-x64' }}
  648. run: |
  649. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  650. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  651. - name: Check AVX512F support
  652. id: check_avx512f
  653. if: ${{ matrix.build == 'avx512-x64' }}
  654. continue-on-error: true
  655. run: |
  656. cd build
  657. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  658. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  659. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  660. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  661. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  662. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  663. - name: Test
  664. id: cmake_test
  665. # not all machines have native AVX-512
  666. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  667. run: |
  668. cd build
  669. ctest -L main -C Release --verbose --timeout 900
  670. - name: Test (Intel SDE)
  671. id: cmake_test_sde
  672. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  673. run: |
  674. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  675. # for some weird reason windows tar doesn't like sde tar.xz
  676. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  677. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  678. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  679. cd build
  680. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  681. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  682. - name: Determine tag name
  683. id: tag
  684. shell: bash
  685. run: |
  686. BUILD_NUMBER="$(git rev-list --count HEAD)"
  687. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  688. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  689. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  690. else
  691. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  692. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  693. fi
  694. - name: Pack artifacts
  695. id: pack_artifacts
  696. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  697. run: |
  698. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  699. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  700. - name: Upload artifacts
  701. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  702. uses: actions/upload-artifact@v4
  703. with:
  704. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  705. name: llama-bin-win-${{ matrix.build }}.zip
  706. windows-latest-cmake-cuda:
  707. runs-on: windows-2019
  708. strategy:
  709. matrix:
  710. cuda: ['12.2.0', '11.7.1']
  711. build: ['cuda']
  712. steps:
  713. - name: Clone
  714. id: checkout
  715. uses: actions/checkout@v4
  716. with:
  717. fetch-depth: 0
  718. - name: Install CUDA toolkit
  719. id: cuda-toolkit
  720. uses: Jimver/cuda-toolkit@v0.2.15
  721. with:
  722. cuda: ${{ matrix.cuda }}
  723. method: 'network'
  724. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  725. - name: Build
  726. id: cmake_build
  727. run: |
  728. mkdir build
  729. cd build
  730. cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON -DGGML_RPC=ON
  731. cmake --build . --config Release -j $((${env:NUMBER_OF_PROCESSORS} - 1)) -t ggml
  732. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  733. - name: Determine tag name
  734. id: tag
  735. shell: bash
  736. run: |
  737. BUILD_NUMBER="$(git rev-list --count HEAD)"
  738. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  739. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  740. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  741. else
  742. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  743. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  744. fi
  745. - name: Pack artifacts
  746. id: pack_artifacts
  747. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  748. run: |
  749. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  750. - name: Upload artifacts
  751. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  752. uses: actions/upload-artifact@v4
  753. with:
  754. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  755. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  756. - name: Copy and pack Cuda runtime
  757. run: |
  758. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  759. $dst='.\build\bin\cudart\'
  760. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  761. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  762. - name: Upload Cuda runtime
  763. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  764. uses: actions/upload-artifact@v4
  765. with:
  766. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  767. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  768. windows-latest-cmake-sycl:
  769. runs-on: windows-latest
  770. defaults:
  771. run:
  772. shell: bash
  773. env:
  774. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
  775. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  776. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  777. steps:
  778. - name: Clone
  779. id: checkout
  780. uses: actions/checkout@v4
  781. with:
  782. fetch-depth: 0
  783. - name: Install
  784. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  785. - name: Build
  786. id: cmake_build
  787. run: examples/sycl/win-build-sycl.bat
  788. - name: Determine tag name
  789. id: tag
  790. shell: bash
  791. run: |
  792. BUILD_NUMBER="$(git rev-list --count HEAD)"
  793. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  794. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  795. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  796. else
  797. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  798. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  799. fi
  800. - name: Pack artifacts
  801. id: pack_artifacts
  802. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  803. run: |
  804. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  805. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  806. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  807. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  808. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  809. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  810. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  811. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  812. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  813. echo "cp oneAPI running time dll files to ./build/bin done"
  814. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  815. - name: Upload artifacts
  816. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  817. uses: actions/upload-artifact@v4
  818. with:
  819. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  820. name: llama-bin-win-sycl-x64.zip
  821. windows-latest-cmake-hip:
  822. if: ${{ github.event.inputs.create_release != 'true' }}
  823. runs-on: windows-latest
  824. steps:
  825. - name: Clone
  826. id: checkout
  827. uses: actions/checkout@v4
  828. - name: Install
  829. id: depends
  830. run: |
  831. $ErrorActionPreference = "Stop"
  832. write-host "Downloading AMD HIP SDK Installer"
  833. 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"
  834. write-host "Installing AMD HIP SDK"
  835. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  836. write-host "Completed AMD HIP SDK installation"
  837. - name: Verify ROCm
  838. id: verify
  839. run: |
  840. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  841. - name: Build
  842. id: cmake_build
  843. run: |
  844. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  845. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  846. cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGGML_RPC=ON
  847. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  848. windows-latest-cmake-hip-release:
  849. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  850. runs-on: windows-latest
  851. strategy:
  852. matrix:
  853. gpu_target: [gfx1100, gfx1101, gfx1030]
  854. steps:
  855. - name: Clone
  856. id: checkout
  857. uses: actions/checkout@v4
  858. - name: Install
  859. id: depends
  860. run: |
  861. $ErrorActionPreference = "Stop"
  862. write-host "Downloading AMD HIP SDK Installer"
  863. 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"
  864. write-host "Installing AMD HIP SDK"
  865. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  866. write-host "Completed AMD HIP SDK installation"
  867. - name: Verify ROCm
  868. id: verify
  869. run: |
  870. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  871. - name: Build
  872. id: cmake_build
  873. run: |
  874. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  875. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  876. cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGPU_TARGETS=${{ matrix.gpu_target }} -DGGML_RPC=ON
  877. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  878. md "build\bin\rocblas\library\"
  879. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  880. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  881. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  882. - name: Determine tag name
  883. id: tag
  884. shell: bash
  885. run: |
  886. BUILD_NUMBER="$(git rev-list --count HEAD)"
  887. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  888. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  889. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  890. else
  891. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  892. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  893. fi
  894. - name: Pack artifacts
  895. id: pack_artifacts
  896. run: |
  897. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  898. - name: Upload artifacts
  899. uses: actions/upload-artifact@v4
  900. with:
  901. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  902. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  903. ios-xcode-build:
  904. runs-on: macos-latest
  905. steps:
  906. - name: Checkout code
  907. uses: actions/checkout@v4
  908. - name: Build Xcode project
  909. 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
  910. android-build:
  911. runs-on: ubuntu-latest
  912. steps:
  913. - name: Clone
  914. uses: actions/checkout@v4
  915. - name: Set up JDK
  916. uses: actions/setup-java@v3
  917. with:
  918. java-version: 17
  919. distribution: zulu
  920. - name: Setup Android SDK
  921. uses: android-actions/setup-android@v3
  922. with:
  923. log-accepted-android-sdk-licenses: false
  924. - name: Build
  925. run: |
  926. cd examples/llama.android
  927. ./gradlew build --no-daemon
  928. # freeBSD-latest:
  929. # runs-on: macos-12
  930. # steps:
  931. # - name: Clone
  932. # uses: actions/checkout@v4
  933. #
  934. # - name: Build
  935. # uses: cross-platform-actions/action@v0.19.0
  936. # with:
  937. # operating_system: freebsd
  938. # version: '13.2'
  939. # hypervisor: 'qemu'
  940. # run: |
  941. # sudo pkg update
  942. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  943. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  944. release:
  945. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  946. runs-on: ubuntu-latest
  947. needs:
  948. - ubuntu-focal-make
  949. - ubuntu-latest-cmake
  950. - macOS-latest-make
  951. - macOS-latest-cmake
  952. - windows-latest-cmake
  953. - windows-latest-cmake-cuda
  954. - windows-latest-cmake-hip-release
  955. - macOS-latest-cmake-arm64
  956. - macOS-latest-cmake-x64
  957. steps:
  958. - name: Clone
  959. id: checkout
  960. uses: actions/checkout@v4
  961. with:
  962. fetch-depth: 0
  963. - name: Determine tag name
  964. id: tag
  965. shell: bash
  966. run: |
  967. BUILD_NUMBER="$(git rev-list --count HEAD)"
  968. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  969. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  970. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  971. else
  972. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  973. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  974. fi
  975. - name: Download artifacts
  976. id: download-artifact
  977. uses: actions/download-artifact@v4
  978. with:
  979. path: ./artifact
  980. - name: Move artifacts
  981. id: move_artifacts
  982. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  983. - name: Create release
  984. id: create_release
  985. uses: anzz1/action-create-release@v1
  986. env:
  987. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  988. with:
  989. tag_name: ${{ steps.tag.outputs.name }}
  990. - name: Upload release
  991. id: upload_release
  992. uses: actions/github-script@v3
  993. with:
  994. github-token: ${{secrets.GITHUB_TOKEN}}
  995. script: |
  996. const path = require('path');
  997. const fs = require('fs');
  998. const release_id = '${{ steps.create_release.outputs.id }}';
  999. for (let file of await fs.readdirSync('./artifact/release')) {
  1000. if (path.extname(file) === '.zip') {
  1001. console.log('uploadReleaseAsset', file);
  1002. await github.repos.uploadReleaseAsset({
  1003. owner: context.repo.owner,
  1004. repo: context.repo.repo,
  1005. release_id: release_id,
  1006. name: file,
  1007. data: await fs.readFileSync(`./artifact/release/${file}`)
  1008. });
  1009. }
  1010. }
  1011. # ubuntu-latest-gcc:
  1012. # runs-on: ubuntu-latest
  1013. #
  1014. # strategy:
  1015. # matrix:
  1016. # build: [Debug, Release]
  1017. #
  1018. # steps:
  1019. # - name: Clone
  1020. # uses: actions/checkout@v4
  1021. #
  1022. # - name: Dependencies
  1023. # run: |
  1024. # sudo apt-get update
  1025. # sudo apt-get install build-essential
  1026. # sudo apt-get install cmake
  1027. #
  1028. # - name: Configure
  1029. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1030. #
  1031. # - name: Build
  1032. # run: |
  1033. # make
  1034. #
  1035. # ubuntu-latest-clang:
  1036. # runs-on: ubuntu-latest
  1037. #
  1038. # strategy:
  1039. # matrix:
  1040. # build: [Debug, Release]
  1041. #
  1042. # steps:
  1043. # - name: Clone
  1044. # uses: actions/checkout@v4
  1045. #
  1046. # - name: Dependencies
  1047. # run: |
  1048. # sudo apt-get update
  1049. # sudo apt-get install build-essential
  1050. # sudo apt-get install cmake
  1051. #
  1052. # - name: Configure
  1053. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1054. #
  1055. # - name: Build
  1056. # run: |
  1057. # make
  1058. #
  1059. # ubuntu-latest-gcc-sanitized:
  1060. # runs-on: ubuntu-latest
  1061. #
  1062. # strategy:
  1063. # matrix:
  1064. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1065. #
  1066. # steps:
  1067. # - name: Clone
  1068. # uses: actions/checkout@v4
  1069. #
  1070. # - name: Dependencies
  1071. # run: |
  1072. # sudo apt-get update
  1073. # sudo apt-get install build-essential
  1074. # sudo apt-get install cmake
  1075. #
  1076. # - name: Configure
  1077. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1078. #
  1079. # - name: Build
  1080. # run: |
  1081. # make
  1082. #
  1083. # windows:
  1084. # runs-on: windows-latest
  1085. #
  1086. # strategy:
  1087. # matrix:
  1088. # build: [Release]
  1089. # arch: [Win32, x64]
  1090. # include:
  1091. # - arch: Win32
  1092. # s2arc: x86
  1093. # - arch: x64
  1094. # s2arc: x64
  1095. #
  1096. # steps:
  1097. # - name: Clone
  1098. # uses: actions/checkout@v4
  1099. #
  1100. # - name: Add msbuild to PATH
  1101. # uses: microsoft/setup-msbuild@v1
  1102. #
  1103. # - name: Configure
  1104. # run: >
  1105. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1106. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1107. #
  1108. # - name: Build
  1109. # run: |
  1110. # cd ./build
  1111. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1112. #
  1113. # - name: Upload binaries
  1114. # uses: actions/upload-artifact@v4
  1115. # with:
  1116. # name: llama-bin-${{ matrix.arch }}
  1117. # path: build/bin/${{ matrix.build }}
  1118. #
  1119. # windows-blas:
  1120. # runs-on: windows-latest
  1121. #
  1122. # strategy:
  1123. # matrix:
  1124. # build: [Release]
  1125. # arch: [Win32, x64]
  1126. # blas: [ON]
  1127. # include:
  1128. # - arch: Win32
  1129. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1130. # s2arc: x86
  1131. # - arch: x64
  1132. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1133. # s2arc: x64
  1134. #
  1135. # steps:
  1136. # - name: Clone
  1137. # uses: actions/checkout@v4
  1138. #
  1139. # - name: Add msbuild to PATH
  1140. # uses: microsoft/setup-msbuild@v1
  1141. #
  1142. # - name: Fetch OpenBLAS
  1143. # if: matrix.blas == 'ON'
  1144. # run: |
  1145. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1146. # 7z x blas.zip -oblas -y
  1147. # copy blas/include/cblas.h .
  1148. # copy blas/include/openblas_config.h .
  1149. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1150. #
  1151. # - name: Configure
  1152. # run: >
  1153. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1154. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1155. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1156. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1157. #
  1158. # - name: Build
  1159. # run: |
  1160. # cd ./build
  1161. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1162. #
  1163. # - name: Copy libopenblas.dll
  1164. # if: matrix.blas == 'ON'
  1165. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1166. #
  1167. # - name: Upload binaries
  1168. # if: matrix.blas == 'ON'
  1169. # uses: actions/upload-artifact@v4
  1170. # with:
  1171. # name: llama-blas-bin-${{ matrix.arch }}
  1172. # path: build/bin/${{ matrix.build }}
  1173. #
  1174. # emscripten:
  1175. # runs-on: ubuntu-latest
  1176. #
  1177. # strategy:
  1178. # matrix:
  1179. # build: [Release]
  1180. #
  1181. # steps:
  1182. # - name: Clone
  1183. # uses: actions/checkout@v4
  1184. #
  1185. # - name: Dependencies
  1186. # run: |
  1187. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1188. # tar -xvf master.tar.gz
  1189. # emsdk-master/emsdk update
  1190. # emsdk-master/emsdk install latest
  1191. # emsdk-master/emsdk activate latest
  1192. #
  1193. # - name: Configure
  1194. # run: echo "tmp"
  1195. #
  1196. # - name: Build
  1197. # run: |
  1198. # pushd emsdk-master
  1199. # source ./emsdk_env.sh
  1200. # popd
  1201. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1202. # make