Skip to content

Commit

Permalink
Merge pull request volcano-sh#29 from WingkaiHo/fix/scheduler-fail-wh…
Browse files Browse the repository at this point in the history
…en-hide-gpu

Fix volcano-sh#17 Warning UnexpectedAdmissionError
  • Loading branch information
volcano-sh-bot authored Apr 7, 2023
2 parents aa92fb8 + 93f591c commit 9d987ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 3 additions & 6 deletions pkg/plugin/nvidia/nvidia.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package nvidia

import (
"fmt"
"log"
"os"
"strings"
Expand Down Expand Up @@ -65,7 +64,7 @@ func (g *GpuDeviceManager) Devices() []*Device {
for i := uint(0); i < n; i++ {
d, err := nvml.NewDeviceLite(i)
check(err)
devs = append(devs, buildDevice(d))
devs = append(devs, buildDevice(d, i))
}

return devs
Expand All @@ -84,14 +83,12 @@ func (g *GpuDeviceManager) CheckHealth(stop <-chan struct{}, devices []*Device,
checkHealth(stop, devices, unhealthy)
}

func buildDevice(d *nvml.Device) *Device {
func buildDevice(d *nvml.Device, devIndex uint) *Device {
dev := Device{}
dev.ID = d.UUID
dev.Health = pluginapi.Healthy
dev.Path = d.Path

_, err := fmt.Sscanf(d.Path, "/dev/nvidia%d", &dev.Index)
check(err)
dev.Index = devIndex

if d.CPUAffinity != nil {
dev.Topology = &pluginapi.TopologyInfo{
Expand Down
4 changes: 1 addition & 3 deletions pkg/plugin/nvidia/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ func GetDevices(gpuMemoryFactor uint) ([]*pluginapi.Device, map[uint]string) {
for i := uint(0); i < n; i++ {
d, err := nvml.NewDevice(i)
check(err)
var id uint
_, err = fmt.Sscanf(d.Path, "/dev/nvidia%d", &id)
check(err)
id := i
deviceByIndex[id] = d.UUID
// TODO: Do we assume all cards are of same capacity
if GetGPUMemory() == uint(0) {
Expand Down

0 comments on commit 9d987ac

Please sign in to comment.