import AutoTooltip from '@/components/auto-tooltip';
import { convertFileSize } from '@/utils';
import { useIntl } from '@umijs/max';
import _ from 'lodash';
import React from 'react';
import '../style/gpu-card.less';
const GPUCard: React.FC<{
data: any;
header?: React.ReactNode;
info?: React.ReactNode;
}> = ({ data, header, info }) => {
const intl = useIntl();
return (
{header ?? (
[{data.index}]
{data.label}
)}
{info ?? (
<>
{intl.formatMessage({ id: 'resources.table.vram' })}(
{intl.formatMessage({ id: 'resources.table.used' })}/
{intl.formatMessage({ id: 'resources.table.total' })}):{' '}
{convertFileSize(
data?.memory?.used || data?.memory?.allocated || 0
)}{' '}
/ {convertFileSize(data?.memory?.total || 0)}
{intl.formatMessage({ id: 'resources.table.gpuutilization' })}:{' '}
{data?.memory?.used
? _.round(data?.memory?.utilization_rate || 0, 2)
: _.round(data.memory?.allocated / data.memory?.total, 2) * 100}
%
>
)}
);
};
export default React.memo(GPUCard);