mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-01 03:24:14 +08:00
feat: Support gpu of schema v11 (#7988)
This commit is contained in:
parent
55d0e27212
commit
b1373ff77e
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
|
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/schema_v12"
|
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/schema"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ func (n NvidiaSMI) LoadGpuInfo() (*common.GpuInfo, error) {
|
|||||||
return nil, fmt.Errorf("calling nvidia-smi failed, err: %v", std)
|
return nil, fmt.Errorf("calling nvidia-smi failed, err: %v", std)
|
||||||
}
|
}
|
||||||
data := []byte(std)
|
data := []byte(std)
|
||||||
schema := "v11"
|
version := "v11"
|
||||||
|
|
||||||
buf := bytes.NewBuffer(data)
|
buf := bytes.NewBuffer(data)
|
||||||
decoder := xml.NewDecoder(buf)
|
decoder := xml.NewDecoder(buf)
|
||||||
@ -51,15 +51,18 @@ func (n NvidiaSMI) LoadGpuInfo() (*common.GpuInfo, error) {
|
|||||||
parts := strings.Split(directive, " ")
|
parts := strings.Split(directive, " ")
|
||||||
s := strings.Trim(parts[len(parts)-1], "\" ")
|
s := strings.Trim(parts[len(parts)-1], "\" ")
|
||||||
if strings.HasPrefix(s, "nvsmi_device_") && strings.HasSuffix(s, ".dtd") {
|
if strings.HasPrefix(s, "nvsmi_device_") && strings.HasSuffix(s, ".dtd") {
|
||||||
schema = strings.TrimSuffix(strings.TrimPrefix(s, "nvsmi_device_"), ".dtd")
|
version = strings.TrimSuffix(strings.TrimPrefix(s, "nvsmi_device_"), ".dtd")
|
||||||
} else {
|
} else {
|
||||||
global.LOG.Debugf("Cannot find schema version in %q", directive)
|
global.LOG.Debugf("Cannot find schema version in %q", directive)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if schema != "v12" {
|
if version == "v12" || version == "v11" {
|
||||||
return &common.GpuInfo{}, nil
|
return schema.Parse(data, version)
|
||||||
|
} else {
|
||||||
|
global.LOG.Errorf("don't support such schema version %s", version)
|
||||||
}
|
}
|
||||||
return schema_v12.Parse(data)
|
|
||||||
|
return &common.GpuInfo{}, nil
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package schema_v12
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
|
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(buf []byte) (*common.GpuInfo, error) {
|
func Parse(buf []byte, version string) (*common.GpuInfo, error) {
|
||||||
var (
|
var (
|
||||||
s smi
|
s smi
|
||||||
info common.GpuInfo
|
info common.GpuInfo
|
||||||
@ -36,8 +36,13 @@ func Parse(buf []byte) (*common.GpuInfo, error) {
|
|||||||
|
|
||||||
gpuItem.Temperature = s.Gpu[i].Temperature.GpuTemp
|
gpuItem.Temperature = s.Gpu[i].Temperature.GpuTemp
|
||||||
gpuItem.PerformanceState = s.Gpu[i].PerformanceState
|
gpuItem.PerformanceState = s.Gpu[i].PerformanceState
|
||||||
gpuItem.PowerDraw = s.Gpu[i].GpuPowerReadings.PowerDraw
|
if version == "v12" {
|
||||||
gpuItem.MaxPowerLimit = s.Gpu[i].GpuPowerReadings.MaxPowerLimit
|
gpuItem.PowerDraw = s.Gpu[i].GpuPowerReadings.PowerDraw
|
||||||
|
gpuItem.MaxPowerLimit = s.Gpu[i].GpuPowerReadings.MaxPowerLimit
|
||||||
|
} else {
|
||||||
|
gpuItem.PowerDraw = s.Gpu[i].PowerReadings.PowerDraw
|
||||||
|
gpuItem.MaxPowerLimit = s.Gpu[i].PowerReadings.MaxPowerLimit
|
||||||
|
}
|
||||||
gpuItem.MemUsed = s.Gpu[i].FbMemoryUsage.Used
|
gpuItem.MemUsed = s.Gpu[i].FbMemoryUsage.Used
|
||||||
gpuItem.MemTotal = s.Gpu[i].FbMemoryUsage.Total
|
gpuItem.MemTotal = s.Gpu[i].FbMemoryUsage.Total
|
||||||
gpuItem.GPUUtil = s.Gpu[i].Utilization.GpuUtil
|
gpuItem.GPUUtil = s.Gpu[i].Utilization.GpuUtil
|
@ -1,4 +1,4 @@
|
|||||||
package schema_v12
|
package schema
|
||||||
|
|
||||||
type smi struct {
|
type smi struct {
|
||||||
AttachedGpus string `xml:"attached_gpus"`
|
AttachedGpus string `xml:"attached_gpus"`
|
@ -329,7 +329,7 @@ const loadEcc = (val: string) => {
|
|||||||
if (val === 'Enabled') {
|
if (val === 'Enabled') {
|
||||||
return i18n.global.t('ai_tools.gpu.enabled');
|
return i18n.global.t('ai_tools.gpu.enabled');
|
||||||
}
|
}
|
||||||
return val;
|
return val || 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadProcessType = (val: string) => {
|
const loadProcessType = (val: string) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user