build.yml 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  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. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  814. echo "cp oneAPI running time dll files to ./build/bin done"
  815. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  816. - name: Upload artifacts
  817. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  818. uses: actions/upload-artifact@v4
  819. with:
  820. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  821. name: llama-bin-win-sycl-x64.zip
  822. windows-latest-cmake-hip:
  823. if: ${{ github.event.inputs.create_release != 'true' }}
  824. runs-on: windows-latest
  825. steps:
  826. - name: Clone
  827. id: checkout
  828. uses: actions/checkout@v4
  829. - name: Install
  830. id: depends
  831. run: |
  832. $ErrorActionPreference = "Stop"
  833. write-host "Downloading AMD HIP SDK Installer"
  834. 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"
  835. write-host "Installing AMD HIP SDK"
  836. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  837. write-host "Completed AMD HIP SDK installation"
  838. - name: Verify ROCm
  839. id: verify
  840. run: |
  841. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  842. - name: Build
  843. id: cmake_build
  844. run: |
  845. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  846. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  847. 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
  848. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  849. windows-latest-cmake-hip-release:
  850. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  851. runs-on: windows-latest
  852. strategy:
  853. matrix:
  854. gpu_target: [gfx1100, gfx1101, gfx1030]
  855. steps:
  856. - name: Clone
  857. id: checkout
  858. uses: actions/checkout@v4
  859. - name: Install
  860. id: depends
  861. run: |
  862. $ErrorActionPreference = "Stop"
  863. write-host "Downloading AMD HIP SDK Installer"
  864. 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"
  865. write-host "Installing AMD HIP SDK"
  866. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  867. write-host "Completed AMD HIP SDK installation"
  868. - name: Verify ROCm
  869. id: verify
  870. run: |
  871. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  872. - name: Build
  873. id: cmake_build
  874. run: |
  875. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  876. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  877. 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
  878. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  879. md "build\bin\rocblas\library\"
  880. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  881. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  882. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  883. - name: Determine tag name
  884. id: tag
  885. shell: bash
  886. run: |
  887. BUILD_NUMBER="$(git rev-list --count HEAD)"
  888. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  889. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  890. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  891. else
  892. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  893. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  894. fi
  895. - name: Pack artifacts
  896. id: pack_artifacts
  897. run: |
  898. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  899. - name: Upload artifacts
  900. uses: actions/upload-artifact@v4
  901. with:
  902. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  903. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  904. ios-xcode-build:
  905. runs-on: macos-latest
  906. steps:
  907. - name: Checkout code
  908. uses: actions/checkout@v4
  909. - name: Build Xcode project
  910. 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
  911. android-build:
  912. runs-on: ubuntu-latest
  913. steps:
  914. - name: Clone
  915. uses: actions/checkout@v4
  916. - name: Set up JDK
  917. uses: actions/setup-java@v3
  918. with:
  919. java-version: 17
  920. distribution: zulu
  921. - name: Setup Android SDK
  922. uses: android-actions/setup-android@v3
  923. with:
  924. log-accepted-android-sdk-licenses: false
  925. - name: Build
  926. run: |
  927. cd examples/llama.android
  928. ./gradlew build --no-daemon
  929. # freeBSD-latest:
  930. # runs-on: macos-12
  931. # steps:
  932. # - name: Clone
  933. # uses: actions/checkout@v4
  934. #
  935. # - name: Build
  936. # uses: cross-platform-actions/action@v0.19.0
  937. # with:
  938. # operating_system: freebsd
  939. # version: '13.2'
  940. # hypervisor: 'qemu'
  941. # run: |
  942. # sudo pkg update
  943. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  944. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  945. release:
  946. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  947. runs-on: ubuntu-latest
  948. needs:
  949. - ubuntu-focal-make
  950. - ubuntu-latest-cmake
  951. - macOS-latest-make
  952. - macOS-latest-cmake
  953. - windows-latest-cmake
  954. - windows-latest-cmake-cuda
  955. - windows-latest-cmake-hip-release
  956. - macOS-latest-cmake-arm64
  957. - macOS-latest-cmake-x64
  958. steps:
  959. - name: Clone
  960. id: checkout
  961. uses: actions/checkout@v4
  962. with:
  963. fetch-depth: 0
  964. - name: Determine tag name
  965. id: tag
  966. shell: bash
  967. run: |
  968. BUILD_NUMBER="$(git rev-list --count HEAD)"
  969. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  970. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  971. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  972. else
  973. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  974. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  975. fi
  976. - name: Download artifacts
  977. id: download-artifact
  978. uses: actions/download-artifact@v4
  979. with:
  980. path: ./artifact
  981. - name: Move artifacts
  982. id: move_artifacts
  983. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  984. - name: Create release
  985. id: create_release
  986. uses: anzz1/action-create-release@v1
  987. env:
  988. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  989. with:
  990. tag_name: ${{ steps.tag.outputs.name }}
  991. - name: Upload release
  992. id: upload_release
  993. uses: actions/github-script@v3
  994. with:
  995. github-token: ${{secrets.GITHUB_TOKEN}}
  996. script: |
  997. const path = require('path');
  998. const fs = require('fs');
  999. const release_id = '${{ steps.create_release.outputs.id }}';
  1000. for (let file of await fs.readdirSync('./artifact/release')) {
  1001. if (path.extname(file) === '.zip') {
  1002. console.log('uploadReleaseAsset', file);
  1003. await github.repos.uploadReleaseAsset({
  1004. owner: context.repo.owner,
  1005. repo: context.repo.repo,
  1006. release_id: release_id,
  1007. name: file,
  1008. data: await fs.readFileSync(`./artifact/release/${file}`)
  1009. });
  1010. }
  1011. }
  1012. # ubuntu-latest-gcc:
  1013. # runs-on: ubuntu-latest
  1014. #
  1015. # strategy:
  1016. # matrix:
  1017. # build: [Debug, Release]
  1018. #
  1019. # steps:
  1020. # - name: Clone
  1021. # uses: actions/checkout@v4
  1022. #
  1023. # - name: Dependencies
  1024. # run: |
  1025. # sudo apt-get update
  1026. # sudo apt-get install build-essential
  1027. # sudo apt-get install cmake
  1028. #
  1029. # - name: Configure
  1030. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1031. #
  1032. # - name: Build
  1033. # run: |
  1034. # make
  1035. #
  1036. # ubuntu-latest-clang:
  1037. # runs-on: ubuntu-latest
  1038. #
  1039. # strategy:
  1040. # matrix:
  1041. # build: [Debug, Release]
  1042. #
  1043. # steps:
  1044. # - name: Clone
  1045. # uses: actions/checkout@v4
  1046. #
  1047. # - name: Dependencies
  1048. # run: |
  1049. # sudo apt-get update
  1050. # sudo apt-get install build-essential
  1051. # sudo apt-get install cmake
  1052. #
  1053. # - name: Configure
  1054. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1055. #
  1056. # - name: Build
  1057. # run: |
  1058. # make
  1059. #
  1060. # ubuntu-latest-gcc-sanitized:
  1061. # runs-on: ubuntu-latest
  1062. #
  1063. # strategy:
  1064. # matrix:
  1065. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1066. #
  1067. # steps:
  1068. # - name: Clone
  1069. # uses: actions/checkout@v4
  1070. #
  1071. # - name: Dependencies
  1072. # run: |
  1073. # sudo apt-get update
  1074. # sudo apt-get install build-essential
  1075. # sudo apt-get install cmake
  1076. #
  1077. # - name: Configure
  1078. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1079. #
  1080. # - name: Build
  1081. # run: |
  1082. # make
  1083. #
  1084. # windows:
  1085. # runs-on: windows-latest
  1086. #
  1087. # strategy:
  1088. # matrix:
  1089. # build: [Release]
  1090. # arch: [Win32, x64]
  1091. # include:
  1092. # - arch: Win32
  1093. # s2arc: x86
  1094. # - arch: x64
  1095. # s2arc: x64
  1096. #
  1097. # steps:
  1098. # - name: Clone
  1099. # uses: actions/checkout@v4
  1100. #
  1101. # - name: Add msbuild to PATH
  1102. # uses: microsoft/setup-msbuild@v1
  1103. #
  1104. # - name: Configure
  1105. # run: >
  1106. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1107. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1108. #
  1109. # - name: Build
  1110. # run: |
  1111. # cd ./build
  1112. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1113. #
  1114. # - name: Upload binaries
  1115. # uses: actions/upload-artifact@v4
  1116. # with:
  1117. # name: llama-bin-${{ matrix.arch }}
  1118. # path: build/bin/${{ matrix.build }}
  1119. #
  1120. # windows-blas:
  1121. # runs-on: windows-latest
  1122. #
  1123. # strategy:
  1124. # matrix:
  1125. # build: [Release]
  1126. # arch: [Win32, x64]
  1127. # blas: [ON]
  1128. # include:
  1129. # - arch: Win32
  1130. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1131. # s2arc: x86
  1132. # - arch: x64
  1133. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1134. # s2arc: x64
  1135. #
  1136. # steps:
  1137. # - name: Clone
  1138. # uses: actions/checkout@v4
  1139. #
  1140. # - name: Add msbuild to PATH
  1141. # uses: microsoft/setup-msbuild@v1
  1142. #
  1143. # - name: Fetch OpenBLAS
  1144. # if: matrix.blas == 'ON'
  1145. # run: |
  1146. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1147. # 7z x blas.zip -oblas -y
  1148. # copy blas/include/cblas.h .
  1149. # copy blas/include/openblas_config.h .
  1150. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1151. #
  1152. # - name: Configure
  1153. # run: >
  1154. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1155. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1156. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1157. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1158. #
  1159. # - name: Build
  1160. # run: |
  1161. # cd ./build
  1162. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1163. #
  1164. # - name: Copy libopenblas.dll
  1165. # if: matrix.blas == 'ON'
  1166. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1167. #
  1168. # - name: Upload binaries
  1169. # if: matrix.blas == 'ON'
  1170. # uses: actions/upload-artifact@v4
  1171. # with:
  1172. # name: llama-blas-bin-${{ matrix.arch }}
  1173. # path: build/bin/${{ matrix.build }}
  1174. #
  1175. # emscripten:
  1176. # runs-on: ubuntu-latest
  1177. #
  1178. # strategy:
  1179. # matrix:
  1180. # build: [Release]
  1181. #
  1182. # steps:
  1183. # - name: Clone
  1184. # uses: actions/checkout@v4
  1185. #
  1186. # - name: Dependencies
  1187. # run: |
  1188. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1189. # tar -xvf master.tar.gz
  1190. # emsdk-master/emsdk update
  1191. # emsdk-master/emsdk install latest
  1192. # emsdk-master/emsdk activate latest
  1193. #
  1194. # - name: Configure
  1195. # run: echo "tmp"
  1196. #
  1197. # - name: Build
  1198. # run: |
  1199. # pushd emsdk-master
  1200. # source ./emsdk_env.sh
  1201. # popd
  1202. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1203. # make