Vector Motion
AI/ML

Hardware Utilization Card - Resource Monitoring

Monitor hardware resource utilization (CPU, GPU, memory) for ML workloads. Optimize infrastructure costs and track compute resource performance.

Hardware Utilization Card

The Hardware Utilization Card displays GPU, CPU, and memory usage for machine learning training and inference workloads.

Preview

Installation

npx shadcn@latest add https://vectormotion.vercel.app/registry/hardware-util-card.json
Hardware Utilization Card
'use client'import React from 'react';import { Cpu, CircuitBoard, Database } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx"import { twMerge } from "tailwind-merge"import { ResponsiveContainer, PieChart, Pie, Cell, Tooltip } from 'recharts';function cn(...inputs: ClassValue[]) {   return twMerge(clsx(inputs))}interface HardwareData {   name: string;   value: number;   fill: string;   [key: string]: any;}interface HardwareUtilCardProps {   className?: string;   title?: string;   gpuName?: string;   data?: HardwareData[];   gpuUsagePercentage?: string;   vramUsage?: string;   totalVram?: string;   computeUsagePercentage?: number;}const DEFAULT_DATA: HardwareData[] = [   { name: 'Used', value: 32, fill: '#22c55e' }, // Green-500   { name: 'Free', value: 8, fill: '#e4e4e7' },  // Zinc-200];const DEFAULT_TITLE = "GPU Status";const DEFAULT_GPU_NAME = "NVIDIA A100";const DEFAULT_GPU_USAGE_PERCENTAGE = "80%";const DEFAULT_VRAM_USAGE = "32";const DEFAULT_TOTAL_VRAM = "40 GB";const DEFAULT_COMPUTE_USAGE_PERCENTAGE = 92;export const HardwareUtilCard: React.FC<HardwareUtilCardProps> = ({   className = "",   title = DEFAULT_TITLE,   gpuName = DEFAULT_GPU_NAME,   data = DEFAULT_DATA,   gpuUsagePercentage = DEFAULT_GPU_USAGE_PERCENTAGE,   vramUsage = DEFAULT_VRAM_USAGE,   totalVram = DEFAULT_TOTAL_VRAM,   computeUsagePercentage = DEFAULT_COMPUTE_USAGE_PERCENTAGE,}) => {   return (      <motion.div         initial={{ opacity: 0, y: 20 }}         animate={{ opacity: 1, y: 0 }}         transition={{ duration: 0.5, delay: 0.2 }}         className={cn(            "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-green-300 dark:hover:border-green-700 hover:shadow-md flex flex-col h-full",            className         )}      >         <div className="p-5 flex flex-col h-full relative z-10">            <div className="mb-4 flex items-start justify-between">               <div>                  <h3 className="font-bold text-lg text-foreground">                     {title}                  </h3>                  <div className="flex items-center gap-1.5 mt-1 text-sm font-mono text-muted-foreground">                     <Cpu className="w-3 h-3" />                     {gpuName}                  </div>               </div>               <div className="rounded-lg border-2 border-green-100 dark:border-green-800 p-2 text-green-500 dark:text-green-400 flex items-center justify-center">                  <Database className="h-5 w-5" />               </div>            </div>            <div className="flex items-center gap-4 flex-1">               <div className="w-[100px] h-[100px] relative flex-shrink-0">                  <ResponsiveContainer width="100%" height="100%">                     <PieChart>                        <Pie                           data={data}                           cx="50%"                           cy="50%"                           innerRadius={35}                           outerRadius={50}                           startAngle={90}                           endAngle={-270}                           dataKey="value"                           stroke="none"                        >                           {data.map((entry, index) => (                              <Cell key={`cell-${index}`} fill={entry.fill} />                           ))}                        </Pie>                        <Tooltip cursor={false} content={() => null} />                     </PieChart>                  </ResponsiveContainer>                  <div className="absolute inset-0 flex items-center justify-center">                     <span className="text-sm font-bold text-foreground">{gpuUsagePercentage}</span>                  </div>               </div>               <div className="flex-1 space-y-3">                  <div>                     <div className="flex justify-between text-xs mb-1">                        <span className="text-muted-foreground">Memory (VRAM)</span>                        <span className="font-bold text-foreground">{vramUsage}/{totalVram}</span>                     </div>                     <div className="w-full bg-zinc-100 dark:bg-zinc-800 h-1.5 rounded-full overflow-hidden">                        <div className="h-full bg-green-500" style={{ width: gpuUsagePercentage }} />                     </div>                  </div>                  <div>                     <div className="flex justify-between text-xs mb-1">                        <span className="text-muted-foreground">Compute</span>                        <span className="font-bold text-foreground">{computeUsagePercentage}%</span>                     </div>                     <div className="w-full bg-zinc-100 dark:bg-zinc-800 h-1.5 rounded-full overflow-hidden">                        <div className="h-full bg-green-400" style={{ width: `${computeUsagePercentage}%` }} />                     </div>                  </div>               </div>            </div>            <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none">               <Cpu className="w-40 h-40 text-green-500" />            </div>         </div>      </motion.div>   );};

Props

Prop

Type

Usage

This component is a demo card displaying hardware utilization metrics with animated visualizations and dark mode support.