From 6080f6e78af60081c33cec2f209d3ec3444cccbf Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Fri, 4 Apr 2025 23:49:35 +0200 Subject: [PATCH 01/15] cmake : enable curl by default --- .devops/cpu.Dockerfile | 4 ++-- .devops/cuda.Dockerfile | 2 +- .devops/intel.Dockerfile | 2 +- .devops/musa.Dockerfile | 2 +- .devops/rocm.Dockerfile | 2 +- .github/workflows/bench.yml.disabled | 1 - .github/workflows/build.yml | 3 --- .github/workflows/server.yml | 5 +---- CMakeLists.txt | 2 +- examples/server/tests/README.md | 2 +- 10 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.devops/cpu.Dockerfile b/.devops/cpu.Dockerfile index 522ee8147d63a..aa2aa0312010e 100644 --- a/.devops/cpu.Dockerfile +++ b/.devops/cpu.Dockerfile @@ -14,9 +14,9 @@ WORKDIR /app COPY . . RUN if [ "$TARGETARCH" = "amd64" ]; then \ - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON; \ + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON; \ elif [ "$TARGETARCH" = "arm64" ]; then \ - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=${GGML_CPU_ARM_ARCH}; \ + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=${GGML_CPU_ARM_ARCH}; \ else \ echo "Unsupported architecture"; \ exit 1; \ diff --git a/.devops/cuda.Dockerfile b/.devops/cuda.Dockerfile index 0bc4e7ee13f66..a196111e61d62 100644 --- a/.devops/cuda.Dockerfile +++ b/.devops/cuda.Dockerfile @@ -21,7 +21,7 @@ COPY . . RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \ fi && \ - cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ + cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release -j$(nproc) RUN mkdir -p /app/lib && \ diff --git a/.devops/intel.Dockerfile b/.devops/intel.Dockerfile index af783f5e998eb..e2b381766f196 100644 --- a/.devops/intel.Dockerfile +++ b/.devops/intel.Dockerfile @@ -17,7 +17,7 @@ RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \ && export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \ fi && \ echo "Building with dynamic libs" && \ - cmake -B build -DGGML_NATIVE=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \ + cmake -B build -DGGML_NATIVE=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ${OPT_SYCL_F16} && \ cmake --build build --config Release -j$(nproc) RUN mkdir -p /app/lib && \ diff --git a/.devops/musa.Dockerfile b/.devops/musa.Dockerfile index 1e87737abfb71..e8297c6948c5c 100644 --- a/.devops/musa.Dockerfile +++ b/.devops/musa.Dockerfile @@ -35,7 +35,7 @@ COPY . . RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \ fi && \ - cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ + cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release -j$(nproc) RUN mkdir -p /app/lib && \ diff --git a/.devops/rocm.Dockerfile b/.devops/rocm.Dockerfile index 48e7e6aaa5b77..66687a25ba068 100644 --- a/.devops/rocm.Dockerfile +++ b/.devops/rocm.Dockerfile @@ -40,7 +40,7 @@ WORKDIR /app COPY . . RUN HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \ - cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=$ROCM_DOCKER_ARCH -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON \ + cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=$ROCM_DOCKER_ARCH -DCMAKE_BUILD_TYPE=Release \ && cmake --build build --config Release -j$(nproc) RUN mkdir -p /app/lib \ diff --git a/.github/workflows/bench.yml.disabled b/.github/workflows/bench.yml.disabled index 0370c8943fa0e..75d2714792891 100644 --- a/.github/workflows/bench.yml.disabled +++ b/.github/workflows/bench.yml.disabled @@ -104,7 +104,6 @@ jobs: cmake -B build \ -DGGML_NATIVE=OFF \ -DLLAMA_BUILD_SERVER=ON \ - -DLLAMA_CURL=ON \ -DLLAMA_CUBLAS=ON \ -DCUDAToolkit_ROOT=/usr/local/cuda \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc2a4c0566840..e98a526ea5622 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,6 @@ jobs: cmake -B build \ -DCMAKE_BUILD_RPATH="@loader_path" \ -DLLAMA_FATAL_WARNINGS=ON \ - -DLLAMA_CURL=ON \ -DGGML_METAL_USE_BF16=ON \ -DGGML_METAL_EMBED_LIBRARY=ON \ -DGGML_RPC=ON @@ -133,7 +132,6 @@ jobs: cmake -B build \ -DCMAKE_BUILD_RPATH="@loader_path" \ -DLLAMA_FATAL_WARNINGS=ON \ - -DLLAMA_CURL=ON \ -DGGML_METAL=OFF \ -DGGML_RPC=ON cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) @@ -207,7 +205,6 @@ jobs: run: | cmake -B build \ -DLLAMA_FATAL_WARNINGS=ON \ - -DLLAMA_CURL=ON \ -DGGML_RPC=ON cmake --build build --config Release -j $(nproc) diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 092c928bdf552..67178e45cf329 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -129,7 +129,6 @@ jobs: cmake -B build \ -DGGML_NATIVE=OFF \ -DLLAMA_BUILD_SERVER=ON \ - -DLLAMA_CURL=ON \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \ -DGGML_OPENMP=OFF ; @@ -142,7 +141,6 @@ jobs: cmake -B build \ -DGGML_NATIVE=OFF \ -DLLAMA_BUILD_SERVER=ON \ - -DLLAMA_CURL=ON \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ; cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server @@ -154,7 +152,6 @@ jobs: cmake -B build \ -DGGML_NATIVE=OFF \ -DLLAMA_BUILD_SERVER=ON \ - -DLLAMA_CURL=ON \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ; cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server @@ -205,7 +202,7 @@ jobs: - name: Build id: cmake_build run: | - cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include" + cmake -B build -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include" cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server - name: Python setup diff --git a/CMakeLists.txt b/CMakeLists.txt index 23cfbce5ae566..f3769d43aa20c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,7 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE}) option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE}) # 3rd party libs -option(LLAMA_CURL "llama: use libcurl to download model from an URL" OFF) +option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON) option(LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF) # Required for relocatable CMake package diff --git a/examples/server/tests/README.md b/examples/server/tests/README.md index 12816bfa8705b..652dea0382ce1 100644 --- a/examples/server/tests/README.md +++ b/examples/server/tests/README.md @@ -17,7 +17,7 @@ To mitigate it, you can increase values in `n_predict`, `kv_size`. ```shell cd ../../.. -cmake -B build -DLLAMA_CURL=ON +cmake -B build cmake --build build --target llama-server ``` From 645579667b4a3d14dc44ae45f5da25d7e27aa786 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 00:03:36 +0200 Subject: [PATCH 02/15] no curl if no examples --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3769d43aa20c..7942d8abe3216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,11 @@ add_subdirectory(src) # utils, programs, examples and tests # +if (NOT LLAMA_BUILD_EXAMPLES) + # curl is only needed for examples + set(LLAMA_CURL OFF) +endif() + if (LLAMA_BUILD_COMMON) add_subdirectory(common) endif() From 2cc893bc93aab3b3c89499303ad1a2a43fa1d484 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 00:03:40 +0200 Subject: [PATCH 03/15] fix build --- .github/workflows/build.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e98a526ea5622..3dd4b27ac881a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,7 @@ jobs: continue-on-error: true run: | brew update + brew install curl - name: Build id: cmake_build @@ -122,6 +123,7 @@ jobs: continue-on-error: true run: | brew update + brew install curl - name: Build id: cmake_build @@ -278,7 +280,7 @@ jobs: id: depends run: | sudo apt-get update - sudo apt-get install build-essential + sudo apt-get install build-essential libcurl4-openssl-dev - name: Build id: cmake_build @@ -319,7 +321,7 @@ jobs: id: depends run: | sudo apt-get update - sudo apt-get install build-essential + sudo apt-get install build-essential libcurl4-openssl-dev - name: Build id: cmake_build @@ -357,7 +359,7 @@ jobs: id: depends run: | sudo apt-get update - sudo apt-get install build-essential + sudo apt-get install build-essential libcurl4-openssl-dev - name: Build id: cmake_build @@ -394,7 +396,7 @@ jobs: wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list sudo apt-get update -y - sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk + sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libcurl4-openssl-dev - name: Build id: cmake_build @@ -451,7 +453,7 @@ jobs: id: depends run: | sudo apt-get update - sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev + sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev libcurl4-openssl-dev - name: ccache uses: hendrikmuhs/ccache-action@v1.2.16 @@ -527,7 +529,7 @@ jobs: shell: bash run: | sudo apt update - sudo apt install intel-oneapi-compiler-dpcpp-cpp + sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev - name: install oneAPI MKL library shell: bash @@ -575,7 +577,7 @@ jobs: shell: bash run: | sudo apt update - sudo apt install intel-oneapi-compiler-dpcpp-cpp + sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev - name: install oneAPI MKL library shell: bash @@ -987,7 +989,7 @@ jobs: DEBIAN_FRONTEND: noninteractive run: | apt update - apt install -y cmake build-essential ninja-build libgomp1 git + apt install -y cmake build-essential ninja-build libgomp1 git libcurl4-openssl-dev - name: ccache uses: hendrikmuhs/ccache-action@v1.2.16 From 793074c996c653122dc68b6b33273bf38deb85e5 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 00:07:45 +0200 Subject: [PATCH 04/15] fix build-linux-cross --- .github/workflows/build-linux-cross.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml index d4176fef9cee2..92a519e604917 100644 --- a/.github/workflows/build-linux-cross.yml +++ b/.github/workflows/build-linux-cross.yml @@ -19,7 +19,8 @@ jobs: sudo apt-get install -y --no-install-recommends \ build-essential \ gcc-14-riscv64-linux-gnu \ - g++-14-riscv64-linux-gnu + g++-14-riscv64-linux-gnu \ + libcurl4-openssl-dev - name: Build run: | @@ -59,7 +60,8 @@ jobs: glslc \ gcc-14-riscv64-linux-gnu \ g++-14-riscv64-linux-gnu \ - libvulkan-dev:riscv64 + libvulkan-dev:riscv64 \ + libcurl4-openssl-dev - name: Build run: | @@ -99,7 +101,8 @@ jobs: build-essential \ glslc \ crossbuild-essential-arm64 \ - libvulkan-dev:arm64 + libvulkan-dev:arm64 \ + libcurl4-openssl-dev - name: Build run: | From 2238e7064646273810a1727867d9533383b5512f Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 12:27:34 +0200 Subject: [PATCH 05/15] add windows-setup-curl --- .github/actions/windows-setup-curl.yml | 28 +++++++++++++++++++++++++ .github/workflows/build-linux-cross.yml | 6 ++++++ .github/workflows/server.yml | 15 +++++++------ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 .github/actions/windows-setup-curl.yml diff --git a/.github/actions/windows-setup-curl.yml b/.github/actions/windows-setup-curl.yml new file mode 100644 index 0000000000000..7b94ca12110d3 --- /dev/null +++ b/.github/actions/windows-setup-curl.yml @@ -0,0 +1,28 @@ +name: 'Windows - Setup CURL' +description: 'Composite action, to be reused in other workflow' +inputs: + curl_version: + description: 'CURL version' + required: false + default: '8.6.0_6' +outputs: + curl_path: + description: "Path to the downloaded libcurl" + value: ${{ steps.get_libcurl.outputs.curl_path }} + curl_cmake_arg: + description: "Arguments to be added to cmake command which allow finding libcurl" + value: ${{ steps.get_libcurl.outputs.curl_cmake_arg }} + +runs: + using: "composite" + steps: + - name: libCURL + id: get_libcurl + env: + CURL_VERSION: 8.6.0_6 + run: | + curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip" + mkdir $env:RUNNER_TEMP/libcurl + tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl + echo "curl_path=$env:RUNNER_TEMP/libcurl" >> $env:GITHUB_OUTPUT + echo "curl_cmake_arg=' -DCURL_LIBRARY=\`"$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a\`" -DCURL_INCLUDE_DIR=\`"$env:RUNNER_TEMP/libcurl/include\`" '" >> $env:GITHUB_OUTPUT diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml index 92a519e604917..255e7db2287d6 100644 --- a/.github/workflows/build-linux-cross.yml +++ b/.github/workflows/build-linux-cross.yml @@ -23,9 +23,11 @@ jobs: libcurl4-openssl-dev - name: Build + # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_OPENMP=OFF \ + -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \ @@ -64,10 +66,12 @@ jobs: libcurl4-openssl-dev - name: Build + # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_VULKAN=ON \ -DGGML_OPENMP=OFF \ + -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \ @@ -105,10 +109,12 @@ jobs: libcurl4-openssl-dev - name: Build + # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_VULKAN=ON \ -DGGML_OPENMP=OFF \ + -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \ diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 67178e45cf329..e10e260a53d46 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -192,17 +192,14 @@ jobs: - name: libCURL id: get_libcurl - env: - CURL_VERSION: 8.6.0_6 - run: | - curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip" - mkdir $env:RUNNER_TEMP/libcurl - tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl + uses: ./.github/actions/windows-setup-curl.yml - name: Build id: cmake_build + env: + CURL_CMAKE_ARG: ${{ steps.get_libcurl.outputs.curl_cmake_arg }} run: | - cmake -B build -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include" + cmake -B build $env:CURL_CMAKE_ARG cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server - name: Python setup @@ -218,8 +215,10 @@ jobs: - name: Copy Libcurl id: prepare_libcurl + env: + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | - cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll + cp $env:CURL_PATH/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll - name: Tests id: server_integration_tests From 707f2b9395fde9f92bae61f2e899e21dc7777f41 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 12:30:21 +0200 Subject: [PATCH 06/15] fix --- .../{windows-setup-curl.yml => windows-setup-curl/action.yml} | 0 .github/workflows/server.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/actions/{windows-setup-curl.yml => windows-setup-curl/action.yml} (100%) diff --git a/.github/actions/windows-setup-curl.yml b/.github/actions/windows-setup-curl/action.yml similarity index 100% rename from .github/actions/windows-setup-curl.yml rename to .github/actions/windows-setup-curl/action.yml diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index e10e260a53d46..ebf0c9ee0279e 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -192,7 +192,7 @@ jobs: - name: libCURL id: get_libcurl - uses: ./.github/actions/windows-setup-curl.yml + uses: ./.github/actions/windows-setup-curl - name: Build id: cmake_build From 79509cc1d59bb1c576d01fd040f0da3eede9d6c5 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 12:32:10 +0200 Subject: [PATCH 07/15] shell --- .github/actions/windows-setup-curl/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/windows-setup-curl/action.yml b/.github/actions/windows-setup-curl/action.yml index 7b94ca12110d3..89b39adfe71e8 100644 --- a/.github/actions/windows-setup-curl/action.yml +++ b/.github/actions/windows-setup-curl/action.yml @@ -18,6 +18,7 @@ runs: steps: - name: libCURL id: get_libcurl + shell: powershell env: CURL_VERSION: 8.6.0_6 run: | From 21c423eefdb8694dab67a86f57ef05a6f241de2c Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 12:37:01 +0200 Subject: [PATCH 08/15] fix path --- .github/actions/windows-setup-curl/action.yml | 6 +----- .github/workflows/server.yml | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/actions/windows-setup-curl/action.yml b/.github/actions/windows-setup-curl/action.yml index 89b39adfe71e8..5d76da3d79ac5 100644 --- a/.github/actions/windows-setup-curl/action.yml +++ b/.github/actions/windows-setup-curl/action.yml @@ -9,9 +9,6 @@ outputs: curl_path: description: "Path to the downloaded libcurl" value: ${{ steps.get_libcurl.outputs.curl_path }} - curl_cmake_arg: - description: "Arguments to be added to cmake command which allow finding libcurl" - value: ${{ steps.get_libcurl.outputs.curl_cmake_arg }} runs: using: "composite" @@ -20,10 +17,9 @@ runs: id: get_libcurl shell: powershell env: - CURL_VERSION: 8.6.0_6 + CURL_VERSION: ${{ inputs.curl_version }} run: | curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip" mkdir $env:RUNNER_TEMP/libcurl tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl echo "curl_path=$env:RUNNER_TEMP/libcurl" >> $env:GITHUB_OUTPUT - echo "curl_cmake_arg=' -DCURL_LIBRARY=\`"$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a\`" -DCURL_INCLUDE_DIR=\`"$env:RUNNER_TEMP/libcurl/include\`" '" >> $env:GITHUB_OUTPUT diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index ebf0c9ee0279e..6c9b5132276fe 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -197,9 +197,9 @@ jobs: - name: Build id: cmake_build env: - CURL_CMAKE_ARG: ${{ steps.get_libcurl.outputs.curl_cmake_arg }} + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | - cmake -B build $env:CURL_CMAKE_ARG + cmake -B build -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server - name: Python setup From 9bf42cd4816a393dddf3123fe7c7940ffdd11023 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 12:49:30 +0200 Subject: [PATCH 09/15] fix windows-latest-cmake* --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dd4b27ac881a..ee511cfc328c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -898,10 +898,17 @@ jobs: -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release" cmake --build build-arm64-release --target install --config release + - name: libCURL + id: get_libcurl + uses: ./.github/actions/windows-setup-curl + - name: Build id: cmake_build + env: + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | - cmake -S . -B build ${{ matrix.defines }} + cmake -S . -B build ${{ matrix.defines }} ` + -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} - name: Add libopenblas.dll @@ -1091,16 +1098,23 @@ jobs: run: | choco install ninja + - name: libCURL + id: get_libcurl + uses: ./.github/actions/windows-setup-curl + - name: Build id: cmake_build shell: cmd + env: + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cmake -S . -B build -G "Ninja Multi-Config" ^ -DLLAMA_BUILD_SERVER=ON ^ -DGGML_NATIVE=OFF ^ -DGGML_CUDA=ON ^ - -DGGML_RPC=ON + -DGGML_RPC=ON ^ + -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include" set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1 cmake --build build --config Release -j %NINJA_JOBS% -t ggml cmake --build build --config Release @@ -1261,8 +1275,14 @@ jobs: key: ${{ github.job }} evict-old-files: 1d + - name: libCURL + id: get_libcurl + uses: ./.github/actions/windows-setup-curl + - name: Build id: cmake_build + env: + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path) $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}" @@ -1273,9 +1293,11 @@ jobs: -DCMAKE_BUILD_TYPE=Release ` -DGGML_HIP=ON ` -DGGML_HIP_ROCWMMA_FATTN=ON ` - -DGGML_RPC=ON + -DGGML_RPC=ON ` + -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" cmake --build build -j ${env:NUMBER_OF_PROCESSORS} + # TODO: reuse windows-latest-cmake-hip instead of duplicating this job windows-latest-cmake-hip-release: if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} runs-on: windows-latest @@ -1317,8 +1339,14 @@ jobs: run: | & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version + - name: libCURL + id: get_libcurl + uses: ./.github/actions/windows-setup-curl + - name: Build id: cmake_build + env: + CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }} run: | $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path) $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}" @@ -1330,7 +1358,8 @@ jobs: -DAMDGPU_TARGETS=${{ matrix.gpu_target }} ` -DGGML_HIP_ROCWMMA_FATTN=ON ` -DGGML_HIP=ON ` - -DGGML_RPC=ON + -DGGML_RPC=ON ` + -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" cmake --build build -j ${env:NUMBER_OF_PROCESSORS} md "build\bin\rocblas\library\" cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\" From a8a7ed94c50fe32be55505e5c7ef81c7b09fceda Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 13:02:41 +0200 Subject: [PATCH 10/15] run: include_directories --- examples/run/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/run/CMakeLists.txt b/examples/run/CMakeLists.txt index cd6b0520e08bb..50186fde0ee61 100644 --- a/examples/run/CMakeLists.txt +++ b/examples/run/CMakeLists.txt @@ -1,5 +1,8 @@ set(TARGET llama-run) add_executable(${TARGET} run.cpp linenoise.cpp/linenoise.cpp) +if (LLAMA_CURL) + include_directories(${CURL_INCLUDE_DIRS}) +endif () install(TARGETS ${TARGET} RUNTIME) target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT}) target_compile_features(${TARGET} PRIVATE cxx_std_17) From a9637055a89f3f689f43dc7fb9246a21c54c6c47 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 13:21:30 +0200 Subject: [PATCH 11/15] LLAMA_RUN_EXTRA_LIBS --- examples/run/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/run/CMakeLists.txt b/examples/run/CMakeLists.txt index 50186fde0ee61..7cff188ca69f0 100644 --- a/examples/run/CMakeLists.txt +++ b/examples/run/CMakeLists.txt @@ -1,8 +1,16 @@ set(TARGET llama-run) add_executable(${TARGET} run.cpp linenoise.cpp/linenoise.cpp) + +# TODO: avoid copying this code block from common/CMakeLists.txt +set(LLAMA_RUN_EXTRA_LIBS "") if (LLAMA_CURL) + find_package(CURL REQUIRED) + target_compile_definitions(${TARGET} PUBLIC LLAMA_USE_CURL) include_directories(${CURL_INCLUDE_DIRS}) + find_library(CURL_LIBRARY curl REQUIRED) + set(LLAMA_RUN_EXTRA_LIBS ${LLAMA_RUN_EXTRA_LIBS} ${CURL_LIBRARY}) endif () + install(TARGETS ${TARGET} RUNTIME) -target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${LLAMA_RUN_EXTRA_LIBS}) target_compile_features(${TARGET} PRIVATE cxx_std_17) From 04eddb8f10fcf218f792b59d64a878199041db73 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 13:54:28 +0200 Subject: [PATCH 12/15] sycl: no llama_curl --- examples/sycl/win-build-sycl.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sycl/win-build-sycl.bat b/examples/sycl/win-build-sycl.bat index 17dd1ff5c169e..6fc897b1486c8 100644 --- a/examples/sycl/win-build-sycl.bat +++ b/examples/sycl/win-build-sycl.bat @@ -13,10 +13,10 @@ if %errorlevel% neq 0 goto ERROR :: for FP16 :: faster for long-prompt inference -:: cmake -G "MinGW Makefiles" .. -DGGML_SYCL=ON -DCMAKE_CXX_COMPILER=icx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DGGML_SYCL_F16=ON +:: cmake -G "MinGW Makefiles" .. -DLLAMA_CURL=OFF -DGGML_SYCL=ON -DCMAKE_CXX_COMPILER=icx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DGGML_SYCL_F16=ON :: for FP32 -cmake -G "Ninja" .. -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release +cmake -G "Ninja" .. -DLLAMA_CURL=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release if %errorlevel% neq 0 goto ERROR :: build example/main only :: make main From 64faafc030848d74c1de4616ea7e1ccb420636e8 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 14:04:34 +0200 Subject: [PATCH 13/15] no test-arg-parser on windows --- .github/workflows/build.yml | 2 ++ tests/CMakeLists.txt | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee511cfc328c1..1680f8573e2b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1190,6 +1190,8 @@ jobs: run: | scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL + # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args + - name: Build id: cmake_build run: examples/sycl/win-build-sycl.bat diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7a158d6024d78..9a3d0eda9acbc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -131,9 +131,13 @@ if (NOT WIN32) endif() llama_target_and_test(test-log.cpp) -llama_target_and_test(test-arg-parser.cpp) llama_target_and_test(test-chat-template.cpp) +# this fails on windows (github hosted runner) due to missing .NET, so we disable it +if (NOT WIN32) + llama_target_and_test(test-arg-parser.cpp) +endif() + # llama_target_and_test(test-opt.cpp) # SLOW llama_target_and_test(test-gguf.cpp) llama_target_and_test(test-backend-ops.cpp) From 1c1c2c7a7d3082747783d0500b70a7644b9df40b Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sat, 5 Apr 2025 14:18:17 +0200 Subject: [PATCH 14/15] clarification --- CMakeLists.txt | 3 +-- common/CMakeLists.txt | 5 ++++- tests/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7942d8abe3216..4729e184555c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,8 +168,7 @@ add_subdirectory(src) # utils, programs, examples and tests # -if (NOT LLAMA_BUILD_EXAMPLES) - # curl is only needed for examples +if (NOT LLAMA_BUILD_EXAMPLES OR NOT LLAMA_BUILD_COMMON) set(LLAMA_CURL OFF) endif() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 829eb5b7238b9..43533fc86abe2 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -85,7 +85,10 @@ set(LLAMA_COMMON_EXTRA_LIBS build_info) # Use curl to download model url if (LLAMA_CURL) - find_package(CURL REQUIRED) + find_package(CURL) + if (NOT CURL_FOUND) + message(FATAL_ERROR "Could NOT find CURL. Hint: to disable this feature, set -DLLAMA_CURL=OFF") + endif() target_compile_definitions(${TARGET} PUBLIC LLAMA_USE_CURL) include_directories(${CURL_INCLUDE_DIRS}) find_library(CURL_LIBRARY curl REQUIRED) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9a3d0eda9acbc..2bb210702aef8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -133,7 +133,7 @@ endif() llama_target_and_test(test-log.cpp) llama_target_and_test(test-chat-template.cpp) -# this fails on windows (github hosted runner) due to missing .NET, so we disable it +# this fails on windows (github hosted runner) due to curl DLL not found (exit code 0xc0000135) if (NOT WIN32) llama_target_and_test(test-arg-parser.cpp) endif() From aec8b46eb203e04151239fb3aec68a79ee881e66 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Sun, 6 Apr 2025 20:22:46 +0200 Subject: [PATCH 15/15] try riscv64 / arm64 --- .github/workflows/build-linux-cross.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml index 255e7db2287d6..e8639913ea3a6 100644 --- a/.github/workflows/build-linux-cross.yml +++ b/.github/workflows/build-linux-cross.yml @@ -20,14 +20,12 @@ jobs: build-essential \ gcc-14-riscv64-linux-gnu \ g++-14-riscv64-linux-gnu \ - libcurl4-openssl-dev + libcurl4-openssl-dev:riscv64 - name: Build - # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_OPENMP=OFF \ - -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \ @@ -63,15 +61,13 @@ jobs: gcc-14-riscv64-linux-gnu \ g++-14-riscv64-linux-gnu \ libvulkan-dev:riscv64 \ - libcurl4-openssl-dev + libcurl4-openssl-dev:riscv64 - name: Build - # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_VULKAN=ON \ -DGGML_OPENMP=OFF \ - -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \ @@ -106,15 +102,13 @@ jobs: glslc \ crossbuild-essential-arm64 \ libvulkan-dev:arm64 \ - libcurl4-openssl-dev + libcurl4-openssl-dev:arm64 - name: Build - # TODO: fix build with LLAMA_CURL=ON run: | cmake -B build -DCMAKE_BUILD_TYPE=Release \ -DGGML_VULKAN=ON \ -DGGML_OPENMP=OFF \ - -DLLAMA_CURL=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=Linux \