build.yml 44 KB

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