Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added gpu driver query for windows #331

Merged
merged 1 commit into from
Mar 19, 2023
Merged

added gpu driver query for windows #331

merged 1 commit into from
Mar 19, 2023

Conversation

hingino
Copy link
Contributor

@hingino hingino commented Mar 19, 2023

Description

GPU does not currently return driver version for Windows. Adding these 3 lines reliably returns driver version

Test

package main

import (
	"fmt"

	"github.com/jaypipes/ghw"
)

type gpuInfo struct {
	Vendor        string
	Name          string
	OfflineDriver string
}

func GetGpuData() []gpuInfo {
	gpus := []gpuInfo{}

	cards, err := ghw.GPU()
	if err != nil {
		fmt.Printf("Error getting GPU info: %v", err)
	}

	for _, card := range cards.GraphicsCards {
		gpu := gpuInfo{
			Name:          card.DeviceInfo.Product.Name,
			Vendor:        card.DeviceInfo.Vendor.Name,
			OfflineDriver: card.DeviceInfo.Driver,
		}

		gpus = append(gpus, gpu)
	}

	return gpus
}

func main() {
	gpus := GetGpuData()

	for _, gpu := range gpus {
		println("GPU Vendor: ", gpu.Vendor)
		println("GPU Name: ", gpu.Name)
		println("Driver: ", gpu.OfflineDriver)
	}
}

Returns before update

GPU Vendor:  NVIDIA
GPU Name:  NVIDIA GeForce RTX 3060 Ti
Driver:

Return after update

GPU Vendor:  NVIDIA
GPU Name:  NVIDIA GeForce RTX 3060 Ti
Driver:  31.0.15.3118

Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you for the contribution, @hingino, much appreciated! All looks good!

@jaypipes jaypipes merged commit 29fb3b5 into jaypipes:main Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants