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)
|
data = updateCudaExistence(data)
|
||||||
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
||||||
|
log(`[APP]::${JSON.stringify(data)}`)
|
||||||
resolve({})
|
resolve({})
|
||||||
} else {
|
} else {
|
||||||
reject(error)
|
reject(error)
|
||||||
@ -263,6 +264,7 @@ const updateGpuInfo = async () =>
|
|||||||
|
|
||||||
data = updateCudaExistence(data)
|
data = updateCudaExistence(data)
|
||||||
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
writeFileSync(GPU_INFO_FILE, JSON.stringify(data, null, 2))
|
||||||
|
log(`[APP]::${JSON.stringify(data)}`)
|
||||||
resolve({})
|
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 { TooltipProvider } from '@janhq/uikit'
|
||||||
|
|
||||||
import GPUDriverPrompt from '@/containers/GPUDriverPromptModal'
|
|
||||||
import EventListenerWrapper from '@/containers/Providers/EventListener'
|
import EventListenerWrapper from '@/containers/Providers/EventListener'
|
||||||
import JotaiWrapper from '@/containers/Providers/Jotai'
|
import JotaiWrapper from '@/containers/Providers/Jotai'
|
||||||
import ThemeWrapper from '@/containers/Providers/Theme'
|
import ThemeWrapper from '@/containers/Providers/Theme'
|
||||||
@ -81,7 +80,6 @@ const Providers = ({ children }: PropsWithChildren) => {
|
|||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
<DataLoader>{children}</DataLoader>
|
<DataLoader>{children}</DataLoader>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
{!isMac && <GPUDriverPrompt />}
|
|
||||||
</EventListenerWrapper>
|
</EventListenerWrapper>
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</KeyListener>
|
</KeyListener>
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react'
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { fs, joinPath } from '@janhq/core'
|
import { fs, joinPath } from '@janhq/core'
|
||||||
import { atom, useAtom } from 'jotai'
|
|
||||||
|
|
||||||
export const isShowNotificationAtom = atom<boolean>(false)
|
|
||||||
|
|
||||||
export type AppSettings = {
|
export type AppSettings = {
|
||||||
run_mode: 'cpu' | 'gpu' | undefined
|
run_mode: 'cpu' | 'gpu' | undefined
|
||||||
@ -15,9 +12,6 @@ export type AppSettings = {
|
|||||||
|
|
||||||
export const useSettings = () => {
|
export const useSettings = () => {
|
||||||
const [isGPUModeEnabled, setIsGPUModeEnabled] = useState(false) // New state for GPU mode
|
const [isGPUModeEnabled, setIsGPUModeEnabled] = useState(false) // New state for GPU mode
|
||||||
const [showNotification, setShowNotification] = useAtom(
|
|
||||||
isShowNotificationAtom
|
|
||||||
)
|
|
||||||
const [settings, setSettings] = useState<AppSettings>()
|
const [settings, setSettings] = useState<AppSettings>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -29,15 +23,6 @@ export const useSettings = () => {
|
|||||||
|
|
||||||
const validateSettings = async () => {
|
const validateSettings = async () => {
|
||||||
readSettings().then((settings) => {
|
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
|
// Check if run_mode is 'gpu' or 'cpu' and update state accordingly
|
||||||
setIsGPUModeEnabled(settings?.run_mode === 'gpu')
|
setIsGPUModeEnabled(settings?.run_mode === 'gpu')
|
||||||
})
|
})
|
||||||
@ -84,11 +69,9 @@ export const useSettings = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showNotification,
|
|
||||||
isGPUModeEnabled,
|
isGPUModeEnabled,
|
||||||
readSettings,
|
readSettings,
|
||||||
saveSettings,
|
saveSettings,
|
||||||
setShowNotification,
|
|
||||||
validateSettings,
|
validateSettings,
|
||||||
settings,
|
settings,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,8 +67,7 @@ const Advanced = () => {
|
|||||||
const [gpuList, setGpuList] = useState<GPU[]>([])
|
const [gpuList, setGpuList] = useState<GPU[]>([])
|
||||||
const [gpusInUse, setGpusInUse] = useState<string[]>([])
|
const [gpusInUse, setGpusInUse] = useState<string[]>([])
|
||||||
|
|
||||||
const { readSettings, saveSettings, validateSettings, setShowNotification } =
|
const { readSettings, saveSettings, validateSettings } = useSettings()
|
||||||
useSettings()
|
|
||||||
const { stopModel } = useActiveModel()
|
const { stopModel } = useActiveModel()
|
||||||
|
|
||||||
const selectedGpu = gpuList
|
const selectedGpu = gpuList
|
||||||
@ -273,7 +272,6 @@ const Advanced = () => {
|
|||||||
if (e === true) {
|
if (e === true) {
|
||||||
saveSettings({ runMode: 'gpu' })
|
saveSettings({ runMode: 'gpu' })
|
||||||
setGpuEnabled(true)
|
setGpuEnabled(true)
|
||||||
setShowNotification(false)
|
|
||||||
snackbar({
|
snackbar({
|
||||||
description:
|
description:
|
||||||
'Successfully turned on GPU Acceleration',
|
'Successfully turned on GPU Acceleration',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user