diff --git a/CMakeLists.txt b/CMakeLists.txt index a1b7f4f5..89f7a7b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,6 @@ set(APP_VERSION_MINOR 4) set(APP_VERSION_PATCH 1) set(APP_VERSION "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}") -# Generate a header file with the version number -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/config.h" -) - # Include the binary directory for the generated header file include_directories("${CMAKE_CURRENT_BINARY_DIR}") @@ -36,6 +30,12 @@ option(GPT4ALL_LOCALHOST OFF "Build installer for localhost repo") option(GPT4ALL_AVX_ONLY OFF "Build for avx only") option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF) +# Generate a header file with the version number +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + find_package(Qt6 6.2 COMPONENTS Core Quick QuickDialogs2 Svg REQUIRED) # Get the Qt6Core target properties diff --git a/cmake/config.h.in b/cmake/config.h.in index c6b77b5b..e578a82d 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -2,5 +2,6 @@ #define CONFIG_H #define APP_VERSION "@APP_VERSION@" +#define GPT4ALL_AVX_ONLY "@GPT4ALL_AVX_ONLY@" #endif // CONFIG_H diff --git a/llm.cpp b/llm.cpp index fda940de..f6009e78 100644 --- a/llm.cpp +++ b/llm.cpp @@ -1,4 +1,5 @@ #include "llm.h" +#include "config.h" #include "download.h" #include "network.h" @@ -24,6 +25,17 @@ LLM::LLM() { connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &LLM::aboutToQuit); + +#if defined(__x86_64__) || defined(__i386__) + if (QString(GPT4ALL_AVX_ONLY) == "OFF") { + const bool avx(__builtin_cpu_supports("avx")); + const bool avx2(__builtin_cpu_supports("avx2")); + const bool fma(__builtin_cpu_supports("fma")); + m_compatHardware = avx && avx2 && fma; + qDebug() << "m_compatHardware" << m_compatHardware; + emit compatHardwareChanged(); + } +#endif } bool LLM::checkForUpdates() const diff --git a/llm.h b/llm.h index 89fee17f..ac12981d 100644 --- a/llm.h +++ b/llm.h @@ -10,6 +10,7 @@ class LLM : public QObject Q_OBJECT Q_PROPERTY(ChatListModel *chatListModel READ chatListModel NOTIFY chatListModelChanged) Q_PROPERTY(int32_t threadCount READ threadCount WRITE setThreadCount NOTIFY threadCountChanged) + Q_PROPERTY(bool compatHardware READ compatHardware NOTIFY compatHardwareChanged) public: static LLM *globalInstance(); @@ -17,12 +18,14 @@ public: ChatListModel *chatListModel() const { return m_chatListModel; } int32_t threadCount() const; void setThreadCount(int32_t n_threads); + bool compatHardware() const { return m_compatHardware; } Q_INVOKABLE bool checkForUpdates() const; Q_SIGNALS: void chatListModelChanged(); void threadCountChanged(); + void compatHardwareChanged(); private Q_SLOTS: void aboutToQuit(); @@ -30,6 +33,7 @@ private Q_SLOTS: private: ChatListModel *m_chatListModel; int32_t m_threadCount; + bool m_compatHardware; private: explicit LLM(); diff --git a/llmodel/CMakeLists.txt b/llmodel/CMakeLists.txt index 91c051e8..46966be5 100644 --- a/llmodel/CMakeLists.txt +++ b/llmodel/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) if(APPLE) - option(BUILD_UNIVERSAL "Build a Universal binary on macOS" OFF) + option(BUILD_UNIVERSAL "Build a Universal binary on macOS" ON) if(BUILD_UNIVERSAL) # Build a Universal binary on macOS # This requires that the found Qt library is compiled as Universal binaries. @@ -25,6 +25,8 @@ set(BUILD_SHARED_LIBS ON FORCE) set(CMAKE_VERBOSE_MAKEFILE ON) if (GPT4ALL_AVX_ONLY) set(LLAMA_AVX2 OFF CACHE BOOL "llama: enable AVX2" FORCE) + set(LLAMA_F16C OFF CACHE BOOL "llama: enable F16C" FORCE) + set(LLAMA_FMA OFF CACHE BOOL "llama: enable FMA" FORCE) endif() add_subdirectory(llama.cpp) diff --git a/main.qml b/main.qml index 8144649e..89196241 100644 --- a/main.qml +++ b/main.qml @@ -25,7 +25,10 @@ Window { // Startup code Component.onCompleted: { - startupDialogs(); + if (!LLM.compatHardware) + errorCompatHardware.open(); + else + startupDialogs(); } Connections { @@ -77,6 +80,16 @@ Window { } } + PopupDialog { + id: errorCompatHardware + anchors.centerIn: parent + shouldTimeOut: false + shouldShowBusy: false + closePolicy: Popup.NoAutoClose + modal: true + text: qsTr("Incompatible hardware detected. Please try the avx-only installer on https://gpt4all.io") + } + StartupDialog { id: firstStartDialog anchors.centerIn: parent