Skip to content

Commit 8899d38

Browse files
authored
fix: update node resources according to gpu list (#68)
1 parent d5292a7 commit 8899d38

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

cmd/nodediscovery/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ func main() {
102102
os.Exit(1)
103103
}
104104

105-
totalTFlops := resource.MustParse("0")
106-
totalVRAM := resource.MustParse("0Ki")
107-
availableTFlops := resource.MustParse("0")
108-
availableVRAM := resource.MustParse("0Ki")
105+
totalTFlops := resource.Quantity{}
106+
totalVRAM := resource.Quantity{}
107+
availableTFlops := resource.Quantity{}
108+
availableVRAM := resource.Quantity{}
109109

110110
allDeviceIDs := make([]string, 0)
111111

@@ -140,7 +140,7 @@ func main() {
140140
})
141141
tflops := info.Fp16TFlops
142142
if !ok {
143-
tflops = resource.MustParse("0")
143+
tflops = resource.Quantity{}
144144
}
145145
gpu := &tfv1.GPU{
146146
ObjectMeta: metav1.ObjectMeta{

internal/controller/gpunode_controller.go

+12
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@ func (r *GPUNodeReconciler) checkStatusAndUpdateVirtualCapacity(ctx context.Cont
208208
return true, nil
209209
}
210210

211+
node.Status.AvailableVRAM = resource.Quantity{}
212+
node.Status.AvailableTFlops = resource.Quantity{}
213+
node.Status.TotalTFlops = resource.Quantity{}
214+
node.Status.TotalVRAM = resource.Quantity{}
215+
216+
for _, gpu := range gpuList {
217+
node.Status.AvailableVRAM.Add(gpu.Status.Available.Vram)
218+
node.Status.AvailableTFlops.Add(gpu.Status.Available.Tflops)
219+
node.Status.TotalVRAM.Add(gpu.Status.Capacity.Vram)
220+
node.Status.TotalTFlops.Add(gpu.Status.Capacity.Tflops)
221+
}
222+
211223
virtualVRAM, virtualTFlops := r.CalculateVirtualCapacity(node, poolObj)
212224
node.Status.VirtualTFlops = virtualTFlops
213225
node.Status.VirtualVRAM = virtualVRAM

0 commit comments

Comments
 (0)