mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17: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,
|
onGpuCountChange,
|
||||||
onGpuDeviceIdChange,
|
onGpuDeviceIdChange,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
const showDeviceId = gpuCount !== "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.nvidiaConfig}>
|
<div className={styles.nvidiaConfig}>
|
||||||
<div className={styles.formGroup}>
|
<div className={styles.formGroup}>
|
||||||
@ -25,16 +27,15 @@ export default function NvidiaGpuConfig({
|
|||||||
<input
|
<input
|
||||||
id="dcg-gpu-count"
|
id="dcg-gpu-count"
|
||||||
type="text"
|
type="text"
|
||||||
|
inputMode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
className={styles.input}
|
className={styles.input}
|
||||||
value={gpuCount}
|
value={gpuCount}
|
||||||
placeholder="1 or all"
|
placeholder="all"
|
||||||
onChange={(e) => onGpuCountChange(e.target.value)}
|
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>
|
</div>
|
||||||
{gpuCount !== "all" && (
|
{showDeviceId && (
|
||||||
<div className={styles.formGroup}>
|
<div className={styles.formGroup}>
|
||||||
<label htmlFor="dcg-gpu-device-id" className={styles.label}>
|
<label htmlFor="dcg-gpu-device-id" className={styles.label}>
|
||||||
GPU device IDs (required, comma-separated):
|
GPU device IDs (required, comma-separated):
|
||||||
|
|||||||
@ -123,7 +123,7 @@ function buildEnvironment(
|
|||||||
function buildDeploy(device: DeviceConfig, input: GeneratorInput): string[] {
|
function buildDeploy(device: DeviceConfig, input: GeneratorInput): string[] {
|
||||||
if (device.id === "stable-tensorrt") {
|
if (device.id === "stable-tensorrt") {
|
||||||
const count = input.nvidiaGpuCount || "all";
|
const count = input.nvidiaGpuCount || "all";
|
||||||
const isAll = count.toLowerCase() === "all";
|
const isAll = count === "all";
|
||||||
const deviceId = input.nvidiaGpuDeviceId?.trim();
|
const deviceId = input.nvidiaGpuDeviceId?.trim();
|
||||||
|
|
||||||
if (isAll) {
|
if (isAll) {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export function useConfigGenerator() {
|
|||||||
return initial;
|
return initial;
|
||||||
});
|
});
|
||||||
|
|
||||||
const [nvidiaGpuCount, setNvidiaGpuCount] = useState("all");
|
const [nvidiaGpuCount, setNvidiaGpuCount] = useState("");
|
||||||
const [nvidiaGpuDeviceId, setNvidiaGpuDeviceId] = useState("");
|
const [nvidiaGpuDeviceId, setNvidiaGpuDeviceId] = useState("");
|
||||||
const [configPath, setConfigPath] = useState("");
|
const [configPath, setConfigPath] = useState("");
|
||||||
const [mediaPath, setMediaPath] = useState("");
|
const [mediaPath, setMediaPath] = useState("");
|
||||||
@ -56,7 +56,7 @@ export function useConfigGenerator() {
|
|||||||
}
|
}
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
setNvidiaGpuCount("all");
|
setNvidiaGpuCount("");
|
||||||
setNvidiaGpuDeviceId("");
|
setNvidiaGpuDeviceId("");
|
||||||
setGpuDeviceIdError(false);
|
setGpuDeviceIdError(false);
|
||||||
}, []);
|
}, []);
|
||||||
@ -121,15 +121,13 @@ export function useConfigGenerator() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleNvidiaGpuCountChange = useCallback((value: string) => {
|
const handleNvidiaGpuCountChange = useCallback((value: string) => {
|
||||||
const lower = value.trim().toLowerCase();
|
// Only allow digits
|
||||||
if (lower === "all" || lower === "" || /^[0-9]+$/.test(lower)) {
|
setNvidiaGpuCount(value);
|
||||||
setNvidiaGpuCount(lower || "all");
|
if (value === "") {
|
||||||
if (lower === "all") {
|
setNvidiaGpuDeviceId("");
|
||||||
setNvidiaGpuDeviceId("");
|
setGpuDeviceIdError(false);
|
||||||
setGpuDeviceIdError(false);
|
} else {
|
||||||
} else if (/^[0-9]+$/.test(lower)) {
|
setGpuDeviceIdError(false);
|
||||||
setGpuDeviceIdError(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user