build.yml 59 KB

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