We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6d5bde8 commit 0c859adCopy full SHA for 0c859ad
pkg/xsysinfo/gpu.go
@@ -2,18 +2,29 @@ package xsysinfo
2
3
import (
4
"strings"
5
+ "sync"
6
7
"github.com/jaypipes/ghw"
8
"github.com/jaypipes/ghw/pkg/gpu"
9
)
10
11
+var (
12
+ gpuCache []*gpu.GraphicsCard
13
+ gpuCacheOnce sync.Once
14
+ gpuCacheErr error
15
+)
16
+
17
func GPUs() ([]*gpu.GraphicsCard, error) {
- gpu, err := ghw.GPU()
- if err != nil {
- return nil, err
- }
18
+ gpuCacheOnce.Do(func() {
19
+ gpu, err := ghw.GPU()
20
+ if err != nil {
21
+ gpuCacheErr = err
22
+ return
23
+ }
24
+ gpuCache = gpu.GraphicsCards
25
+ })
26
- return gpu.GraphicsCards, nil
27
+ return gpuCache, gpuCacheErr
28
}
29
30
func TotalAvailableVRAM() (uint64, error) {
0 commit comments