fix: multiple gpu (#4641)

* fix: multiple gpu

* chore: check vulkan when app load

* chore: remove log

* chore: update engine variant conditional
This commit is contained in:
Faisal Amir 2025-02-12 22:50:56 +07:00 committed by GitHub
parent 6d73f49cdf
commit aed42edb3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 24 deletions

View File

@ -25,10 +25,10 @@ const os = (settings?: GpuSetting): string => {
return PLATFORM === 'win32' return PLATFORM === 'win32'
? 'windows-amd64' ? 'windows-amd64'
: PLATFORM === 'darwin' : PLATFORM === 'darwin'
? settings?.cpu?.arch === 'arm64' ? settings?.cpu?.arch === 'arm64'
? 'mac-arm64' ? 'mac-arm64'
: 'mac-amd64' : 'mac-amd64'
: 'linux-amd64' : 'linux-amd64'
} }
/** /**
@ -65,21 +65,22 @@ export const engineVariant = async (
// There is no need to append the variant extension for mac // There is no need to append the variant extension for mac
if (platform.startsWith('mac')) return platform if (platform.startsWith('mac')) return platform
let engineVariant = [ let engineVariant =
platform, gpuSetting?.vulkan || gpuSetting.gpus.some((e) => !e.additional_information)
gpuSetting?.vulkan ? [platform, 'vulkan']
? 'vulkan' : [
: (gpuRunMode(gpuSetting) === 'cuda' && // GPU mode - packaged CUDA variants of avx2 and noavx platform,
gpuSetting.cpu.instructions.some((inst) => inst === 'avx2')) || gpuRunMode(gpuSetting) === 'cuda' &&
gpuSetting.cpu.instructions.some((inst) => inst === 'avx512') (gpuSetting.cpu.instructions.includes('avx2') ||
? 'avx2' gpuSetting.cpu.instructions.includes('avx512'))
: 'noavx', ? 'avx2'
gpuRunMode(gpuSetting), : 'noavx',
cudaVersion(gpuSetting), gpuRunMode(gpuSetting),
] cudaVersion(gpuSetting),
.filter((e) => !!e) ].filter(Boolean) // Remove any falsy values
.join('-')
log(`[CORTEX]: Engine variant: ${engineVariant}`) let engineVariantString = engineVariant.join('-')
return engineVariant
log(`[CORTEX]: Engine variant: ${engineVariantString}`)
return engineVariantString
} }

View File

@ -50,9 +50,9 @@ const Hardware = () => {
} }
// Handle switch toggle for GPU activation // Handle switch toggle for GPU activation
const handleSwitchChange = async (index: number, isActive: boolean) => { const handleSwitchChange = async (id: string, isActive: boolean) => {
const updatedGpus = gpus.map((gpu, i) => const updatedGpus = gpus.map((gpu) =>
i === index ? { ...gpu, activated: isActive } : gpu gpu.id === id ? { ...gpu, activated: isActive } : gpu
) )
setGpus(updatedGpus) setGpus(updatedGpus)
// Call the API to update the active GPUs // Call the API to update the active GPUs
@ -282,7 +282,10 @@ const Hardware = () => {
<Switch <Switch
checked={item.activated} checked={item.activated}
onChange={(e) => onChange={(e) =>
handleSwitchChange(i, e.target.checked) handleSwitchChange(
item.id,
e.target.checked
)
} }
/> />