Skip to content

Commit

Permalink
add Windows ARM build (#3385)
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
  • Loading branch information
cebtenzzre authored Jan 21, 2025
1 parent 82175b2 commit 810615d
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 15 deletions.
269 changes: 269 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,261 @@ jobs:
- store_artifacts:
path: build/upload

build-offline-chat-installer-windows-arm:
machine:
# we use 2024.04.01 because nvcc complains about the MSVC ver if we use anything newer
image: windows-server-2022-gui:2024.04.1
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
steps:
- checkout
- run:
name: Update Submodules
command: |
git submodule sync
git submodule update --init --recursive
- restore_cache:
keys:
- ccache-gpt4all-win-aarch64-
- run:
name: Install dependencies
command: choco install -y ccache wget
- run:
name: Installing Qt
command: |
wget.exe "https://gpt4all.io/ci/qt-unified-windows-x64-4.6.0-online.exe"
# note: need x86_64 toolset for windeployqt.exe, which isn't provided with the ARM64 cross toolset
& .\qt-unified-windows-x64-4.6.0-online.exe --no-force-installations --no-default-installations `
--no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
--email ${Env:QT_EMAIL} --password ${Env:QT_PASSWORD} install `
qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.651.win64_msvc2019_64 `
qt.qt6.651.win64_msvc2019_arm64 qt.qt6.651.qt5compat qt.qt6.651.debug_info qt.qt6.651.addons.qthttpserver
- run:
name: "Install Dotnet 8"
command: |
mkdir dotnet
cd dotnet
$dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
wget.exe "$dotnet_url"
Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
$Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
dotnet tool install --global AzureSignTool
- run:
name: Build
no_output_timeout: 30m
command: |
$vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -Arch arm64 -HostArch amd64 -DevCmdArguments '-no_logo'
$Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
mkdir build
cd build
& "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
-S ..\gpt4all-chat -B . -G Ninja `
-DCMAKE_BUILD_TYPE=Release `
"-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.5.1\msvc2019_arm64" `
"-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
"-DCMAKE_TOOLCHAIN_FILE=C:\Qt\6.5.1\msvc2019_arm64\lib\cmake\Qt6\qt.toolchain.cmake" `
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
-DLLMODEL_CUDA=OFF `
-DLLMODEL_KOMPUTE=OFF `
"-DWINDEPLOYQT=C:\Qt\6.5.1\msvc2019_64\bin\windeployqt.exe;--qtpaths;C:\Qt\6.5.1\msvc2019_arm64\bin\qtpaths.bat" `
-DGPT4ALL_TEST=OFF `
-DGPT4ALL_OFFLINE_INSTALLER=ON
& "C:\Qt\Tools\Ninja\ninja.exe"
& "C:\Qt\Tools\Ninja\ninja.exe" install
& "C:\Qt\Tools\Ninja\ninja.exe" package
ccache -s
mkdir upload
copy gpt4all-installer-win64-arm.exe upload
- store_artifacts:
path: build/upload
# add workspace so signing jobs can connect & obtain dmg
- save_cache:
key: ccache-gpt4all-win-aarch64-{{ epoch }}
when: always
paths:
- ..\.ccache
- persist_to_workspace:
root: build
# specify path to only include components we want to persist
# accross builds
paths:
- upload

sign-offline-chat-installer-windows-arm:
machine:
image: windows-server-2022-gui:2024.04.1
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
steps:
- checkout
- attach_workspace:
at: build
- run:
name: Install dependencies
command: choco install -y wget
- run:
name: "Install Dotnet 8 && Azure Sign Tool"
command: |
mkdir dotnet
cd dotnet
$dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
wget.exe "$dotnet_url"
Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
$Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
dotnet tool install --global AzureSignTool
- run:
name: "Sign Windows Installer With AST"
command: |
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)\build\upload\gpt4all-installer-win64-arm.exe"
- store_artifacts:
path: build/upload

build-online-chat-installer-windows-arm:
machine:
image: windows-server-2022-gui:2024.04.1
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
steps:
- checkout
- run:
name: Update Submodules
command: |
git submodule sync
git submodule update --init --recursive
- restore_cache:
keys:
- ccache-gpt4all-win-aarch64-
- run:
name: Install dependencies
command: choco install -y ccache wget
- run:
name: Installing Qt
command: |
wget.exe "https://gpt4all.io/ci/qt-unified-windows-x64-4.6.0-online.exe"
# note: need x86_64 toolset for windeployqt.exe, which isn't provided with the ARM64 cross toolset
& .\qt-unified-windows-x64-4.6.0-online.exe --no-force-installations --no-default-installations `
--no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
--email ${Env:QT_EMAIL} --password ${Env:QT_PASSWORD} install `
qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.651.win64_msvc2019_64 `
qt.qt6.651.win64_msvc2019_arm64 qt.qt6.651.qt5compat qt.qt6.651.debug_info qt.qt6.651.addons.qthttpserver
- run:
name: "Install Dotnet 8"
command: |
mkdir dotnet
cd dotnet
$dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
wget.exe "$dotnet_url"
Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
- run:
name: "Setup Azure SignTool"
command: |
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
$Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
dotnet tool install --global AzureSignTool
- run:
name: Build
no_output_timeout: 30m
command: |
$vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -Arch arm64 -HostArch amd64 -DevCmdArguments '-no_logo'
$Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
mkdir build
cd build
& "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
-S ..\gpt4all-chat -B . -G Ninja `
-DCMAKE_BUILD_TYPE=Release `
"-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.5.1\msvc2019_arm64" `
"-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
"-DCMAKE_TOOLCHAIN_FILE=C:\Qt\6.5.1\msvc2019_arm64\lib\cmake\Qt6\qt.toolchain.cmake" `
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
-DLLMODEL_CUDA=OFF `
-DLLMODEL_KOMPUTE=OFF `
"-DWINDEPLOYQT=C:\Qt\6.5.1\msvc2019_64\bin\windeployqt.exe;--qtpaths;C:\Qt\6.5.1\msvc2019_arm64\bin\qtpaths.bat" `
-DGPT4ALL_TEST=OFF `
-DGPT4ALL_OFFLINE_INSTALLER=OFF
& "C:\Qt\Tools\Ninja\ninja.exe"
& "C:\Qt\Tools\Ninja\ninja.exe" install
& "C:\Qt\Tools\Ninja\ninja.exe" package
ccache -s
mkdir upload
copy gpt4all-installer-win64-arm.exe upload
Set-Location -Path "_CPack_Packages/win64/IFW/gpt4all-installer-win64-arm"
Compress-Archive -Path 'repository' -DestinationPath '..\..\..\..\upload\repository.zip'
- store_artifacts:
path: build/upload
- save_cache:
key: ccache-gpt4all-win-aarch64-{{ epoch }}
when: always
paths:
- ..\.ccache
# add workspace so signing jobs can connect & obtain dmg
- persist_to_workspace:
root: build
# specify path to only include components we want to persist
# accross builds
paths:
- upload

sign-online-chat-installer-windows-arm:
machine:
image: windows-server-2022-gui:2024.04.1
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
steps:
- checkout
- attach_workspace:
at: build
- run:
name: Install dependencies
command: choco install -y wget
- run:
name: "Install Dotnet 8"
command: |
mkdir dotnet
cd dotnet
$dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
wget.exe "$dotnet_url"
Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
- run:
name: "Setup Azure SignTool"
command: |
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
$Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
dotnet tool install --global AzureSignTool
- run:
name: "Sign Windows Installer With AST"
command: |
$Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
$Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)/build/upload/gpt4all-installer-win64-arm.exe"
- store_artifacts:
path: build/upload

build-gpt4all-chat-linux:
machine:
image: ubuntu-2204:current
Expand Down Expand Up @@ -1516,6 +1771,12 @@ workflows:
context: gpt4all
requires:
- build-offline-chat-installer-windows
- build-offline-chat-installer-windows-arm:
requires:
- hold
- sign-offline-chat-installer-windows-arm:
requires:
- build-offline-chat-installer-windows-arm
- build-offline-chat-installer-linux:
context: gpt4all
requires:
Expand Down Expand Up @@ -1554,6 +1815,14 @@ workflows:
context: gpt4all
requires:
- build-online-chat-installer-windows
- build-online-chat-installer-windows-arm:
<<: *main_only
requires:
- hold
- sign-online-chat-installer-windows-arm:
<<: *main_only
requires:
- build-online-chat-installer-windows-arm
- build-online-chat-installer-linux:
<<: *main_only
context: gpt4all
Expand Down
3 changes: 3 additions & 0 deletions gpt4all-chat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added
- Add support for the Windows ARM64 target platform (CPU-only) ([#3385](https://github.com/nomic-ai/gpt4all/pull/3385))

### Fixed
- Fix the timeout error in code interpreter ([#3369](https://github.com/nomic-ai/gpt4all/pull/3369))
- Fix code interpreter console.log not accepting multiple arguments ([#3371](https://github.com/nomic-ai/gpt4all/pull/3371))
Expand Down
57 changes: 45 additions & 12 deletions gpt4all-chat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ option(GPT4ALL_LOCALHOST "Build installer for localhost repo" OFF)
option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF)
option(GPT4ALL_SIGN_INSTALL "Sign installed binaries and installers (requires signing identities)" OFF)
option(GPT4ALL_GEN_CPACK_CONFIG "Generate the CPack config.xml in the package step and nothing else." OFF)
set(GPT4ALL_USE_QTPDF "AUTO" CACHE STRING "Whether to Use QtPDF for LocalDocs. If OFF or not available on this platform, PDFium is used.")
set_property(CACHE GPT4ALL_USE_QTPDF PROPERTY STRINGS AUTO ON OFF)

include(cmake/cpack_config.cmake)

Expand Down Expand Up @@ -91,7 +93,18 @@ configure_file(
)

set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON)
find_package(Qt6 6.5 COMPONENTS Core HttpServer LinguistTools Pdf Quick QuickDialogs2 Sql Svg REQUIRED)
set(GPT4ALL_QT_COMPONENTS Core HttpServer LinguistTools Quick QuickDialogs2 Sql Svg)
set(GPT4ALL_USING_QTPDF OFF)
if (CMAKE_SYSTEM_NAME MATCHES Windows AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|AARCH64|arm64|ARM64)$")
# QtPDF is not available.
if (GPT4ALL_USE_QTPDF STREQUAL "ON")
message(FATAL_ERROR "QtPDF is not available on Windows ARM64.")
endif()
elseif (GPT4ALL_USE_QTPDF MATCHES "^(ON|AUTO)$")
set(GPT4ALL_USING_QTPDF ON)
list(APPEND GPT4ALL_QT_COMPONENTS Pdf)
endif()
find_package(Qt6 6.5 COMPONENTS ${GPT4ALL_QT_COMPONENTS} REQUIRED)

if (QT_KNOWN_POLICY_QTP0004)
qt_policy(SET QTP0004 NEW) # generate extra qmldir files on Qt 6.8+
Expand Down Expand Up @@ -415,7 +428,14 @@ target_include_directories(chat PRIVATE deps/usearch/include
deps/usearch/fp16/include)

target_link_libraries(chat
PRIVATE Qt6::Core Qt6::HttpServer Qt6::Pdf Qt6::Quick Qt6::Sql Qt6::Svg)
PRIVATE Qt6::Core Qt6::HttpServer Qt6::Quick Qt6::Sql Qt6::Svg)
if (GPT4ALL_USING_QTPDF)
target_compile_definitions(chat PRIVATE GPT4ALL_USE_QTPDF)
target_link_libraries(chat PRIVATE Qt6::Pdf)
else()
# Link PDFium
target_link_libraries(chat PRIVATE pdfium)
endif()
target_link_libraries(chat
PRIVATE llmodel SingleApplication fmt::fmt duckx::duckx QXlsx jinja2cpp)

Expand Down Expand Up @@ -497,6 +517,15 @@ if (LLMODEL_CUDA)
endif()
endif()

if (NOT GPT4ALL_USING_QTPDF)
# Install PDFium
if (WIN32)
install(FILES "${PDFium_LIBRARY}" DESTINATION bin COMPONENT ${COMPONENT_NAME_MAIN})
else()
install(FILES "${PDFium_LIBRARY}" DESTINATION lib COMPONENT ${COMPONENT_NAME_MAIN})
endif()
endif()

if (NOT APPLE)
install(FILES "${LOCAL_EMBEDDING_MODEL_PATH}"
DESTINATION resources
Expand Down Expand Up @@ -547,15 +576,19 @@ endif()

if (GPT4ALL_LOCALHOST)
cpack_ifw_add_repository("GPT4AllRepository" URL "http://localhost/repository")
elseif(GPT4ALL_OFFLINE_INSTALLER)
add_compile_definitions(GPT4ALL_OFFLINE_INSTALLER)
elseif (GPT4ALL_OFFLINE_INSTALLER)
add_compile_definitions(GPT4ALL_OFFLINE_INSTALLER)
else()
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/linux/repository")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
#To sign the target on windows have to create a batch script add use it as a custom target and then use CPACK_IFW_EXTRA_TARGETS to set this extra target
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/windows/repository")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/mac/repository")
endif()
if (CMAKE_SYSTEM_NAME MATCHES Linux)
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/linux/repository")
elseif (CMAKE_SYSTEM_NAME MATCHES Windows)
# To sign the target on windows have to create a batch script add use it as a custom target and then use CPACK_IFW_EXTRA_TARGETS to set this extra target
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/windows/repository")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|AARCH64|arm64|ARM64)$")
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/windows_arm/repository")
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES Darwin)
cpack_ifw_add_repository("GPT4AllRepository" URL "https://gpt4all.io/installer_repos/mac/repository")
endif()
endif()
Loading

0 comments on commit 810615d

Please sign in to comment.