Giter Club home page Giter Club logo

gonvml's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gonvml's Issues

Cannot dynamic link nvidia-ml and use gonvml at the same time

example failed to query device count:

package main

// #cgo LDFLAGS: -ldl -lnvidia-ml
// #cgo CFLAGS: -I /usr/local/cuda-8.0/include
/*
#include <stdio.h>
#include "nvml.h"
void testNvml()
{
    nvmlReturn_t result;
    unsigned int device_count, i;

    // First initialize NVML library
    result = nvmlInit();
    if (NVML_SUCCESS != result)
    {
        printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
        return;
    }

    result = nvmlDeviceGetCount(&device_count);
    if (NVML_SUCCESS != result)
    {
        printf("Failed to query device count: %s\n", nvmlErrorString(result));
        return;
    }
    printf("Found %d device%s\n\n", device_count, device_count != 1 ? "s" : "");
}
*/
import "C"

import (
	"fmt"

	"github.com/mindprince/gonvml"
)

func testGoNvml() (value []string) {
	err := gonvml.Initialize()
	if err != nil {
		return
	}
	defer func() { _ = gonvml.Shutdown() }()

	n, err := gonvml.DeviceCount()
	if err != nil {
		panic(err)
	}
	fmt.Println("testGoNvml gpu num:", n)
	return
}

func main() {
	C.testNvml()
	testGoNvml()
	C.testNvml()
}

output:

Failed to query device count: nvmlErrorString Function Not Found
testGoNvml gpu num: 8
Found 8 devices

example ok

package main

// #cgo LDFLAGS: -ldl -lnvidia-ml
// #cgo CFLAGS: -I /usr/local/cuda-8.0/include
/*
#include <stdio.h>
#include "nvml.h"
void testNvml()
{
    nvmlReturn_t result;
    unsigned int device_count, i;

    // First initialize NVML library
    result = nvmlInit();
    if (NVML_SUCCESS != result)
    {
        printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
        return;
    }

    result = nvmlDeviceGetCount(&device_count);
    if (NVML_SUCCESS != result)
    {
        printf("Failed to query device count: %s\n", nvmlErrorString(result));
        return;
    }
    printf("Found %d device%s\n\n", device_count, device_count != 1 ? "s" : "");
}
*/
import "C"

func main() {
	C.testNvml()
}

output:

Found 8 devices

This is a simple example, actually a possible situation:

a complex golang program import package a and b
package a import gonvml
package b call libnvidia-xxx use cgo
libnvidia-xxx dynamic link libnvidia-ml

Updating to nvidia driver 390.116 has broken this

I updated to the latest nvidia drivers and there's an issue with running the example go file...

$ gonvml/cmd/example$ go run example.go
Initialize() took 668.203408ms
SystemDriverVersion(): 390.116
DeviceCount(): 1
	minorNumber: 0
	uuid: GPU-f4978516-fb34-9fff-a5ae-d7a5b7f8a33c
	name: Quadro P2000
	memory.total: 5304745984, memory.used: 0
	utilization.gpu: 0, utilization.memory: 0
	power.draw: 18850
	average power.draw for last 10s: 18565
	dev.AverageGPUUtilization() error: nvml: Not Found

Found the library on my system in these paths

/usr/lib/i386-linux-gnu/libnvidia-ml.so
/usr/lib/i386-linux-gnu/libnvidia-ml.so.1
/usr/lib/i386-linux-gnu/libnvidia-ml.so.390.116
/usr/lib/x86_64-linux-gnu/libnvidia-ml.so
/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1
/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.390.116

Query clock speeds

I'd like to be able to query the current and maximum gpu clock speeds if possible:

Specifically, for my purposes:

nvmlDeviceGetMaxClockInfo
and
nvmlDeviceGetClockInfo with a clock type of NVML_CLOCK_SM = 1

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.