Skip to content

Commit

Permalink
chore: add GPU driver and toolkit status
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-menlo committed Apr 5, 2024
1 parent 9303e7a commit b3b5c66
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 105 deletions.
2 changes: 2 additions & 0 deletions extensions/monitoring-extension/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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({})
}
)
Expand Down
79 changes: 0 additions & 79 deletions web/containers/GPUDriverPromptModal/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions web/containers/Providers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -81,7 +80,6 @@ const Providers = ({ children }: PropsWithChildren) => {
<TooltipProvider delayDuration={0}>
<DataLoader>{children}</DataLoader>
</TooltipProvider>
{!isMac && <GPUDriverPrompt />}
</EventListenerWrapper>
<Toaster />
</KeyListener>
Expand Down
11 changes: 7 additions & 4 deletions web/hooks/useGetSystemResources.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useState } from 'react'

import { ExtensionTypeEnum, MonitoringExtension } from '@janhq/core'
import { ExtensionTypeEnum, log, MonitoringExtension } from '@janhq/core'

import { useSetAtom } from 'jotai'
import { useAtom, useSetAtom } from 'jotai'

import { extensionManager } from '@/extension/ExtensionManager'
import {
Expand All @@ -21,7 +21,7 @@ export default function useGetSystemResources() {
>(undefined)

const setTotalRam = useSetAtom(totalRamAtom)
const setGpus = useSetAtom(gpusAtom)
const [gpus, setGpus] = useAtom(gpusAtom)
const setUsedRam = useSetAtom(usedRamAtom)
const setCpuUsage = useSetAtom(cpuUsageAtom)
const setTotalNvidiaVram = useSetAtom(nvidiaTotalVramAtom)
Expand Down Expand Up @@ -97,12 +97,15 @@ export default function useGetSystemResources() {
}, [intervalId])

useEffect(() => {
getSystemResources()
getSystemResources().then(
() => gpus.length > 0 && log(`[APP]::${JSON.stringify(gpus)}`)
)
// Component did unmount
// Stop watching if any
return () => {
stopWatching()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [getSystemResources, stopWatching])

return {
Expand Down
17 changes: 0 additions & 17 deletions web/hooks/useSettings.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(() => {
Expand All @@ -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')
})
Expand Down Expand Up @@ -84,11 +69,9 @@ export const useSettings = () => {
}

return {
showNotification,
isGPUModeEnabled,
readSettings,
saveSettings,
setShowNotification,
validateSettings,
settings,
}
Expand Down
4 changes: 1 addition & 3 deletions web/screens/Settings/Advanced/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -273,7 +272,6 @@ const Advanced = () => {
if (e === true) {
saveSettings({ runMode: 'gpu' })
setGpuEnabled(true)
setShowNotification(false)
snackbar({
description:
'Successfully turned on GPU Acceleration',
Expand Down

0 comments on commit b3b5c66

Please sign in to comment.