GithubHelp home page GithubHelp logo

go-nvlib's Introduction

The go-nvlib project

This repository holds a collection of go packages to ease the development of NVIDIA GPU management software. Many of its abstractions build and expand upon the base go-nvml package which provides a comprehensive wrapper around the official NVIDIA Management Library.

go-nvlib's People

Contributors

arangogutierrez avatar cdesiniotis avatar dependabot[bot] avatar elezar avatar klueska avatar rorajani avatar tariq1890 avatar zvonkok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-nvlib's Issues

Add GetDeviceNodePaths (or similar) function to go-nvlib/pkg/device.Device interface

The logic for querying device nodes for regular and MIG devices are used in the generation of CDI specifications and in the device plugin.

For example: For regular devices:

	// TODO: The functionality to get device paths should be integrated into the go-nvlib/pkg/device.Device interface.
	// This will allow reuse here and in other code where the paths are queried such as the NVIDIA device plugin.
	minor, ret := d.GetMinorNumber()
	if ret != nvml.SUCCESS {
		return nil, fmt.Errorf("error getting GPU device minor number: %v", ret)
	}
	path := fmt.Sprintf("/dev/nvidia%d", minor)

For MIG devices:

	minor, ret := parent.GetMinorNumber()
	if ret != nvml.SUCCESS {
		return nil, fmt.Errorf("error getting GPU device minor number: %v", ret)
	}
	parentPath := fmt.Sprintf("/dev/nvidia%d", minor)

	migCaps, err := nvcaps.NewMigCaps()
	if err != nil {
		return nil, fmt.Errorf("error getting MIG capability device paths: %v", err)
	}

	gi, ret := d.GetGpuInstanceId()
	if ret != nvml.SUCCESS {
		return nil, fmt.Errorf("error getting GPU Instance ID: %v", ret)
	}

	ci, ret := d.GetComputeInstanceId()
	if ret != nvml.SUCCESS {
		return nil, fmt.Errorf("error getting Compute Instance ID: %v", ret)
	}

	giCap := nvcaps.NewGPUInstanceCap(minor, gi)
	giCapDevicePath, err := migCaps.GetCapDevicePath(giCap)
	if err != nil {
		return nil, fmt.Errorf("failed to get GI cap device path: %v", err)
	}

	ciCap := nvcaps.NewComputeInstanceCap(minor, gi, ci)
	ciCapDevicePath, err := migCaps.GetCapDevicePath(ciCap)
	if err != nil {
		return nil, fmt.Errorf("failed to get CI cap device path: %v", err)
	}

GetTopologyCommonAncestor method error

go-nvlib/pkg/nvml/device.go

Lines 183 to 190 in f3264c8

func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) {
other, ok := o.(nvmlDevice)
if !ok {
return 0, ERROR_INVALID_ARGUMENT
}
l, r := nvml.Device(d).GetTopologyCommonAncestor(nvml.Device(other))
return GpuTopologyLevel(l), Return(r)

other, ok := o.(nvmlDevice)
	if !ok {
		return 0, ERROR_INVALID_ARGUMENT
	}

this ok is false, i don't now why, anybody can help me.

image

Address golangci-lint warnings

PR #29

Disables

 disable:
    - unused
    - gocritic
    - stylecheck
    - forcetypeassert

We should address golangci-lint warnings and re-enable the golangci-lint checks at .golangci.yml

❯ golangci-lint run ./...
pkg/pciids/pciids.go:399:4: assignOp: replace `hkFullID = hkFullID & 0xFFFF0000` with `hkFullID &= 0xFFFF0000` (gocritic)
                        hkFullID = hkFullID & 0xFFFF0000
                        ^
pkg/pciids/pciids.go:412:4: assignOp: replace `hkFullID = hkFullID & 0xFFFF0000` with `hkFullID &= 0xFFFF0000` (gocritic)
                        hkFullID = hkFullID & 0xFFFF0000
                        ^
pkg/pciids/pciids.go:415:4: assignOp: replace `hkFullID = hkFullID & 0xFFFFFF00` with `hkFullID &= 0xFFFFFF00` (gocritic)
                        hkFullID = hkFullID & 0xFFFFFF00
                        ^
pkg/pciids/pciids.go:413:4: assignOp: replace `hkFullID = hkFullID | uint32(id)<<8` with `hkFullID |= uint32(id)<<8` (gocritic)
                        hkFullID = hkFullID | uint32(id)<<8
                        ^
pkg/nvlib/device/device.go:125:2: commentFormatting: put a space between `//` and comment text (gocritic)
        //case nvml.BRAND_NVIDIA_VGAMING:
        ^
pkg/nvml/device.go:129:47: captLocal: `Index' should not be capitalized (gocritic)
func (d nvmlDevice) GetMigDeviceHandleByIndex(Index int) (Device, Return) {
                                              ^
pkg/nvml/device.go:177:36: captLocal: `EventTypes' should not be capitalized (gocritic)
func (d nvmlDevice) RegisterEvents(EventTypes uint64, Set EventSet) Return {
                                   ^
pkg/nvml/event_set.go:24:24: captLocal: `Timeoutms' should not be capitalized (gocritic)
func (e EventSet) Wait(Timeoutms uint32) (EventData, Return) {
                       ^
pkg/nvpci/nvpci.go:246:2: ifElseChain: rewrite if-else to switch statement (gocritic)
        if err == nil {
        ^
pkg/nvpci/nvpci.go:256:2: ifElseChain: rewrite if-else to switch statement (gocritic)
        if err == nil {
        ^
pkg/nvpci/resources.go:126:4: assignOp: replace `memSize32bit = memSize32bit + uint64(memSize)` with `memSize32bit += uint64(memSize)` (gocritic)
                        memSize32bit = memSize32bit + uint64(memSize)
                        ^
pkg/nvpci/resources.go:129:4: assignOp: replace `memSize64bit = memSize64bit + uint64(memSize)` with `memSize64bit += uint64(memSize)` (gocritic)
                        memSize64bit = memSize64bit + uint64(memSize)
                        ^
pkg/nvpci/resources.go:115:3: assignOp: replace `numBAR = numBAR + 1` with `numBAR++` (gocritic)
                numBAR = numBAR + 1
                ^
pkg/pciids/pciids.go:116:19: func `(*scanner).unread` is unused (unused)
func (s *scanner) unread() { _ = s.r.UnreadRune() }
                  ^
pkg/pciids/pciids.go:251:18: func `(*parser).unscan` is unused (unused)
func (p *parser) unscan() { p.buf.n = 1 }
                 ^
pkg/nvpci/mock.go:46:2: type assertion must be checked (forcetypeassert)
        mock = &MockNvpci{
        ^
pkg/nvml/consts.go:25:2: ST1003: should not use ALL_CAPS in Go names; use CamelCase instead (stylecheck)
        NVLINK_MAX_LINKS = nvml.NVLINK_MAX_LINKS
        ^
pkg/nvml/consts.go:31:2: ST1003: should not use ALL_CAPS in Go names; use CamelCase instead (stylecheck)
        ERROR_UNINITIALIZED           = Return(nvml.ERROR_UNINITIALIZED)
        ^
pkg/nvml/consts.go:32:2: ST1003: should not use ALL_CAPS in Go names; use CamelCase instead (stylecheck)
        ERROR_INVALID_ARGUMENT        = Return(nvml.ERROR_INVALID_ARGUMENT)
        ^
pkg/nvml/device.go:85:21: ST1003: method GetGpuInstanceById should be GetGpuInstanceByID (stylecheck)
func (d nvmlDevice) GetGpuInstanceById(id int) (GpuInstance, Return) {
                    ^
pkg/nvml/device.go:135:21: ST1003: method GetGpuInstanceId should be GetGpuInstanceID (stylecheck)
func (d nvmlDevice) GetGpuInstanceId() (int, Return) {
                    ^
pkg/nvml/device.go:141:21: ST1003: method GetComputeInstanceId should be GetComputeInstanceID (stylecheck)
func (d nvmlDevice) GetComputeInstanceId() (int, Return) {
                    ^
pkg/nvml/gi.go:40:27: ST1003: method GetComputeInstanceById should be GetComputeInstanceByID (stylecheck)
func (gi nvmlGpuInstance) GetComputeInstanceById(id int) (ComputeInstance, Return) {
                          ^
pkg/nvml/types.go:99:2: ST1003: struct field Id should be ID (stylecheck)
        Id        uint32
        ^
pkg/nvml/types.go:100:2: ST1003: struct field ProfileId should be ProfileID (stylecheck)
        ProfileId uint32
        ^
pkg/nvml/types.go:108:2: ST1003: struct field Id should be ID (stylecheck)
        Id          uint32
        ^
pkg/nvml/types.go:109:2: ST1003: struct field ProfileId should be ProfileID (stylecheck)
        ProfileId   uint32
        ^
pkg/nvml/types.go:118:2: ST1003: struct field GpuInstanceId should be GpuInstanceID (stylecheck)
        GpuInstanceId     uint32
        ^
pkg/nvml/types.go:119:2: ST1003: struct field ComputeInstanceId should be ComputeInstanceID (stylecheck)
        ComputeInstanceId uint32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.