Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/hami-webui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vendorNodeSelectors:
DCU: dcu=on
MLU: mlu=on
Metax: metax-tech.com/gpu.installed=true
Iluvatar: iluvatar.com/gpu.present=true

image:
frontend:
Expand Down
4 changes: 2 additions & 2 deletions packages/web/projects/vgpu/views/task/admin/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
</block-box>

<block-box v-for="{ title, data } in lineConfig" :key="title" :title="title">
<template #extra v-if="detail.type && (detail.type.startsWith('NVIDIA') || detail.type.startsWith('MXC'))">
<template #extra v-if="detail.type && (detail.type.startsWith('NVIDIA') || detail.type.startsWith('MXC') || detail.type.startsWith('BI-') || detail.type.startsWith('MR-'))">
<time-picker v-model="times" type="datetimerange" size="small" />
</template>
<div style="height: 200px">
<template v-if="detail.type && !detail.type.startsWith('NVIDIA') && !detail.type.startsWith('MXC')">
<template v-if="detail.type && !detail.type.startsWith('NVIDIA') && !detail.type.startsWith('MXC') && !detail.type.startsWith('BI-') && !detail.type.startsWith('MR-')">
<el-empty :description="$t('task.noMonitorSupport')" :image-size="60" />
</template>
<template v-else>
Expand Down
3 changes: 2 additions & 1 deletion server/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ node_selectors:
Ascend: ascend=on
DCU: dcu=on
MLU: mlu=on
Metax: metax-tech.com/gpu.installed=true
Metax: metax-tech.com/gpu.installed=true
Iluvatar: iluvatar.com/gpu.present=true
9 changes: 5 additions & 4 deletions server/internal/biz/biz.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ var ProviderSet = wire.NewSet(
)

const (
NvidiaGPUDevice = "NVIDIA"
HygonGPUDevice = "DCU"
AscendGPUDevice = "Ascend"
MetaxGPUDevice = "Metax"
NvidiaGPUDevice = "NVIDIA"
HygonGPUDevice = "DCU"
AscendGPUDevice = "Ascend"
MetaxGPUDevice = "Metax"
IluvatarGPUDevice = "Iluvatar"

CambriconGPUDevice = "MLU"

Expand Down
17 changes: 10 additions & 7 deletions server/internal/data/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ import (
"context"
"errors"
"fmt"
"github.com/go-kratos/kratos/v2/log"
corev1 "k8s.io/api/core/v1"
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/informers"
listerscorev1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"strings"
"sync"
"time"
"vgpu/internal/biz"
"vgpu/internal/provider"
"vgpu/internal/provider/ascend"
"vgpu/internal/provider/hygon"
"vgpu/internal/provider/iluvatar"
"vgpu/internal/provider/metax"
"vgpu/internal/provider/mlu"
"vgpu/internal/provider/nvidia"

"github.com/go-kratos/kratos/v2/log"
corev1 "k8s.io/api/core/v1"
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/informers"
listerscorev1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
)

type nodeRepo struct {
Expand All @@ -45,6 +47,7 @@ func NewNodeRepo(data *Data, nodeSelectors map[string]string, logger log.Logger)
ascend.NewAscend(data.promCl, log.NewHelper(logger), nodeSelectors[biz.AscendGPUDevice]),
hygon.NewHygon(data.promCl, log.NewHelper(logger), nodeSelectors[biz.HygonGPUDevice]),
metax.NewMetax(data.promCl, log.NewHelper(logger), nodeSelectors[biz.MetaxGPUDevice]),
iluvatar.NewIluvatar(data.promCl, log.NewHelper(logger), nodeSelectors[biz.IluvatarGPUDevice]),
},
}
nodeRepo.init()
Expand Down Expand Up @@ -79,7 +82,7 @@ func (r *nodeRepo) updateLocalNodes() {
continue
}
for _, device := range devices {
n[node.UID].Devices = append(bizNode.Devices, &biz.DeviceInfo{
n[node.UID].Devices = append(n[node.UID].Devices, &biz.DeviceInfo{
Index: int(device.Index),
Id: device.ID,
AliasId: device.AliasId,
Expand Down
31 changes: 31 additions & 0 deletions server/internal/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
pb "vgpu/api/v1"
"vgpu/internal/biz"
"vgpu/internal/data/prom"
"vgpu/internal/provider/iluvatar"
"vgpu/internal/provider/metax"
"vgpu/internal/provider/mlu"
"vgpu/internal/service"
Expand Down Expand Up @@ -234,6 +235,9 @@ func (s *MetricsGenerator) GenerateContainerMetrics(ctx context.Context) error {
if provider == "" || provider == metax.MetaxGPUDevice {
continue
}
if mapped, ok := iluvatar.IluvatarProviders[provider]; ok {
provider = mapped
}
HamiContainerVgpuAllocated.WithLabelValues(device.NodeName, provider, device.Type, device.Id, c.PodName, c.Name, c.Namespace, fmt.Sprintf("%s:%s", c.Name, c.PodUID)).Set(float64(vGPU))
HamiContainerVmemoryAllocated.WithLabelValues(device.NodeName, provider, device.Type, device.Id, c.PodName, c.Name, c.Namespace, fmt.Sprintf("%s:%s", c.Name, c.PodUID)).Set(float64(memory))
HamiContainerVcoreAllocated.WithLabelValues(device.NodeName, provider, device.Type, device.Id, c.PodName, c.Name, c.Namespace, fmt.Sprintf("%s:%s", c.Name, c.PodUID)).Set(float64(core))
Expand All @@ -255,6 +259,9 @@ func (s *MetricsGenerator) GenerateContainerMetrics(ctx context.Context) error {
case metax.MetaxSGPUDevice:
used = float64(taskCoreUsed)
util = roundToOneDecimal(100 * float64(taskCoreUsed) / float64(core))
case biz.IluvatarGPUDevice:
used = float64(taskCoreUsed)
util = roundToOneDecimal(100 * float64(taskCoreUsed) / float64(core))
default:
}
cardCoreUtil, err := s.deviceCoreUtil(ctx, provider, device.Id)
Expand All @@ -272,6 +279,8 @@ func (s *MetricsGenerator) GenerateContainerMetrics(ctx context.Context) error {
taskMemoryUsed = float32((taskMemoryUsed/100)*float32(memory)) * 1024 * 1024
case metax.MetaxSGPUDevice:
taskMemoryUsed = float32(taskMemoryUsed) * 1024 // KB->Byte
case biz.IluvatarGPUDevice:
taskMemoryUsed = float32((taskMemoryUsed/100)*float32(memory)) * 1024 * 1024
default:
}
HamiContainerMemoryUsed.WithLabelValues(device.NodeName, provider, device.Type, device.Id, c.PodName, c.Name, c.Namespace).Set(float64(taskMemoryUsed / 1024 / 1024))
Expand Down Expand Up @@ -309,6 +318,8 @@ func (s *MetricsGenerator) deviceMemUsed(ctx context.Context, provider, deviceUU
query = fmt.Sprintf("avg(dcu_usedmemory_bytes{device_id=\"%s\"})", deviceUUID)
case biz.MetaxGPUDevice:
query = fmt.Sprintf("avg(mx_memory_used{uuid=\"%s\", type=\"vram\"})", deviceUUID)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(ix_mem_used{uuid=\"%s\"})", deviceUUID)
default:
return 0, errors.New("provider not exists")
}
Expand Down Expand Up @@ -340,6 +351,8 @@ func (s *MetricsGenerator) deviceMemTotal(ctx context.Context, provider, deviceU
query = fmt.Sprintf("avg(dcu_memorycap_bytes{device_id=\"%s\"})", deviceUUID)
case biz.MetaxGPUDevice:
query = fmt.Sprintf("avg(mx_memory_total{uuid=\"%s\", type=\"vram\"})", deviceUUID)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(ix_mem_total{uuid=\"%s\"})", deviceUUID)
default:
return 0, errors.New("provider not exists")
}
Expand Down Expand Up @@ -371,6 +384,8 @@ func (s *MetricsGenerator) deviceCoreUtil(ctx context.Context, provider, deviceU
query = fmt.Sprintf("avg(dcu_utilizationrate{device_id=\"%s\"})", deviceUUID)
case biz.MetaxGPUDevice, metax.MetaxGPUDevice, metax.MetaxSGPUDevice:
query = fmt.Sprintf("avg(mx_gpu_usage{uuid=\"%s\"})", deviceUUID)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(ix_gpu_utilization{uuid=\"%s\"})", deviceUUID)
default:
return 0, errors.New("provider not exists")
}
Expand Down Expand Up @@ -401,6 +416,8 @@ func (s *MetricsGenerator) taskCoreUsed(ctx context.Context, provider, namespace
case metax.MetaxSGPUDevice:
query = fmt.Sprintf("avg(mx_sgpu_usage{Hostname=\"%s\", deviceId=\"%d\", exported_namespace=\"%s\", exported_pod=\"%s\", exported_container=\"%s\"})",
hostname, deviceIndex, namespace, pod, container)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(container_gpu_utilization{pod_name=\"%s\", container_name=\"%s\"})", pod, container)
default:
return 0, errors.New("provider not exists")
}
Expand All @@ -424,6 +441,9 @@ func (s *MetricsGenerator) taskMemoryUsed(ctx context.Context, provider, namespa
case metax.MetaxSGPUDevice:
query = fmt.Sprintf("avg(mx_sgpu_used_memory{Hostname=\"%s\", deviceId=\"%d\", exported_namespace=\"%s\", exported_pod=\"%s\", exported_container=\"%s\"})",
hostname, deviceIndex, namespace, pod, container)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(container_gpu_memory_total{container_name=\"%s\", pod_name=\"%s\"})",
container, pod)
default:
return 0, errors.New("provider not exists")
}
Expand All @@ -444,6 +464,8 @@ func (s *MetricsGenerator) gpuTemperature(ctx context.Context, provider, deviceU
query = fmt.Sprintf("avg(dcu_temp{device_id=\"%s\"})", deviceUUID)
case biz.MetaxGPUDevice:
query = fmt.Sprintf("avg(mx_chip_hotspot_temp{uuid=\"%s\"})", deviceUUID)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(ix_temperature{uuid=\"%s\"})", deviceUUID)
default:
return 0, errors.New("provider not exists")
}
Expand Down Expand Up @@ -480,6 +502,8 @@ func (s *MetricsGenerator) gpuPower(ctx context.Context, provider, deviceUUID st
query = fmt.Sprintf("avg(dcu_power_usage{device_id=\"%s\"})", deviceUUID)
case biz.MetaxGPUDevice:
query = fmt.Sprintf("avg(mx_board_power{uuid=\"%s\"})", deviceUUID) // mW
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("avg(ix_power_usage{uuid=\"%s\"})", deviceUUID)
default:
return 0, errors.New("provider not exists")
}
Expand Down Expand Up @@ -538,6 +562,9 @@ func (s *MetricsGenerator) queryDeviceAdditional(ctx context.Context, provider,
query = fmt.Sprintf("dcu_power_usage{device_id=\"%s\"}", deviceUUID)
case biz.MetaxGPUDevice:
query = fmt.Sprintf("mx_board_power{uuid=\"%s\"}", deviceUUID)
case biz.IluvatarGPUDevice:
query = fmt.Sprintf("ix_power_usage{uuid=\"%s\"}", deviceUUID)

default:
return nil, errors.New("provider not exists")
}
Expand Down Expand Up @@ -567,6 +594,10 @@ func (s *MetricsGenerator) queryDeviceAdditional(ctx context.Context, provider,
case biz.MetaxGPUDevice:
info.DriverVersion = metric["driver_version"]
info.DeviceNo = metric["deviceId"]
case biz.IluvatarGPUDevice:
info.DriverVersion = metric["driver"]
info.DeviceNo = metric["serial"]

}
return info, nil
}
Expand Down
36 changes: 36 additions & 0 deletions server/internal/provider/iluvatar/device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package iluvatar

import "vgpu/internal/provider/util"

const (
IluvatarBI150Device = "Iluvatar-BI-V150"
IluvatarBI100Device = "Iluvatar-BI-V100"
IluvatarMR100Device = "Iluvatar-MR-V100"

BI150NodeRegisterAnno = "hami.io/node-BI-V150-register"
MR100NodeRegisterAnno = "hami.io/node-MR-V100-register"
BI100NodeRegisterAnno = "hami.io/node-BI-V100-register"
)

var (
IluvatarResourceCount string
IluvatarResourceMemory string
IluvatarResourceCores string
IluvatarNodeRegisterAnnos []string
IluvatarProviders map[string]string
)

func init() {
IluvatarProviders = map[string]string{
"BI-V150": "Iluvatar",
"BI-V100": "Iluvatar",
"MR-V100": "Iluvatar",
}
IluvatarNodeRegisterAnnos = []string{BI150NodeRegisterAnno, MR100NodeRegisterAnno, BI100NodeRegisterAnno}
util.InRequestDevices[IluvatarBI150Device] = "hami.io/BI-V150-devices-to-allocate"
util.SupportDevices[IluvatarBI150Device] = "hami.io/BI-V150-devices-allocated"
util.InRequestDevices[IluvatarBI100Device] = "hami.io/BI-V100-devices-to-allocate"
util.SupportDevices[IluvatarBI100Device] = "hami.io/BI-V100-devices-allocated"
util.InRequestDevices[IluvatarMR100Device] = "hami.io/MR-V100-devices-to-allocate"
util.SupportDevices[IluvatarMR100Device] = "hami.io/MR-V100-devices-allocated"
}
54 changes: 54 additions & 0 deletions server/internal/provider/iluvatar/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package iluvatar

import (
"fmt"
"vgpu/internal/biz"
"vgpu/internal/data/prom"
"vgpu/internal/provider/util"

"github.com/go-kratos/kratos/v2/log"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
)

type Iluvatar struct {
prom *prom.Client
log *log.Helper

nodeSelectors string
}

func NewIluvatar(prom *prom.Client, log *log.Helper, nodeSelectors string) *Iluvatar {
return &Iluvatar{
prom: prom,
log: log,
nodeSelectors: nodeSelectors,
}
}

func (i *Iluvatar) GetNodeDevicePluginLabels() (labels.Selector, error) {
return labels.Parse(i.nodeSelectors)
}

func (i *Iluvatar) GetProvider() string {
return biz.IluvatarGPUDevice
}

type DeviceMeta struct {
UUID string
Type string
Driver string
}

func (i *Iluvatar) FetchDevices(node *corev1.Node) ([]*util.DeviceInfo, error) {
for _, anno := range IluvatarNodeRegisterAnnos {
anno, ok := node.Annotations[anno]
if !ok {
log.Infof("anno %s not found", anno)
continue
}
deviceInfos, err := util.DecodeNodeDevices(anno, i.log)
return deviceInfos, err
}
return []*util.DeviceInfo{}, fmt.Errorf("")
}
21 changes: 21 additions & 0 deletions server/internal/provider/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const (
CambriconGPUDevice = "MLU"
MetaxGPUDevice = "Metax-GPU"
MetaxSGPUDevice = "Metax-SGPU"
IluvatarBI150Device = "Iluvatar-BI-V150"
IluvatarBI100Device = "Iluvatar-BI-V100"
IluvatarMR100Device = "Iluvatar-MR-V100"

DsmluProfileAndInstance = "CAMBRICON_DSMLU_PROFILE_INSTANCE"

Expand Down Expand Up @@ -391,6 +394,24 @@ func DecodePodDevices(pod *corev1.Pod, log *log.Helper) (PodDevices, error) {
}
pd[devType] = append(pd[devType], cd)
}
case IluvatarBI100Device, IluvatarBI150Device, IluvatarMR100Device:
for i, s := range strings.Split(str, OnePodMultiContainerSplitSymbol) {
if i >= len(pod.Spec.Containers) {
break
}
if s == "" {
pd[devType] = append(pd[devType], ContainerDevices{})
continue
}
cd, err := DecodeContainerDevices(s, priorities[i])
if err != nil {
return PodDevices{}, nil
}
if len(cd) == 0 {
continue
}
pd[devType] = append(pd[devType], cd)
}
}
}
log.Infof("Decoded pod annos: poddevices %v", pd)
Expand Down