From f8cf93a906ebe269c724228afa925967edb0901c Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 8 Apr 2024 09:50:16 +0700 Subject: [PATCH] chore: add GPU driver and toolkit status (#2628) --- .../monitoring-extension/src/node/index.ts | 2 + web/containers/GPUDriverPromptModal/index.tsx | 79 ------------------- web/containers/Providers/index.tsx | 2 - web/hooks/useSettings.ts | 17 ---- web/screens/Settings/Advanced/index.tsx | 4 +- 5 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 web/containers/GPUDriverPromptModal/index.tsx diff --git a/extensions/monitoring-extension/src/node/index.ts b/extensions/monitoring-extension/src/node/index.ts index b40cdbfe33..dc3ee8d815 100644 --- a/extensions/monitoring-extension/src/node/index.ts +++ b/extensions/monitoring-extension/src/node/index.ts @@ -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({}) } ) diff --git a/web/containers/GPUDriverPromptModal/index.tsx b/web/containers/GPUDriverPromptModal/index.tsx deleted file mode 100644 index bdcf1b2f8f..0000000000 --- a/web/containers/GPUDriverPromptModal/index.tsx +++ /dev/null @@ -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) => { - const isChecked = !e.target.checked - saveSettings({ notify: isChecked }) - } - - const openChanged = () => { - setShowNotification(false) - } - - return ( -
- - - - - Checking for machine that does not meet the requirements. - - -

- It appears that you are missing some dependencies required to run in - GPU mode. Please follow the instructions below for more details{' '} - - openExternalUrl( - 'https://jan.ai/guides/troubleshooting/gpu-not-used/' - ) - } - > - Jan is Not Using GPU - {' '} - . -

-
- - Don't show again -
- -
- - - -
-
-
-
-
- ) -} -export default GPUDriverPrompt diff --git a/web/containers/Providers/index.tsx b/web/containers/Providers/index.tsx index 999979758d..66ba42a7da 100644 --- a/web/containers/Providers/index.tsx +++ b/web/containers/Providers/index.tsx @@ -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) => { {children} - {!isMac && } diff --git a/web/hooks/useSettings.ts b/web/hooks/useSettings.ts index 9ff733f155..1930a10e05 100644 --- a/web/hooks/useSettings.ts +++ b/web/hooks/useSettings.ts @@ -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(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() 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, } diff --git a/web/screens/Settings/Advanced/index.tsx b/web/screens/Settings/Advanced/index.tsx index 035119accd..b8312258bb 100644 --- a/web/screens/Settings/Advanced/index.tsx +++ b/web/screens/Settings/Advanced/index.tsx @@ -67,8 +67,7 @@ const Advanced = () => { const [gpuList, setGpuList] = useState([]) const [gpusInUse, setGpusInUse] = useState([]) - 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',