Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hardware section #3866

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 76 additions & 71 deletions web/screens/Settings/Advanced/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
const selectedGpu = gpuList
.filter((x) => gpusInUse.includes(x.id))
.map((y) => {
return y['name']

Check warning on line 78 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

78 line is not covered with tests
})

/**
Expand All @@ -88,7 +88,7 @@
if (value.trim().startsWith('http')) {
setProxy(value.trim())
} else {
setProxy('')

Check warning on line 91 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

91 line is not covered with tests
}
},
[setPartialProxy, setProxy]
Expand All @@ -105,10 +105,10 @@
relaunch: boolean = true
) => {
const appConfiguration: AppConfiguration =
await window.core?.api?.getAppConfigurations()
appConfiguration.quick_ask = e
await window.core?.api?.updateAppConfiguration(appConfiguration)
if (relaunch) window.core?.api?.relaunch()

Check warning on line 111 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

108-111 lines are not covered with tests
}

/**
Expand All @@ -118,15 +118,15 @@
* @returns void
*/
const updateVulkanEnabled = async (e: boolean, relaunch: boolean = true) => {
toaster({

Check warning on line 121 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

121 line is not covered with tests
title: 'Reload',
description: 'Vulkan settings updated. Reload now to apply the changes.',
})
stopModel()
setVulkanEnabled(e)
await saveSettings({ vulkan: e, gpusInUse: [] })

Check warning on line 127 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

125-127 lines are not covered with tests
// Relaunch to apply settings
if (relaunch) window.location.reload()

Check warning on line 129 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

129 line is not covered with tests
}

/**
Expand Down Expand Up @@ -174,7 +174,7 @@
try {
await fs.rm(`file://logs`)
} catch (err) {
console.error('Error clearing logs: ', err)

Check warning on line 177 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

177 line is not covered with tests
}

toaster({
Expand All @@ -190,15 +190,15 @@
* @returns
*/
const handleGPUChange = (gpuId: string) => {
let updatedGpusInUse = [...gpusInUse]
if (updatedGpusInUse.includes(gpuId)) {
updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId)
if (gpuEnabled && updatedGpusInUse.length === 0) {

Check warning on line 196 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

193-196 lines are not covered with tests
// Vulkan support only allow 1 active device at a time
if (vulkanEnabled) {
updatedGpusInUse = []

Check warning on line 199 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

198-199 lines are not covered with tests
}
updatedGpusInUse.push(gpuId)

Check warning on line 201 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

201 line is not covered with tests
}
} else {
// Vulkan support only allow 1 active device at a time
Expand Down Expand Up @@ -237,7 +237,7 @@
</div>

{/* CPU / GPU switching */}
{!isMac && gpuList.length > 0 && (
{!isMac && (
<div className="flex w-full flex-col items-start justify-between border-b border-[hsla(var(--app-border))] py-4 first:pt-0 last:border-none">
<div className="flex w-full items-start justify-between">
<div className="space-y-1">
Expand Down Expand Up @@ -314,81 +314,86 @@
/>
</div>
</div>
<div className="mt-2 flex w-full flex-col rounded-lg px-2 py-4">
<label className="mb-2 mr-2 inline-block font-medium">
Choose device(s)
</label>
<div className="relative w-full md:w-1/2" ref={setToggle}>
<Input
value={selectedGpu.join() || ''}
className="w-full cursor-pointer"
readOnly
placeholder=""
suffixIcon={
<ChevronDownIcon
size={14}
className={twMerge(open && 'rotate-180')}
/>
}
onClick={() => setOpen(!open)}
/>
<div
className={twMerge(
'absolute right-0 top-0 z-20 mt-10 max-h-80 w-full overflow-hidden rounded-lg border border-[hsla(var(--app-border))] bg-[hsla(var(--app-bg))] shadow-sm',
open ? 'flex' : 'hidden'
)}
ref={setDropdownOptions}
>
<div className="w-full p-4">
<p>{vulkanEnabled ? 'Vulkan Supported GPUs' : 'Nvidia'}</p>
<div className="py-2">
<div className="rounded-lg">
{gpuList
.filter((gpu) =>
vulkanEnabled
? gpu.name
: gpu.name?.toLowerCase().includes('nvidia')
)
.map((gpu) => (
<div
key={gpu.id}
className="mt-2 flex items-center space-x-2"
>
<Checkbox
id={`gpu-${gpu.id}`}
name="gpu-nvidia"
value={gpu.id}
checked={gpusInUse.includes(gpu.id)}
onChange={() => handleGPUChange(gpu.id)}
label={
<span>
<span>{gpu.name}</span>
{!vulkanEnabled && (
<span>{gpu.vram}MB VRAM</span>
)}
</span>
}
/>
</div>
))}
</div>
{gpuEnabled && gpusInUse.length > 1 && (
<div className="mt-2 flex items-start space-x-2 text-[hsla(var(--warning-bg))]">
<AlertTriangleIcon
size={16}
className="flex-shrink-0"
/>
<p className="text-xs leading-relaxed">
If multi-GPU is enabled with different GPU models or
without NVLink, it could impact token speed.
</p>

{gpuList.length > 0 && (
<div className="mt-2 flex w-full flex-col rounded-lg px-2 py-4">
<label className="mb-2 mr-2 inline-block font-medium">
Choose device(s)
</label>
<div className="relative w-full md:w-1/2" ref={setToggle}>
<Input
value={selectedGpu.join() || ''}
className="w-full cursor-pointer"
readOnly
placeholder=""
suffixIcon={
<ChevronDownIcon
size={14}
className={twMerge(open && 'rotate-180')}
/>
}
onClick={() => setOpen(!open)}
/>
<div
className={twMerge(
'absolute right-0 top-0 z-20 mt-10 max-h-80 w-full overflow-hidden rounded-lg border border-[hsla(var(--app-border))] bg-[hsla(var(--app-bg))] shadow-sm',
open ? 'flex' : 'hidden'
)}
ref={setDropdownOptions}
>
<div className="w-full p-4">
<p>
{vulkanEnabled ? 'Vulkan Supported GPUs' : 'Nvidia'}
</p>
<div className="py-2">
<div className="rounded-lg">
{gpuList
.filter((gpu) =>
vulkanEnabled
? gpu.name
: gpu.name?.toLowerCase().includes('nvidia')
)
.map((gpu) => (
<div
key={gpu.id}
className="mt-2 flex items-center space-x-2"
>
<Checkbox
id={`gpu-${gpu.id}`}
name="gpu-nvidia"
value={gpu.id}
checked={gpusInUse.includes(gpu.id)}
onChange={() => handleGPUChange(gpu.id)}
label={
<span>
<span>{gpu.name}</span>
{!vulkanEnabled && (
<span>{gpu.vram}MB VRAM</span>
)}
</span>
}
/>
</div>
))}
</div>
)}
{gpuEnabled && gpusInUse.length > 1 && (
<div className="mt-2 flex items-start space-x-2 text-[hsla(var(--warning-bg))]">
<AlertTriangleIcon
size={16}
className="flex-shrink-0"
/>
<p className="text-xs leading-relaxed">
If multi-GPU is enabled with different GPU models
or without NVLink, it could impact token speed.
</p>
</div>
)}
</div>
</div>
</div>
</div>
</div>
</div>
)}
</div>
)}

Expand Down
Loading