Skip to content

Latest commit

 

History

History
94 lines (72 loc) · 2.55 KB

README.md

File metadata and controls

94 lines (72 loc) · 2.55 KB

Go Bindings for the ROCm SMI Library

Go Report Card GoDoc License

A lightweight Go wrapper for AMD's ROCm System Management Interface (SMI) library. Monitor and control AMD GPUs with ease.

Overview

This library provides Go bindings for the ROCm SMI library, allowing you to:

  • Monitor GPU metrics (temperature, power, memory, utilization)
  • Control GPU settings (fan speed, clock frequencies)
  • Access device information (name, PCIe config, driver version)

Requirements

  • ROCm 5.0 or later
  • Go 1.21 or later
  • GCC/Clang compiler

Quick Start

  1. Install ROCm

    # Verify ROCm installation
    ls /opt/rocm/include/rocm_smi/rocm_smi.h
    ls /opt/rocm/lib/librocm_smi64.so
  2. Install Package

    go get github.com/xigang/go-rocm
  3. Basic Usage

    package main
    
    import (
        "log"
        "github.com/xigang/go-rocm/pkg/rocm"
    )
    
    func main() {
        // Initialize ROCm SMI
        if err := rocm.Initialize(); err != nil {
            log.Fatal(err)
        }
        defer rocm.Shutdown()
    
        // Get GPU count
        count, err := rocm.DeviceCount()
        if err != nil {
            log.Fatal(err)
        }
    
        // Print GPU information
        for i := 0; i < count; i++ {
            device := rocm.NewDevice(uint32(i))
            name, _ := device.GetDeviceName()
            temp, _ := device.GetTemperature(0, rocm.TempCurrent)
            power, _ := device.GetPowerUsage()
            util, _ := device.GetUtilization()
    
            log.Printf("GPU %d: %s", i, name)
            log.Printf("  Temperature: %d°C", temp)
            log.Printf("  Power: %d W", power/1000000)
            log.Printf("  Utilization: %d%%", util)
        }
    }

Building

make build

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • AMD ROCm team for the SMI library
  • All contributors to this project