mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-11-09 16:55:32 +03:00
Fail early/gracefully if incompatible hardware detected. And default to universal builds on mac.
This commit is contained in:
parent
3c30310539
commit
6d943917f1
@ -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
|
||||
|
@ -2,5 +2,6 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define APP_VERSION "@APP_VERSION@"
|
||||
#define GPT4ALL_AVX_ONLY "@GPT4ALL_AVX_ONLY@"
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
12
llm.cpp
12
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
|
||||
|
4
llm.h
4
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();
|
||||
|
@ -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)
|
||||
|
15
main.qml
15
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
|
||||
|
Loading…
Reference in New Issue
Block a user