forked from Github/frigate
Improve Nvidia GPU stats (#14206)
* :Add support for nvidia driver info * Don't show temperature if detector isn't called coral * Add encoder and decoder info for Nvidia GPUs * Fix device info * Implement GPU info for nvidia GPU * Update web/src/views/system/GeneralMetrics.tsx Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> * Update web/src/views/system/GeneralMetrics.tsx Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> --------- Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
100
web/src/components/overlay/GPUInfoDialog.tsx
Normal file
100
web/src/components/overlay/GPUInfoDialog.tsx
Normal file
@@ -0,0 +1,100 @@
|
||||
import useSWR from "swr";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "../ui/dialog";
|
||||
import ActivityIndicator from "../indicators/activity-indicator";
|
||||
import { GpuInfo, Nvinfo, Vainfo } from "@/types/stats";
|
||||
import { Button } from "../ui/button";
|
||||
import copy from "copy-to-clipboard";
|
||||
|
||||
type GPUInfoDialogProps = {
|
||||
showGpuInfo: boolean;
|
||||
gpuType: GpuInfo;
|
||||
setShowGpuInfo: (show: boolean) => void;
|
||||
};
|
||||
export default function GPUInfoDialog({
|
||||
showGpuInfo,
|
||||
gpuType,
|
||||
setShowGpuInfo,
|
||||
}: GPUInfoDialogProps) {
|
||||
const { data: vainfo } = useSWR<Vainfo>(
|
||||
showGpuInfo && gpuType == "vainfo" ? "vainfo" : null,
|
||||
);
|
||||
const { data: nvinfo } = useSWR<Nvinfo>(
|
||||
showGpuInfo && gpuType == "nvinfo" ? "nvinfo" : null,
|
||||
);
|
||||
|
||||
const onCopyInfo = async () => {
|
||||
copy(
|
||||
JSON.stringify(gpuType == "vainfo" ? vainfo : nvinfo).replace(
|
||||
/[\\\s]+/gi,
|
||||
"",
|
||||
),
|
||||
);
|
||||
setShowGpuInfo(false);
|
||||
};
|
||||
|
||||
if (gpuType == "vainfo") {
|
||||
return (
|
||||
<Dialog open={showGpuInfo} onOpenChange={setShowGpuInfo}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Vainfo Output</DialogTitle>
|
||||
</DialogHeader>
|
||||
{vainfo ? (
|
||||
<div className="scrollbar-container mb-2 max-h-96 overflow-y-scroll whitespace-pre-line">
|
||||
<div>Return Code: {vainfo.return_code}</div>
|
||||
<br />
|
||||
<div>Process {vainfo.return_code == 0 ? "Output" : "Error"}:</div>
|
||||
<br />
|
||||
<div>
|
||||
{vainfo.return_code == 0 ? vainfo.stdout : vainfo.stderr}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<ActivityIndicator />
|
||||
)}
|
||||
<DialogFooter>
|
||||
<Button onClick={() => setShowGpuInfo(false)}>Close</Button>
|
||||
<Button variant="select" onClick={() => onCopyInfo()}>
|
||||
Copy
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Dialog open={showGpuInfo} onOpenChange={setShowGpuInfo}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Nvidia SMI Output</DialogTitle>
|
||||
</DialogHeader>
|
||||
{nvinfo ? (
|
||||
<div className="scrollbar-container mb-2 max-h-96 overflow-y-scroll whitespace-pre-line">
|
||||
<div>Name: {nvinfo["0"].name}</div>
|
||||
<br />
|
||||
<div>Driver: {nvinfo["0"].driver}</div>
|
||||
<br />
|
||||
<div>Cuda Compute Capability: {nvinfo["0"].cuda_compute}</div>
|
||||
<br />
|
||||
<div>VBios Info: {nvinfo["0"].vbios}</div>
|
||||
</div>
|
||||
) : (
|
||||
<ActivityIndicator />
|
||||
)}
|
||||
<DialogFooter>
|
||||
<Button onClick={() => setShowGpuInfo(false)}>Close</Button>
|
||||
<Button variant="select" onClick={() => onCopyInfo()}>
|
||||
Copy
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import useSWR from "swr";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "../ui/dialog";
|
||||
import ActivityIndicator from "../indicators/activity-indicator";
|
||||
import { Vainfo } from "@/types/stats";
|
||||
import { Button } from "../ui/button";
|
||||
import copy from "copy-to-clipboard";
|
||||
|
||||
type VainfoDialogProps = {
|
||||
showVainfo: boolean;
|
||||
setShowVainfo: (show: boolean) => void;
|
||||
};
|
||||
export default function VainfoDialog({
|
||||
showVainfo,
|
||||
setShowVainfo,
|
||||
}: VainfoDialogProps) {
|
||||
const { data: vainfo } = useSWR<Vainfo>(showVainfo ? "vainfo" : null);
|
||||
|
||||
const onCopyVainfo = async () => {
|
||||
copy(JSON.stringify(vainfo).replace(/[\\\s]+/gi, ""));
|
||||
setShowVainfo(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={showVainfo} onOpenChange={setShowVainfo}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Vainfo Output</DialogTitle>
|
||||
</DialogHeader>
|
||||
{vainfo ? (
|
||||
<div className="scrollbar-container mb-2 max-h-96 overflow-y-scroll whitespace-pre-line">
|
||||
<div>Return Code: {vainfo.return_code}</div>
|
||||
<br />
|
||||
<div>Process {vainfo.return_code == 0 ? "Output" : "Error"}:</div>
|
||||
<br />
|
||||
<div>{vainfo.return_code == 0 ? vainfo.stdout : vainfo.stderr}</div>
|
||||
</div>
|
||||
) : (
|
||||
<ActivityIndicator />
|
||||
)}
|
||||
<DialogFooter>
|
||||
<Button onClick={() => setShowVainfo(false)}>Close</Button>
|
||||
<Button variant="select" onClick={() => onCopyVainfo()}>
|
||||
Copy
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user