From ceb93cafef634520b7abcc1c3507c64ad0b3798f Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 11 Feb 2025 10:24:47 +0700 Subject: [PATCH] chore: bump cortex to the latest version 1.0.10-rc1 to address hardware UI issues (#4622) * chore: bump cortex to the latest version 1.0.10-rc1 to address hardware API issues * fix: app crashes while reading properties from undefined value * fix: cuda engine variant selection logic --- core/src/types/hardware/index.ts | 2 +- .../types/miscellaneous/systemResourceInfo.ts | 17 ++++---- .../engine-management-extension/src/utils.ts | 43 +++++++++---------- .../bin/version.txt | 2 +- web/screens/Settings/Hardware/index.tsx | 2 +- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/core/src/types/hardware/index.ts b/core/src/types/hardware/index.ts index f729ba4e5..d154a4417 100644 --- a/core/src/types/hardware/index.ts +++ b/core/src/types/hardware/index.ts @@ -13,7 +13,7 @@ export type GpuAdditionalInformation = { export type Gpu = { activated: boolean - additional_information: GpuAdditionalInformation + additional_information?: GpuAdditionalInformation free_vram: number id: string name: string diff --git a/core/src/types/miscellaneous/systemResourceInfo.ts b/core/src/types/miscellaneous/systemResourceInfo.ts index c29327e74..9361b79b6 100644 --- a/core/src/types/miscellaneous/systemResourceInfo.ts +++ b/core/src/types/miscellaneous/systemResourceInfo.ts @@ -1,4 +1,4 @@ - +import { GpuAdditionalInformation } from '../hardware' export type SystemResourceInfo = { memAvailable: number @@ -12,13 +12,14 @@ export type GpuSetting = { } export type GpuSettingInfo = { - activated: boolean; - free_vram: number; - id: string; - name: string; - total_vram: number; - uuid: string; - version: string; + activated: boolean + free_vram: number + id: string + name: string + total_vram: number + uuid: string + version: string + additional_information?: GpuAdditionalInformation } export type SystemInformation = { diff --git a/extensions/engine-management-extension/src/utils.ts b/extensions/engine-management-extension/src/utils.ts index 588fd938c..eb2b47e53 100644 --- a/extensions/engine-management-extension/src/utils.ts +++ b/extensions/engine-management-extension/src/utils.ts @@ -1,8 +1,4 @@ - -import { - GpuSetting, - log, -} from '@janhq/core' +import { GpuSetting, log } from '@janhq/core' /** * The GPU runMode that will be set - either 'vulkan', 'cuda', or empty for cpu. @@ -10,14 +6,15 @@ import { * @returns */ - const gpuRunMode = (settings?: GpuSetting): string => { - - if (!settings) return '' - - return settings.vulkan === true || - settings.gpus?.some((gpu) => gpu.activated !== true) - ? '' - : 'cuda' +const gpuRunMode = (settings?: GpuSetting): string => { + return settings.gpus?.some( + (gpu) => + gpu.activated === true && + gpu.additional_information && + gpu.additional_information.driver_version + ) + ? 'cuda' + : '' } /** @@ -28,10 +25,10 @@ const os = (settings?: GpuSetting): string => { return PLATFORM === 'win32' ? 'windows-amd64' : PLATFORM === 'darwin' - ? settings?.cpu?.arch === 'arm64' - ? 'mac-arm64' - : 'mac-amd64' - : 'linux-amd64' + ? settings?.cpu?.arch === 'arm64' + ? 'mac-arm64' + : 'mac-amd64' + : 'linux-amd64' } /** @@ -60,16 +57,18 @@ const cudaVersion = (settings?: GpuSetting): '12-0' | '11-7' | undefined => { /** * Find which variant to run based on the current platform. */ -export const engineVariant = async (gpuSetting?: GpuSetting): Promise => { +export const engineVariant = async ( + gpuSetting?: GpuSetting +): Promise => { let engineVariant = [ os(gpuSetting), gpuSetting?.vulkan ? 'vulkan' : (gpuRunMode(gpuSetting) === 'cuda' && // GPU mode - packaged CUDA variants of avx2 and noavx - gpuSetting.cpu.instructions.some((inst) => inst === 'avx2')) || - gpuSetting.cpu.instructions.some((inst) => inst === 'avx512') - ? 'avx2' - : 'noavx', + gpuSetting.cpu.instructions.some((inst) => inst === 'avx2')) || + gpuSetting.cpu.instructions.some((inst) => inst === 'avx512') + ? 'avx2' + : 'noavx', gpuRunMode(gpuSetting), cudaVersion(gpuSetting), ] diff --git a/extensions/inference-cortex-extension/bin/version.txt b/extensions/inference-cortex-extension/bin/version.txt index 00a5e9492..2c85ca180 100644 --- a/extensions/inference-cortex-extension/bin/version.txt +++ b/extensions/inference-cortex-extension/bin/version.txt @@ -1 +1 @@ -1.0.9-rc8 +1.0.10-rc1 diff --git a/web/screens/Settings/Hardware/index.tsx b/web/screens/Settings/Hardware/index.tsx index 7a13dbec9..cd9c302db 100644 --- a/web/screens/Settings/Hardware/index.tsx +++ b/web/screens/Settings/Hardware/index.tsx @@ -317,7 +317,7 @@ const Hardware = () => { Compute Capability - {item.additional_information.compute_cap} + {item.additional_information?.compute_cap}