build.yml 45 KB

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