chore: add GPU driver and toolkit status (#2628)
This commit is contained in:
parent
c5c3156b28
commit
f8cf93a906
@ -221,6 +221,7 @@ const updateGpuInfo = async () =>
|
||||
|
||||
data = updateCudaExistence(data)
|
||||
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
||||
log(`[APP]::${JSON.stringify(data)}`)
|
||||
resolve({})
|
||||
} else {
|
||||
reject(error)
|
||||
@ -263,6 +264,7 @@ const updateGpuInfo = async () =>
|
||||
|
||||
data = updateCudaExistence(data)
|
||||
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
||||
log(`[APP]::${JSON.stringify(data)}`)
|
||||
resolve({})
|
||||
}
|
||||
)
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
import React from 'react'
|
||||
|
||||
import { openExternalUrl } from '@janhq/core'
|
||||
|
||||
import {
|
||||
ModalClose,
|
||||
ModalFooter,
|
||||
ModalContent,
|
||||
Modal,
|
||||
ModalTitle,
|
||||
ModalHeader,
|
||||
Button,
|
||||
} from '@janhq/uikit'
|
||||
|
||||
import { useAtom } from 'jotai'
|
||||
|
||||
import { isShowNotificationAtom, useSettings } from '@/hooks/useSettings'
|
||||
|
||||
const GPUDriverPrompt: React.FC = () => {
|
||||
const [showNotification, setShowNotification] = useAtom(
|
||||
isShowNotificationAtom
|
||||
)
|
||||
|
||||
const { saveSettings } = useSettings()
|
||||
const onDoNotShowAgainChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const isChecked = !e.target.checked
|
||||
saveSettings({ notify: isChecked })
|
||||
}
|
||||
|
||||
const openChanged = () => {
|
||||
setShowNotification(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Modal open={showNotification} onOpenChange={openChanged}>
|
||||
<ModalContent>
|
||||
<ModalHeader>
|
||||
<ModalTitle className="pr-4 leading-relaxed">
|
||||
Checking for machine that does not meet the requirements.
|
||||
</ModalTitle>
|
||||
</ModalHeader>
|
||||
<p>
|
||||
It appears that you are missing some dependencies required to run in
|
||||
GPU mode. Please follow the instructions below for more details{' '}
|
||||
<span
|
||||
className="cursor-pointer text-blue-600"
|
||||
onClick={() =>
|
||||
openExternalUrl(
|
||||
'https://jan.ai/guides/troubleshooting/gpu-not-used/'
|
||||
)
|
||||
}
|
||||
>
|
||||
Jan is Not Using GPU
|
||||
</span>{' '}
|
||||
.
|
||||
</p>
|
||||
<div className="flex items-center space-x-2">
|
||||
<input
|
||||
id="default-checkbox"
|
||||
type="checkbox"
|
||||
onChange={onDoNotShowAgainChange}
|
||||
className="h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800 dark:focus:ring-blue-600"
|
||||
/>
|
||||
<span>Don't show again</span>
|
||||
</div>
|
||||
<ModalFooter>
|
||||
<div className="flex gap-x-2">
|
||||
<ModalClose asChild>
|
||||
<Button themes="ghost">OK</Button>
|
||||
</ModalClose>
|
||||
</div>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default GPUDriverPrompt
|
||||
@ -6,7 +6,6 @@ import { Toaster } from 'react-hot-toast'
|
||||
|
||||
import { TooltipProvider } from '@janhq/uikit'
|
||||
|
||||
import GPUDriverPrompt from '@/containers/GPUDriverPromptModal'
|
||||
import EventListenerWrapper from '@/containers/Providers/EventListener'
|
||||
import JotaiWrapper from '@/containers/Providers/Jotai'
|
||||
import ThemeWrapper from '@/containers/Providers/Theme'
|
||||
@ -81,7 +80,6 @@ const Providers = ({ children }: PropsWithChildren) => {
|
||||
<TooltipProvider delayDuration={0}>
|
||||
<DataLoader>{children}</DataLoader>
|
||||
</TooltipProvider>
|
||||
{!isMac && <GPUDriverPrompt />}
|
||||
</EventListenerWrapper>
|
||||
<Toaster />
|
||||
</KeyListener>
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
|
||||
import { fs, joinPath } from '@janhq/core'
|
||||
import { atom, useAtom } from 'jotai'
|
||||
|
||||
export const isShowNotificationAtom = atom<boolean>(false)
|
||||
|
||||
export type AppSettings = {
|
||||
run_mode: 'cpu' | 'gpu' | undefined
|
||||
@ -15,9 +12,6 @@ export type AppSettings = {
|
||||
|
||||
export const useSettings = () => {
|
||||
const [isGPUModeEnabled, setIsGPUModeEnabled] = useState(false) // New state for GPU mode
|
||||
const [showNotification, setShowNotification] = useAtom(
|
||||
isShowNotificationAtom
|
||||
)
|
||||
const [settings, setSettings] = useState<AppSettings>()
|
||||
|
||||
useEffect(() => {
|
||||
@ -29,15 +23,6 @@ export const useSettings = () => {
|
||||
|
||||
const validateSettings = async () => {
|
||||
readSettings().then((settings) => {
|
||||
if (
|
||||
settings &&
|
||||
settings.notify &&
|
||||
((settings.nvidia_driver?.exist && !settings.cuda?.exist) ||
|
||||
!settings.nvidia_driver?.exist)
|
||||
) {
|
||||
setShowNotification(false)
|
||||
}
|
||||
|
||||
// Check if run_mode is 'gpu' or 'cpu' and update state accordingly
|
||||
setIsGPUModeEnabled(settings?.run_mode === 'gpu')
|
||||
})
|
||||
@ -84,11 +69,9 @@ export const useSettings = () => {
|
||||
}
|
||||
|
||||
return {
|
||||
showNotification,
|
||||
isGPUModeEnabled,
|
||||
readSettings,
|
||||
saveSettings,
|
||||
setShowNotification,
|
||||
validateSettings,
|
||||
settings,
|
||||
}
|
||||
|
||||
@ -67,8 +67,7 @@ const Advanced = () => {
|
||||
const [gpuList, setGpuList] = useState<GPU[]>([])
|
||||
const [gpusInUse, setGpusInUse] = useState<string[]>([])
|
||||
|
||||
const { readSettings, saveSettings, validateSettings, setShowNotification } =
|
||||
useSettings()
|
||||
const { readSettings, saveSettings, validateSettings } = useSettings()
|
||||
const { stopModel } = useActiveModel()
|
||||
|
||||
const selectedGpu = gpuList
|
||||
@ -273,7 +272,6 @@ const Advanced = () => {
|
||||
if (e === true) {
|
||||
saveSettings({ runMode: 'gpu' })
|
||||
setGpuEnabled(true)
|
||||
setShowNotification(false)
|
||||
snackbar({
|
||||
description:
|
||||
'Successfully turned on GPU Acceleration',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user