fix(deployments): display gpu allocated value in gpu selector
This commit is contained in:
@@ -77,7 +77,7 @@ export default function useAddResource(options?: { onCreated?: () => void }) {
|
||||
}, [resourceAtom, loadingStatus]);
|
||||
|
||||
const contentInfo = useMemo(() => {
|
||||
if (!resourceCount.cluster_count) {
|
||||
if (!resourceCount?.cluster_count) {
|
||||
return {
|
||||
title: intl.formatMessage({ id: 'noresult.cluster.title' }),
|
||||
subTitle: intl.formatMessage({ id: 'noresult.resources.cluster' }),
|
||||
@@ -98,7 +98,7 @@ export default function useAddResource(options?: { onCreated?: () => void }) {
|
||||
const handleCreate = () => {
|
||||
setHideModalTemporarily(true);
|
||||
onCreated?.();
|
||||
if (!resourceCount.cluster_count) {
|
||||
if (!resourceCount?.cluster_count) {
|
||||
setClusterSession({
|
||||
firstAddWorker: false,
|
||||
firstAddCluster: true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { convertFileSize } from '@/utils';
|
||||
import { AutoTooltip } from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Flex } from 'antd';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import '../style/gpu-card.less';
|
||||
@@ -19,12 +20,17 @@ const Header = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const ItemInfo = styled.div`
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
white-space: break-spaces;
|
||||
font-size: 13px;
|
||||
`;
|
||||
const Metric: React.FC<{ label: React.ReactNode; value: React.ReactNode }> = ({
|
||||
label,
|
||||
value
|
||||
}) => (
|
||||
<span style={{ lineHeight: 1.2 }}>
|
||||
{label}:{' '}
|
||||
<span className="font-500" style={{ color: 'var(--ant-color-text)' }}>
|
||||
{value}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
const Description = styled.div`
|
||||
display: flex;
|
||||
@@ -64,29 +70,20 @@ const GPUCard: React.FC<{
|
||||
}
|
||||
description={
|
||||
info || (
|
||||
<>
|
||||
<ItemInfo>
|
||||
{intl.formatMessage({ id: 'resources.table.vram' })}(
|
||||
{intl.formatMessage({ id: 'resources.table.used' })}/
|
||||
{intl.formatMessage({ id: 'resources.table.total' })}):{' '}
|
||||
<span>
|
||||
{convertFileSize(
|
||||
data?.memory?.used || data?.memory?.allocated || 0
|
||||
)}{' '}
|
||||
/ {convertFileSize(data?.memory?.total || 0)}
|
||||
</span>
|
||||
</ItemInfo>
|
||||
{/* <ItemInfo>
|
||||
<span>
|
||||
{intl.formatMessage({ id: 'resources.table.gpuutilization' })}
|
||||
:{' '}
|
||||
</span>
|
||||
{data?.memory?.used
|
||||
? _.round(data?.memory?.utilization_rate || 0, 2)
|
||||
: _.round(data.memory?.allocated / data.memory?.total, 2) * 100}
|
||||
%
|
||||
</ItemInfo> */}
|
||||
</>
|
||||
<Flex wrap gap={8} style={{ fontSize: 13 }}>
|
||||
<Metric
|
||||
label={intl.formatMessage({ id: 'resources.table.total' })}
|
||||
value={convertFileSize(data?.memory?.total || 0)}
|
||||
/>
|
||||
<Metric
|
||||
label={intl.formatMessage({ id: 'resources.table.used' })}
|
||||
value={convertFileSize(data?.memory?.used || 0)}
|
||||
/>
|
||||
<Metric
|
||||
label={intl.formatMessage({ id: 'resources.table.allocated' })}
|
||||
value={convertFileSize(data?.memory?.allocated || 0)}
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
></CardContainer>
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
import { backendOptionsMap } from '../constants/backend-parameters';
|
||||
import '../style/gpu-selector.less';
|
||||
|
||||
const InputWrapper = styled.div`
|
||||
padding: 8px 4px;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.cascader-popup-wrapper.gpu-selector {
|
||||
.ant-cascader-menu-item-content {
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user