From d0a37ca0c8baa26364bdfed7466d5f2b1003711c Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Sun, 30 Mar 2025 04:52:49 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DGPU=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8E=87=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- network/network_test.go | 1 + system/gpu.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/network/network_test.go b/network/network_test.go index 1f26175..1d8fbe9 100644 --- a/network/network_test.go +++ b/network/network_test.go @@ -5,6 +5,7 @@ import ( "testing" ) +// 本文件夹 network 修改需要同步 https://github.com/oneclickvirt/security 否则 goecs 无法使用 func TestIpv4SecurityCheck(t *testing.T) { // 全项测试 ipInfo, _, _ := NetworkCheck("both", false, "zh") diff --git a/system/gpu.go b/system/gpu.go index 138e05a..491bd9e 100644 --- a/system/gpu.go +++ b/system/gpu.go @@ -43,7 +43,6 @@ func updateGPUStat(gpuStat *uint64, wg *sync.WaitGroup) { return } defer atomic.StoreInt32(&updateGPUStatus, 0) - for statDataFetchAttempts["GPU"] < maxDeviceDataFetchAttempts { gs, err := gpustat.GetGPUStat() if err != nil { @@ -74,7 +73,9 @@ func getGPUInfo(ret *model.SystemInfo) (*model.SystemInfo, error) { wg.Add(1) go updateGPUStat(&gpuStat, &wg) wg.Wait() // 等待 updateGPUStat 完成 - ret.GpuStats = fmt.Sprintf("%f", math.Float64frombits(gpuStat)) + if math.Float64frombits(gpuStat) > 0 { + ret.GpuStats = fmt.Sprintf("%f", math.Float64frombits(gpuStat)) + } return ret, nil } else { hostDataFetchAttempts["GPU"]++