Skip to content

Commit

Permalink
Merge branch 'hotfix/dcgm_test_suit' into 'master'
Browse files Browse the repository at this point in the history
test(master): fix dcgm test error

See merge request nvidia/container-toolkit/gpu-monitoring-tools!24
  • Loading branch information
RenaudWasTaken committed Jun 22, 2020
2 parents 148415f + 31c3f30 commit c345074
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 51 deletions.
15 changes: 9 additions & 6 deletions bindings/go/dcgm/dcgm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ func check(err error, t *testing.T) {
}

func TestDeviceCount(t *testing.T) {
check(Init(Embedded), t)
defer func() { check(Shutdown(), t) }()
cleanup, err := Init(Embedded)
check(err, t)
defer cleanup()

count, err := GetAllDeviceCount()
check(err, t)
Expand All @@ -43,8 +44,9 @@ func BenchmarkDeviceCount1(b *testing.B) {
}

func TestDeviceInfo(t *testing.T) {
check(Init(Embedded), t)
defer func() { check(Shutdown(), t) }()
cleanup, err := Init(Embedded)
check(err, t)
defer cleanup()

fields := []string{
"driver_version",
Expand Down Expand Up @@ -125,8 +127,9 @@ func BenchmarkDeviceInfo1(b *testing.B) {
}

func TestDeviceStatus(t *testing.T) {
check(Init(Embedded), t)
defer func() { check(Shutdown(), t) }()
cleanup, err := Init(Embedded)
check(err, t)
defer cleanup()

gpus, err := GetSupportedDevices()
check(err, t)
Expand Down
4 changes: 3 additions & 1 deletion bindings/go/samples/dcgm/deviceInfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ func main() {
// 2. dcgm.Standalone -connect "addr", -socket "isSocket"
// 3. dcgm.StartHostengine
flag.Parse()
if err := dcgm.Init(dcgm.Standalone, *connectAddr, *isSocket); err != nil {
cleanup, err := dcgm.Init(dcgm.Standalone, *connectAddr, *isSocket)
if err != nil {
log.Panicln(err)
}
defer cleanup()

defer func() {
if err := dcgm.Shutdown(); err != nil {
Expand Down
13 changes: 5 additions & 8 deletions bindings/go/samples/dcgm/dmon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

gpus, err := dcgm.GetSupportedDevices()
if err != nil {
Expand All @@ -49,8 +46,8 @@ func main() {
log.Panicln(err)
}
fmt.Printf("%5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
gpu, int64(*st.Power), *st.Temperature, *st.Utilization.GPU, *st.Utilization.Memory,
*st.Utilization.Encoder, *st.Utilization.Decoder, *st.Clocks.Memory, *st.Clocks.Cores)
gpu, int64(st.Power), st.Temperature, st.Utilization.GPU, st.Utilization.Memory,
st.Utilization.Encoder, st.Utilization.Decoder, st.Clocks.Memory, st.Clocks.Cores)
}

case <-sigs:
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/health/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

gpus, err := dcgm.GetSupportedDevices()
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/hostengineStatus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import (
// dcgmi introspect --enable
// dcgmi introspect -s -H
func main() {
if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

st, err := dcgm.Introspect()
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/policy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import (
// dcgmi policy -g GROUPID --set 0,0 -x -n -p -e -P 250 -T 100 -M 10
// dcgmi policy -g GROUPID --reg
func main() {
if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

gpus, err := dcgm.GetSupportedDevices()
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/processInfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ var process = flag.Uint("pid", 0, "Provide pid to get this process information."
// dcgmi stats --pid ENTERPID -v
// sample: sudo ./processInfo -pid PID
func main() {
if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

// Request DCGM to start recording stats for GPU process fields
group, err := dcgm.WatchPidFields()
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/restApi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ func main() {
stopSig := make(chan os.Signal, 1)
signal.Notify(stopSig, syscall.SIGINT, syscall.SIGTERM)

if err := dcgm.Init(dcgm.Embedded); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

addr := ":8070"
server := newHttpServer(addr)
Expand Down
9 changes: 3 additions & 6 deletions bindings/go/samples/dcgm/topology/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ func main() {
// 1. dcgm.Embedded
// 2. dcgm.Standalone
// 3. dcgm.StartHostengine
if err := dcgm.Init(dcgm.StartHostengine); err != nil {
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
log.Panicln(err)
}
defer func() {
if err := dcgm.Shutdown(); err != nil {
log.Panicln(err)
}
}()
defer cleanup()

gpus, err := dcgm.GetSupportedDevices()
if err != nil {
Expand Down

0 comments on commit c345074

Please sign in to comment.