From 18065bce0d71316e617d95d0fbd21a786549bba7 Mon Sep 17 00:00:00 2001 From: okada Date: Sun, 10 Dec 2023 23:03:45 +0900 Subject: [PATCH 1/5] add windows build --- .github/workflows/build.yaml | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f3b1a1c..f33b8b1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -94,6 +94,87 @@ jobs: name: flatline_lsp_ubuntu2004_${{ matrix.build }}.zip path: dist/flatline_lsp_ubuntu2004_${{ matrix.build }}.zip + build-release-windows-latest: + runs-on: windows-latest + + env: + OPENBLAS_VERSION: 0.3.23 + + strategy: + matrix: + include: + - build: 'openblas' + defines: '-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS' + + steps: + - name: Clone + id: checkout + uses: actions/checkout@v1 + + - name: Common dependencies + id: depends + run: | + python3 -m pip install cmake + python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu + python3 -m pip install transformers==4.33.3 tiktoken pygls pyinstaller + + - name: Download OpenBLAS + id: get_openblas + if: ${{ matrix.build == 'openblas' }} + run: | + 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" + curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE" + mkdir $env:RUNNER_TEMP/openblas + tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas + $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath) + $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim())) + $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe') + & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll + + - name: Build backend server + id: cmake_build_backend_server + run: | + cmake -B build_backend_server -S . -DLLAMA_NATIVE=OFF ${{ matrix.defines }} + cmake --build build_backend_server --config Release + + - name: Build lsp server + id: pyinstaller_build_lsp_server + run: | + pyinstaller flatline_lsp.py \ + --copy-metadata tqdm \ + --copy-metadata regex \ + --copy-metadata requests \ + --copy-metadata packaging \ + --copy-metadata filelock \ + --copy-metadata numpy \ + --copy-metadata tokenizers \ + --copy-metadata huggingface-hub \ + --copy-metadata safetensors \ + --copy-metadata pyyaml \ + --copy-metadata torch \ + --hidden-import=tiktoken_ext.openai_public \ + --hidden-import=tiktoken_ext \ + ; + + - name: Make package + id: make_package + shell: bash + run: | + mkdir -p ./dist/flatline_lsp/_internal/flatline/model_data + mkdir -p ./dist/flatline_lsp/_internal/flatline/backend_server + mv build_backend_server/bin/flatline-server ./dist/flatline_lsp/_internal/flatline/backend_server/flatline-server + mkdir -p ./dist/flatline_lsp/license + find build_backend_server/bin -name \*.LICENSE.txt | xargs -I{} cp {} ./dist/flatline_lsp/license/ + cd dist + 7z a flatline_lsp_windows_${{ matrix.build }}.zip flatline_lsp + + - name: Upload package + id: upload_package + uses: actions/upload-artifact@v3 + with: + name: flatline_lsp_ubuntu2004_${{ matrix.build }}.zip + path: dist/flatline_lsp_ubuntu2004_${{ matrix.build }}.zip + create-release: runs-on: ubuntu-latest needs: [build-release-ubuntu-2004] From 1d398e21304b6c653c589d09ca7ef81aa2592749 Mon Sep 17 00:00:00 2001 From: okada Date: Sun, 10 Dec 2023 23:33:48 +0900 Subject: [PATCH 2/5] fix --- .github/workflows/build.yaml | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f33b8b1..1e9c5a3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -104,7 +104,7 @@ jobs: matrix: include: - build: 'openblas' - defines: '-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS' + defines: '-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"' steps: - name: Clone @@ -137,6 +137,13 @@ jobs: cmake -B build_backend_server -S . -DLLAMA_NATIVE=OFF ${{ matrix.defines }} cmake --build build_backend_server --config Release + - name: Add libopenblas.dll + id: add_libopenblas_dll + if: ${{ matrix.build == 'openblas' }} + run: | + cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build_backend_server/bin/Release/openblas.dll + cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build_backend_server/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt + - name: Build lsp server id: pyinstaller_build_lsp_server run: | @@ -172,8 +179,8 @@ jobs: id: upload_package uses: actions/upload-artifact@v3 with: - name: flatline_lsp_ubuntu2004_${{ matrix.build }}.zip - path: dist/flatline_lsp_ubuntu2004_${{ matrix.build }}.zip + name: flatline_lsp_windows_${{ matrix.build }}.zip + path: dist/flatline_lsp_windows_${{ matrix.build }}.zip create-release: runs-on: ubuntu-latest @@ -202,8 +209,8 @@ jobs: draft: false prerelease: true - - name: Upload release openblas asset - id: upload_release_openblas_asset + - name: Upload release ubuntu2004 openblas asset + id: upload_release_ubuntu2004_openblas_asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -213,8 +220,8 @@ jobs: asset_name: flatline_lsp_ubuntu2004_openblas.zip asset_content_type: application/zip - - name: Upload release cublas asset - id: upload_release_cublas_asset + - name: Upload release ubuntu2004 cublas asset + id: upload_release_ubuntu2004_cublas_asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -224,6 +231,17 @@ jobs: asset_name: flatline_lsp_ubuntu2004_cublas.zip asset_content_type: application/zip + - name: Upload release windows openblas asset + id: upload_release_windows_openblas_asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: flatline_lsp_windows_openblas.zip/flatline_lsp_windows_openblas.zip + asset_name: flatline_lsp_windows_openblas.zip + asset_content_type: application/zip + test-on-ubuntu-2004: runs-on: ubuntu-20.04 needs: [create-release] From 4774590c25ddd358265d8551d0b3cfd108eb5488 Mon Sep 17 00:00:00 2001 From: okada Date: Sun, 10 Dec 2023 23:42:19 +0900 Subject: [PATCH 3/5] remove unused c++fs lib --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 640d00e..a0cd0d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ target_link_libraries(httplib INTERFACE Threads::Threads) add_executable(${PROJECT_NAME}-server ${CMAKE_CURRENT_SOURCE_DIR}/flatline_server.cpp) set_target_properties(${PROJECT_NAME}-server PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -target_link_libraries(${PROJECT_NAME}-server PRIVATE llama ggml httplib jsoncpp_static structopt spdlog::spdlog "stdc++fs") +target_link_libraries(${PROJECT_NAME}-server PRIVATE llama ggml httplib jsoncpp_static structopt spdlog::spdlog) add_custom_command( TARGET ${PROJECT_NAME}-server POST_BUILD From b40dc44a99c3f312d1429783191483e50e6840fb Mon Sep 17 00:00:00 2001 From: okada Date: Sun, 10 Dec 2023 23:51:03 +0900 Subject: [PATCH 4/5] specify shell bash --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1e9c5a3..5d71ad5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -146,6 +146,7 @@ jobs: - name: Build lsp server id: pyinstaller_build_lsp_server + shell: bash run: | pyinstaller flatline_lsp.py \ --copy-metadata tqdm \ From 9d7d1a6d6a90d9a7849e985afe753bd0d54815a9 Mon Sep 17 00:00:00 2001 From: okada Date: Mon, 11 Dec 2023 00:30:13 +0900 Subject: [PATCH 5/5] trial --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5d71ad5..caaeb36 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -170,7 +170,8 @@ jobs: run: | mkdir -p ./dist/flatline_lsp/_internal/flatline/model_data mkdir -p ./dist/flatline_lsp/_internal/flatline/backend_server - mv build_backend_server/bin/flatline-server ./dist/flatline_lsp/_internal/flatline/backend_server/flatline-server + find build_backend_server + mv build_backend_server/bin/flatline-server.exe ./dist/flatline_lsp/_internal/flatline/backend_server/flatline-server.exe mkdir -p ./dist/flatline_lsp/license find build_backend_server/bin -name \*.LICENSE.txt | xargs -I{} cp {} ./dist/flatline_lsp/license/ cd dist