build.yml 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643
  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. variant: sccache
  589. evict-old-files: 1d
  590. - name: Setup ${{ matrix.sys }}
  591. uses: msys2/setup-msys2@v2
  592. with:
  593. update: true
  594. msystem: ${{matrix.sys}}
  595. install: >-
  596. base-devel
  597. git
  598. mingw-w64-${{matrix.env}}-toolchain
  599. mingw-w64-${{matrix.env}}-cmake
  600. mingw-w64-${{matrix.env}}-openblas
  601. - name: Build using CMake
  602. shell: msys2 {0}
  603. run: |
  604. cmake -B build
  605. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  606. - name: Clean after building using CMake
  607. shell: msys2 {0}
  608. run: |
  609. rm -rf build
  610. - name: Build using CMake w/ OpenBLAS
  611. shell: msys2 {0}
  612. run: |
  613. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  614. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  615. windows-latest-cmake:
  616. runs-on: windows-latest
  617. env:
  618. OPENBLAS_VERSION: 0.3.23
  619. SDE_VERSION: 9.33.0-2024-01-07
  620. VULKAN_VERSION: 1.3.261.1
  621. strategy:
  622. matrix:
  623. include:
  624. - build: 'noavx-x64'
  625. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
  626. - build: 'avx2-x64'
  627. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON'
  628. - build: 'avx-x64'
  629. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF'
  630. - build: 'avx512-x64'
  631. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON'
  632. - build: 'openblas-x64'
  633. 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"'
  634. - build: 'kompute-x64'
  635. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON'
  636. - build: 'vulkan-x64'
  637. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON'
  638. - build: 'llvm-arm64'
  639. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  640. - build: 'msvc-arm64'
  641. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  642. - build: 'llvm-arm64-opencl-adreno'
  643. 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'
  644. steps:
  645. - name: Clone
  646. id: checkout
  647. uses: actions/checkout@v4
  648. with:
  649. fetch-depth: 0
  650. - name: ccache
  651. uses: hendrikmuhs/ccache-action@v1.2.16
  652. with:
  653. key: windows-latest-cmake-${{ matrix.build }}
  654. variant: sccache
  655. evict-old-files: 1d
  656. - name: Clone Kompute submodule
  657. id: clone_kompute
  658. if: ${{ matrix.build == 'kompute-x64' }}
  659. run: |
  660. git submodule update --init ggml/src/ggml-kompute/kompute
  661. - name: Download OpenBLAS
  662. id: get_openblas
  663. if: ${{ matrix.build == 'openblas-x64' }}
  664. run: |
  665. 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"
  666. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  667. mkdir $env:RUNNER_TEMP/openblas
  668. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  669. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  670. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  671. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  672. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  673. - name: Install Vulkan SDK
  674. id: get_vulkan
  675. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  676. run: |
  677. 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"
  678. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  679. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  680. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  681. - name: Install Ninja
  682. id: install_ninja
  683. run: |
  684. choco install ninja
  685. - name: Install OpenCL Headers and Libs
  686. id: install_opencl
  687. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  688. run: |
  689. git clone https://github.com/KhronosGroup/OpenCL-Headers
  690. cd OpenCL-Headers
  691. mkdir build && cd build
  692. cmake .. `
  693. -DBUILD_TESTING=OFF `
  694. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  695. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  696. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  697. cmake --build . --target install
  698. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  699. cd OpenCL-ICD-Loader
  700. mkdir build-arm64-release && cd build-arm64-release
  701. cmake .. `
  702. -A arm64 `
  703. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  704. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  705. cmake --build . --target install --config release
  706. - name: Build
  707. id: cmake_build
  708. run: |
  709. cmake -S . -B build ${{ matrix.defines }}
  710. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  711. - name: Add libopenblas.dll
  712. id: add_libopenblas_dll
  713. if: ${{ matrix.build == 'openblas-x64' }}
  714. run: |
  715. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  716. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  717. - name: Check AVX512F support
  718. id: check_avx512f
  719. if: ${{ matrix.build == 'avx512-x64' }}
  720. continue-on-error: true
  721. run: |
  722. cd build
  723. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  724. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  725. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  726. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  727. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  728. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  729. - name: Test
  730. id: cmake_test
  731. # not all machines have native AVX-512
  732. 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') }}
  733. run: |
  734. cd build
  735. ctest -L main -C Release --verbose --timeout 900
  736. - name: Test (Intel SDE)
  737. id: cmake_test_sde
  738. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  739. run: |
  740. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  741. # for some weird reason windows tar doesn't like sde tar.xz
  742. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  743. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  744. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  745. cd build
  746. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  747. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  748. - name: Determine tag name
  749. id: tag
  750. shell: bash
  751. run: |
  752. BUILD_NUMBER="$(git rev-list --count HEAD)"
  753. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  754. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  755. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  756. else
  757. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  758. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  759. fi
  760. - name: Pack artifacts
  761. id: pack_artifacts
  762. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  763. run: |
  764. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  765. Copy-Item .\examples\run\linenoise.cpp\LICENSE .\build\bin\Release\linenoise.cpp.txt
  766. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  767. - name: Upload artifacts
  768. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  769. uses: actions/upload-artifact@v4
  770. with:
  771. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  772. name: llama-bin-win-${{ matrix.build }}.zip
  773. ubuntu-latest-cmake-cuda:
  774. runs-on: ubuntu-latest
  775. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  776. steps:
  777. - name: Clone
  778. id: checkout
  779. uses: actions/checkout@v4
  780. with:
  781. fetch-depth: 0
  782. - name: Install dependencies
  783. env:
  784. DEBIAN_FRONTEND: noninteractive
  785. run: |
  786. apt update
  787. apt install -y cmake build-essential ninja-build libgomp1 git
  788. - name: ccache
  789. uses: hendrikmuhs/ccache-action@v1.2.16
  790. with:
  791. key: ubuntu-latest-cmake-cuda
  792. evict-old-files: 1d
  793. - name: Build with CMake
  794. run: |
  795. cmake -S . -B build -G Ninja \
  796. -DCMAKE_BUILD_TYPE=Release \
  797. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  798. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  799. -DLLAMA_FATAL_WARNINGS=ON \
  800. -DGGML_NATIVE=OFF \
  801. -DGGML_CUDA=ON
  802. cmake --build build
  803. windows-2019-cmake-cuda:
  804. runs-on: windows-2019
  805. strategy:
  806. matrix:
  807. cuda: ['12.4', '11.7']
  808. build: ['cuda']
  809. steps:
  810. - name: Clone
  811. id: checkout
  812. uses: actions/checkout@v4
  813. with:
  814. fetch-depth: 0
  815. - name: Install ccache
  816. uses: hendrikmuhs/ccache-action@v1.2.16
  817. with:
  818. key: ${{ github.job }}-${{ matrix.cuda }}-${{ matrix.build }}
  819. variant: sccache
  820. evict-old-files: 1d
  821. - name: Install Cuda Toolkit 11.7
  822. if: ${{ matrix.cuda == '11.7' }}
  823. run: |
  824. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  825. choco install unzip -y
  826. 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"
  827. 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"
  828. 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"
  829. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-11.7.4.6-archive.zip"
  830. 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"
  831. 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"
  832. 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"
  833. 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"
  834. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  835. 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
  836. 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
  837. 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
  838. 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
  839. 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
  840. 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
  841. 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
  842. 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
  843. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  844. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  845. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  846. echo "CUDA_PATH_V11_7=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  847. - name: Install Cuda Toolkit 12.4
  848. if: ${{ matrix.cuda == '12.4' }}
  849. run: |
  850. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  851. choco install unzip -y
  852. 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"
  853. 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"
  854. 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"
  855. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.5.8-archive.zip"
  856. 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"
  857. 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"
  858. 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"
  859. 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"
  860. 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"
  861. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  862. 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
  863. 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
  864. 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
  865. 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
  866. 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
  867. 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
  868. 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
  869. 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
  870. 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
  871. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  872. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  873. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  874. echo "CUDA_PATH_V12_4=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  875. - name: Install Ninja
  876. id: install_ninja
  877. run: |
  878. choco install ninja
  879. - name: Build
  880. id: cmake_build
  881. shell: cmd
  882. run: |
  883. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  884. cmake -S . -B build -G "Ninja Multi-Config" ^
  885. -DLLAMA_BUILD_SERVER=ON ^
  886. -DGGML_NATIVE=OFF ^
  887. -DGGML_CUDA=ON ^
  888. -DGGML_RPC=ON
  889. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  890. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  891. cmake --build build --config Release
  892. - name: Determine tag name
  893. id: tag
  894. shell: bash
  895. run: |
  896. BUILD_NUMBER="$(git rev-list --count HEAD)"
  897. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  898. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  899. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  900. else
  901. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  902. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  903. fi
  904. - name: Pack artifacts
  905. id: pack_artifacts
  906. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  907. run: |
  908. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  909. - name: Upload artifacts
  910. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  911. uses: actions/upload-artifact@v4
  912. with:
  913. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  914. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  915. - name: Copy and pack Cuda runtime
  916. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
  917. run: |
  918. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  919. $dst='.\build\bin\cudart\'
  920. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  921. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  922. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  923. - name: Upload Cuda runtime
  924. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  925. uses: actions/upload-artifact@v4
  926. with:
  927. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  928. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  929. windows-latest-cmake-sycl:
  930. runs-on: windows-latest
  931. defaults:
  932. run:
  933. shell: bash
  934. env:
  935. 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
  936. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  937. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  938. steps:
  939. - name: Clone
  940. id: checkout
  941. uses: actions/checkout@v4
  942. with:
  943. fetch-depth: 0
  944. - name: ccache
  945. uses: hendrikmuhs/ccache-action@v1.2.16
  946. with:
  947. key: windows-latest-cmake-sycl
  948. variant: sccache
  949. evict-old-files: 1d
  950. - name: Install
  951. run: |
  952. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  953. - name: Build
  954. id: cmake_build
  955. run: examples/sycl/win-build-sycl.bat
  956. - name: Determine tag name
  957. id: tag
  958. shell: bash
  959. run: |
  960. BUILD_NUMBER="$(git rev-list --count HEAD)"
  961. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  962. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  963. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  964. else
  965. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  966. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  967. fi
  968. - name: Build the release package
  969. id: pack_artifacts
  970. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  971. run: |
  972. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  973. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
  974. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  975. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  976. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
  977. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
  978. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
  979. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
  980. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
  981. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  982. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  983. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  984. cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
  985. cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
  986. echo "cp oneAPI running time dll files to ./build/bin done"
  987. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  988. - name: Upload the release package
  989. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  990. uses: actions/upload-artifact@v4
  991. with:
  992. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  993. name: llama-bin-win-sycl-x64.zip
  994. windows-latest-cmake-hip:
  995. if: ${{ github.event.inputs.create_release != 'true' }}
  996. runs-on: windows-latest
  997. steps:
  998. - name: Clone
  999. id: checkout
  1000. uses: actions/checkout@v4
  1001. - name: Install
  1002. id: depends
  1003. run: |
  1004. $ErrorActionPreference = "Stop"
  1005. write-host "Downloading AMD HIP SDK Installer"
  1006. 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"
  1007. write-host "Installing AMD HIP SDK"
  1008. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1009. write-host "Completed AMD HIP SDK installation"
  1010. - name: Verify ROCm
  1011. id: verify
  1012. run: |
  1013. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1014. - name: Install ccache
  1015. uses: hendrikmuhs/ccache-action@v1.2.16
  1016. with:
  1017. key: ${{ github.job }}
  1018. variant: sccache
  1019. evict-old-files: 1d
  1020. - name: Build
  1021. id: cmake_build
  1022. run: |
  1023. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1024. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1025. cmake -G "Unix Makefiles" -B build -S . `
  1026. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1027. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1028. -DCMAKE_BUILD_TYPE=Release `
  1029. -DGGML_HIP=ON `
  1030. -DGGML_RPC=ON
  1031. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1032. windows-latest-cmake-hip-release:
  1033. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1034. runs-on: windows-latest
  1035. strategy:
  1036. matrix:
  1037. gpu_target: [gfx1100, gfx1101, gfx1030]
  1038. steps:
  1039. - name: Clone
  1040. id: checkout
  1041. uses: actions/checkout@v4
  1042. with:
  1043. fetch-depth: 0
  1044. - name: ccache
  1045. uses: hendrikmuhs/ccache-action@v1.2.16
  1046. with:
  1047. key: windows-latest-cmake-hip-release
  1048. variant: sccache
  1049. evict-old-files: 1d
  1050. - name: Install
  1051. id: depends
  1052. run: |
  1053. $ErrorActionPreference = "Stop"
  1054. write-host "Downloading AMD HIP SDK Installer"
  1055. 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"
  1056. write-host "Installing AMD HIP SDK"
  1057. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1058. write-host "Completed AMD HIP SDK installation"
  1059. - name: Verify ROCm
  1060. id: verify
  1061. run: |
  1062. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1063. - name: Build
  1064. id: cmake_build
  1065. run: |
  1066. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1067. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1068. cmake -G "Unix Makefiles" -B build -S . `
  1069. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1070. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1071. -DCMAKE_BUILD_TYPE=Release `
  1072. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  1073. -DGGML_HIP=ON `
  1074. -DGGML_RPC=ON
  1075. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1076. md "build\bin\rocblas\library\"
  1077. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  1078. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  1079. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  1080. - name: Determine tag name
  1081. id: tag
  1082. shell: bash
  1083. run: |
  1084. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1085. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1086. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1087. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1088. else
  1089. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1090. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1091. fi
  1092. - name: Pack artifacts
  1093. id: pack_artifacts
  1094. run: |
  1095. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  1096. - name: Upload artifacts
  1097. uses: actions/upload-artifact@v4
  1098. with:
  1099. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1100. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1101. ios-xcode-build:
  1102. runs-on: macos-latest
  1103. steps:
  1104. - name: Checkout code
  1105. uses: actions/checkout@v4
  1106. - name: Build
  1107. id: cmake_build
  1108. run: |
  1109. sysctl -a
  1110. mkdir build
  1111. cd build
  1112. cmake -G Xcode .. \
  1113. -DGGML_METAL_USE_BF16=ON \
  1114. -DGGML_METAL_EMBED_LIBRARY=ON \
  1115. -DLLAMA_BUILD_EXAMPLES=OFF \
  1116. -DLLAMA_BUILD_TESTS=OFF \
  1117. -DLLAMA_BUILD_SERVER=OFF \
  1118. -DCMAKE_SYSTEM_NAME=iOS \
  1119. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  1120. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  1121. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  1122. sudo cmake --install . --config Release
  1123. - name: xcodebuild for swift package
  1124. id: xcodebuild
  1125. run: |
  1126. xcodebuild -scheme llama-Package -destination 'generic/platform=iOS'
  1127. - name: Build Xcode project
  1128. 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
  1129. android-build:
  1130. runs-on: ubuntu-latest
  1131. steps:
  1132. - name: Clone
  1133. uses: actions/checkout@v4
  1134. - name: ccache
  1135. uses: hendrikmuhs/ccache-action@v1.2.16
  1136. with:
  1137. key: android-build
  1138. evict-old-files: 1d
  1139. - name: Set up JDK
  1140. uses: actions/setup-java@v3
  1141. with:
  1142. java-version: 17
  1143. distribution: zulu
  1144. - name: Setup Android SDK
  1145. uses: android-actions/setup-android@v3
  1146. with:
  1147. log-accepted-android-sdk-licenses: false
  1148. - name: Build
  1149. run: |
  1150. cd examples/llama.android
  1151. ./gradlew build --no-daemon
  1152. release:
  1153. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1154. runs-on: ubuntu-latest
  1155. needs:
  1156. - ubuntu-cpu-cmake
  1157. - windows-latest-cmake
  1158. - windows-2019-cmake-cuda
  1159. - windows-latest-cmake-hip-release
  1160. - macOS-latest-cmake-arm64
  1161. - macOS-latest-cmake-x64
  1162. steps:
  1163. - name: Clone
  1164. id: checkout
  1165. uses: actions/checkout@v4
  1166. with:
  1167. fetch-depth: 0
  1168. - name: ccache
  1169. uses: hendrikmuhs/ccache-action@v1.2.16
  1170. with:
  1171. key: release
  1172. evict-old-files: 1d
  1173. - name: Determine tag name
  1174. id: tag
  1175. shell: bash
  1176. run: |
  1177. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1178. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1179. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1180. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1181. else
  1182. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1183. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1184. fi
  1185. - name: Download artifacts
  1186. id: download-artifact
  1187. uses: actions/download-artifact@v4
  1188. with:
  1189. path: ./artifact
  1190. - name: Move artifacts
  1191. id: move_artifacts
  1192. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  1193. - name: Create release
  1194. id: create_release
  1195. uses: ggml-org/action-create-release@v1
  1196. env:
  1197. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1198. with:
  1199. tag_name: ${{ steps.tag.outputs.name }}
  1200. - name: Upload release
  1201. id: upload_release
  1202. uses: actions/github-script@v3
  1203. with:
  1204. github-token: ${{secrets.GITHUB_TOKEN}}
  1205. script: |
  1206. const path = require('path');
  1207. const fs = require('fs');
  1208. const release_id = '${{ steps.create_release.outputs.id }}';
  1209. for (let file of await fs.readdirSync('./artifact/release')) {
  1210. if (path.extname(file) === '.zip') {
  1211. console.log('uploadReleaseAsset', file);
  1212. await github.repos.uploadReleaseAsset({
  1213. owner: context.repo.owner,
  1214. repo: context.repo.repo,
  1215. release_id: release_id,
  1216. name: file,
  1217. data: await fs.readFileSync(`./artifact/release/${file}`)
  1218. });
  1219. }
  1220. }
  1221. # ubuntu-latest-gcc:
  1222. # runs-on: ubuntu-latest
  1223. #
  1224. # strategy:
  1225. # matrix:
  1226. # build: [Debug, Release]
  1227. #
  1228. # steps:
  1229. # - name: Clone
  1230. # uses: actions/checkout@v4
  1231. #
  1232. # - name: Dependencies
  1233. # run: |
  1234. # sudo apt-get update
  1235. # sudo apt-get install build-essential
  1236. # sudo apt-get install cmake
  1237. #
  1238. # - name: Configure
  1239. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1240. #
  1241. # - name: Build
  1242. # run: |
  1243. # make
  1244. #
  1245. # ubuntu-latest-clang:
  1246. # runs-on: ubuntu-latest
  1247. #
  1248. # strategy:
  1249. # matrix:
  1250. # build: [Debug, Release]
  1251. #
  1252. # steps:
  1253. # - name: Clone
  1254. # uses: actions/checkout@v4
  1255. #
  1256. # - name: Dependencies
  1257. # run: |
  1258. # sudo apt-get update
  1259. # sudo apt-get install build-essential
  1260. # sudo apt-get install cmake
  1261. #
  1262. # - name: Configure
  1263. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1264. #
  1265. # - name: Build
  1266. # run: |
  1267. # make
  1268. #
  1269. # ubuntu-latest-gcc-sanitized:
  1270. # runs-on: ubuntu-latest
  1271. #
  1272. # strategy:
  1273. # matrix:
  1274. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1275. #
  1276. # steps:
  1277. # - name: Clone
  1278. # uses: actions/checkout@v4
  1279. #
  1280. # - name: Dependencies
  1281. # run: |
  1282. # sudo apt-get update
  1283. # sudo apt-get install build-essential
  1284. # sudo apt-get install cmake
  1285. #
  1286. # - name: Configure
  1287. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1288. #
  1289. # - name: Build
  1290. # run: |
  1291. # make
  1292. #
  1293. # windows:
  1294. # runs-on: windows-latest
  1295. #
  1296. # strategy:
  1297. # matrix:
  1298. # build: [Release]
  1299. # arch: [Win32, x64]
  1300. # include:
  1301. # - arch: Win32
  1302. # s2arc: x86
  1303. # - arch: x64
  1304. # s2arc: x64
  1305. #
  1306. # steps:
  1307. # - name: Clone
  1308. # uses: actions/checkout@v4
  1309. #
  1310. # - name: Add msbuild to PATH
  1311. # uses: microsoft/setup-msbuild@v1
  1312. #
  1313. # - name: Configure
  1314. # run: >
  1315. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1316. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1317. #
  1318. # - name: Build
  1319. # run: |
  1320. # cd ./build
  1321. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1322. #
  1323. # - name: Upload binaries
  1324. # uses: actions/upload-artifact@v4
  1325. # with:
  1326. # name: llama-bin-${{ matrix.arch }}
  1327. # path: build/bin/${{ matrix.build }}
  1328. #
  1329. # windows-blas:
  1330. # runs-on: windows-latest
  1331. #
  1332. # strategy:
  1333. # matrix:
  1334. # build: [Release]
  1335. # arch: [Win32, x64]
  1336. # blas: [ON]
  1337. # include:
  1338. # - arch: Win32
  1339. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1340. # s2arc: x86
  1341. # - arch: x64
  1342. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1343. # s2arc: x64
  1344. #
  1345. # steps:
  1346. # - name: Clone
  1347. # uses: actions/checkout@v4
  1348. #
  1349. # - name: Add msbuild to PATH
  1350. # uses: microsoft/setup-msbuild@v1
  1351. #
  1352. # - name: Fetch OpenBLAS
  1353. # if: matrix.blas == 'ON'
  1354. # run: |
  1355. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1356. # 7z x blas.zip -oblas -y
  1357. # copy blas/include/cblas.h .
  1358. # copy blas/include/openblas_config.h .
  1359. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1360. #
  1361. # - name: Configure
  1362. # run: >
  1363. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1364. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1365. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1366. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1367. #
  1368. # - name: Build
  1369. # run: |
  1370. # cd ./build
  1371. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1372. #
  1373. # - name: Copy libopenblas.dll
  1374. # if: matrix.blas == 'ON'
  1375. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1376. #
  1377. # - name: Upload binaries
  1378. # if: matrix.blas == 'ON'
  1379. # uses: actions/upload-artifact@v4
  1380. # with:
  1381. # name: llama-blas-bin-${{ matrix.arch }}
  1382. # path: build/bin/${{ matrix.build }}
  1383. #
  1384. # emscripten:
  1385. # runs-on: ubuntu-latest
  1386. #
  1387. # strategy:
  1388. # matrix:
  1389. # build: [Release]
  1390. #
  1391. # steps:
  1392. # - name: Clone
  1393. # uses: actions/checkout@v4
  1394. #
  1395. # - name: Dependencies
  1396. # run: |
  1397. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1398. # tar -xvf master.tar.gz
  1399. # emsdk-master/emsdk update
  1400. # emsdk-master/emsdk install latest
  1401. # emsdk-master/emsdk activate latest
  1402. #
  1403. # - name: Configure
  1404. # run: echo "tmp"
  1405. #
  1406. # - name: Build
  1407. # run: |
  1408. # pushd emsdk-master
  1409. # source ./emsdk_env.sh
  1410. # popd
  1411. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1412. # make
  1413. openEuler-latest-cmake-cann:
  1414. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  1415. defaults:
  1416. run:
  1417. shell: bash -el {0}
  1418. runs-on: ubuntu-24.04-arm
  1419. strategy:
  1420. matrix:
  1421. cann:
  1422. - '8.0.rc3.beta1-910b-openeuler22.03-py3.10'
  1423. device:
  1424. - 'ascend910b3'
  1425. build:
  1426. - 'Release'
  1427. container: ascendai/cann:${{ matrix.cann }}
  1428. steps:
  1429. - name: Checkout
  1430. uses: actions/checkout@v4
  1431. - name: Dependencies
  1432. run: |
  1433. yum update -y
  1434. yum install -y git gcc gcc-c++ make cmake
  1435. - name: Build
  1436. run: |
  1437. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  1438. cmake -S . -B build \
  1439. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  1440. -DGGML_CANN=on \
  1441. -DSOC_TYPE=${{ matrix.device }}
  1442. cmake --build build -j $(nproc)