| | |
| | | Stat.Mem = *meminfo |
| | | } |
| | | |
| | | |
| | | // Gpu |
| | | // agxGpuProcIface := "/sys/devices/gpu.0/load" |
| | | |
| | | // if Exists(agxGpuProcIface) { |
| | | // fd, err1 := os.Open(agxGpuProcIface) |
| | | // if err1 == nil { |
| | | // var load int64 |
| | | // fmt.Fscanf(fd, "%d", &load) |
| | | // // 模拟nvidia库的输出 |
| | | // Stat.Gpu = append(Stat.Gpu, gogpu.GpuUnitInfo{ |
| | | // GpuMemoryTotal: 1000, |
| | | // GpuMemoryUsed: load, |
| | | // }) |
| | | // fd.Close() |
| | | // } |
| | | // } else { |
| | | // if gpuInfo, err := gogpu.Info(); err == nil { |
| | | // sort.Sort(gogpu.GPURank(gpuInfo.Info)) |
| | | // Stat.Gpu = Stat.Gpu[0:0] |
| | | // for _, v := range gpuInfo.Info { |
| | | // Stat.Gpu = append(Stat.Gpu, v) |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // Gpu |
| | | agxGpuProcIface := "/sys/devices/gpu.0/load" |
| | | if _, err := os.Stat(agxGpuProcIface); !os.IsExist(err) { |
| | | if Exists(agxGpuProcIface){ |
| | | fd, err1 := os.Open(agxGpuProcIface) |
| | | if err1 == nil { |
| | | var load int64 |
| | |
| | | |
| | | return Stat |
| | | } |
| | | |
| | | func Exists(path string) bool { |
| | | _, err := os.Stat(path) //os.Stat获取文件信息 |
| | | if err != nil { |
| | | if os.IsExist(err) { |
| | | return true |
| | | } |
| | | return false |
| | | } |
| | | return true |
| | | } |