fix version compare
This commit is contained in:
parent
3490299f66
commit
a75d13f42f
@ -175,17 +175,16 @@ async function _getSupportedFeatures() {
|
|||||||
|
|
||||||
// TODO: HIP and SYCL
|
// TODO: HIP and SYCL
|
||||||
for (const gpuInfo of sysInfo.gpus) {
|
for (const gpuInfo of sysInfo.gpus) {
|
||||||
|
const driverVersion = gpuInfo.driver_version
|
||||||
|
|
||||||
if (gpuInfo.nvidiaInfo?.compute_capability) {
|
if (gpuInfo.nvidiaInfo?.compute_capability) {
|
||||||
if (gpuInfo.driver_version.localeCompare(minCuda11DriverVersion) >= 0) {
|
if (compareVersions(driverVersion, minCuda11DriverVersion) >= 0)
|
||||||
features.cuda11 = true
|
features.cuda11 = true
|
||||||
}
|
if (compareVersions(driverVersion, minCuda12DriverVersion) >= 0)
|
||||||
if (gpuInfo.driver_version.localeCompare(minCuda12DriverVersion) >= 0) {
|
|
||||||
features.cuda12 = true
|
features.cuda12 = true
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gpuInfo.vulkanInfo?.api_version) {
|
|
||||||
features.vulkan = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gpuInfo.vulkanInfo?.api_version) features.vulkan = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return features
|
return features
|
||||||
@ -225,3 +224,17 @@ async function _isCudaInstalled(version: string): Promise<boolean> {
|
|||||||
const cudartPath = await joinPath([janDataFolderPath, 'llamacpp', 'lib', libname])
|
const cudartPath = await joinPath([janDataFolderPath, 'llamacpp', 'lib', libname])
|
||||||
return await fs.existsSync(cudartPath)
|
return await fs.existsSync(cudartPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function compareVersions(a: string, b: string): number {
|
||||||
|
const aParts = a.split('.').map(Number);
|
||||||
|
const bParts = b.split('.').map(Number);
|
||||||
|
const len = Math.max(aParts.length, bParts.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const x = aParts[i] || 0;
|
||||||
|
const y = bParts[i] || 0;
|
||||||
|
if (x > y) return 1;
|
||||||
|
if (x < y) return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user