mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-12 22:09:13 +00:00
fix non-AVX CPU detection (#2141)
* chat: fix non-AVX CPU detection on Windows * bindings: throw exception instead of logging to console Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "llm.h"
|
||||
#include "../gpt4all-backend/llmodel.h"
|
||||
#include "../gpt4all-backend/sysinfo.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -25,22 +26,8 @@ LLM *LLM::globalInstance()
|
||||
|
||||
LLM::LLM()
|
||||
: QObject{nullptr}
|
||||
, m_compatHardware(true)
|
||||
, m_compatHardware(LLModel::Implementation::hasSupportedCPU())
|
||||
{
|
||||
#if defined(__x86_64__)
|
||||
#ifndef _MSC_VER
|
||||
const bool minimal(__builtin_cpu_supports("avx"));
|
||||
#else
|
||||
int cpuInfo[4];
|
||||
__cpuid(cpuInfo, 1);
|
||||
const bool minimal(cpuInfo[2] & (1 << 28));
|
||||
#endif
|
||||
#else
|
||||
const bool minimal = true; // Don't know how to handle non-x86_64
|
||||
#endif
|
||||
|
||||
m_compatHardware = minimal;
|
||||
|
||||
QNetworkInformation::loadDefaultBackend();
|
||||
auto * netinfo = QNetworkInformation::instance();
|
||||
if (netinfo) {
|
||||
|
@@ -228,11 +228,11 @@ int ModelInfo::maxContextLength() const
|
||||
if (!installed || isOnline) return -1;
|
||||
if (m_maxContextLength != -1) return m_maxContextLength;
|
||||
auto path = (dirpath + filename()).toStdString();
|
||||
int layers = LLModel::Implementation::maxContextLength(path);
|
||||
if (layers < 0) {
|
||||
layers = 4096; // fallback value
|
||||
int n_ctx = LLModel::Implementation::maxContextLength(path);
|
||||
if (n_ctx < 0) {
|
||||
n_ctx = 4096; // fallback value
|
||||
}
|
||||
m_maxContextLength = layers;
|
||||
m_maxContextLength = n_ctx;
|
||||
return m_maxContextLength;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user