mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 11:07:41 +03:00
docs: improve NVIDIA GPU count input
This commit is contained in:
parent
6cc4db1103
commit
4b421c66a5
@ -16,6 +16,8 @@ export default function NvidiaGpuConfig({
|
||||
onGpuCountChange,
|
||||
onGpuDeviceIdChange,
|
||||
}: Props) {
|
||||
const showDeviceId = gpuCount !== "";
|
||||
|
||||
return (
|
||||
<div className={styles.nvidiaConfig}>
|
||||
<div className={styles.formGroup}>
|
||||
@ -25,16 +27,15 @@ export default function NvidiaGpuConfig({
|
||||
<input
|
||||
id="dcg-gpu-count"
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
className={styles.input}
|
||||
value={gpuCount}
|
||||
placeholder="1 or all"
|
||||
onChange={(e) => onGpuCountChange(e.target.value)}
|
||||
placeholder="all"
|
||||
onChange={(e) => onGpuCountChange(e.target.value.replace(/\D/g, ""))}
|
||||
/>
|
||||
<p className={styles.helpText}>
|
||||
Enter a number (e.g. 1, 2, 3) or "all" to use all GPUs
|
||||
</p>
|
||||
</div>
|
||||
{gpuCount !== "all" && (
|
||||
{showDeviceId && (
|
||||
<div className={styles.formGroup}>
|
||||
<label htmlFor="dcg-gpu-device-id" className={styles.label}>
|
||||
GPU device IDs (required, comma-separated):
|
||||
|
||||
@ -123,7 +123,7 @@ function buildEnvironment(
|
||||
function buildDeploy(device: DeviceConfig, input: GeneratorInput): string[] {
|
||||
if (device.id === "stable-tensorrt") {
|
||||
const count = input.nvidiaGpuCount || "all";
|
||||
const isAll = count.toLowerCase() === "all";
|
||||
const isAll = count === "all";
|
||||
const deviceId = input.nvidiaGpuDeviceId?.trim();
|
||||
|
||||
if (isAll) {
|
||||
|
||||
@ -29,7 +29,7 @@ export function useConfigGenerator() {
|
||||
return initial;
|
||||
});
|
||||
|
||||
const [nvidiaGpuCount, setNvidiaGpuCount] = useState("all");
|
||||
const [nvidiaGpuCount, setNvidiaGpuCount] = useState("");
|
||||
const [nvidiaGpuDeviceId, setNvidiaGpuDeviceId] = useState("");
|
||||
const [configPath, setConfigPath] = useState("");
|
||||
const [mediaPath, setMediaPath] = useState("");
|
||||
@ -56,7 +56,7 @@ export function useConfigGenerator() {
|
||||
}
|
||||
return next;
|
||||
});
|
||||
setNvidiaGpuCount("all");
|
||||
setNvidiaGpuCount("");
|
||||
setNvidiaGpuDeviceId("");
|
||||
setGpuDeviceIdError(false);
|
||||
}, []);
|
||||
@ -121,15 +121,13 @@ export function useConfigGenerator() {
|
||||
);
|
||||
|
||||
const handleNvidiaGpuCountChange = useCallback((value: string) => {
|
||||
const lower = value.trim().toLowerCase();
|
||||
if (lower === "all" || lower === "" || /^[0-9]+$/.test(lower)) {
|
||||
setNvidiaGpuCount(lower || "all");
|
||||
if (lower === "all") {
|
||||
setNvidiaGpuDeviceId("");
|
||||
setGpuDeviceIdError(false);
|
||||
} else if (/^[0-9]+$/.test(lower)) {
|
||||
setGpuDeviceIdError(false);
|
||||
}
|
||||
// Only allow digits
|
||||
setNvidiaGpuCount(value);
|
||||
if (value === "") {
|
||||
setNvidiaGpuDeviceId("");
|
||||
setGpuDeviceIdError(false);
|
||||
} else {
|
||||
setGpuDeviceIdError(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user