NVIDIA/go-nvfm
C
Captured source
source ↗NVIDIA/go-nvfm
Description: Go Bindings for the NVIDIA Fabric Manager SDK (NVFM)
Language: C
License: Apache-2.0
Stars: 0
Forks: 1
Open issues: 0
Created: 2026-06-22T21:42:58Z
Pushed: 2026-06-29T23:50:45Z
Default branch: main
Fork: no
Archived: no
README:
go-nvfm
Go Bindings for the NVIDIA Fabric Manager SDK (NVFM)
Table of Contents
- [Overview](#overview)
- [Fabric Manager SDK Package](#fabric-manager-sdk-package)
- [Quick Start](#quick-start)
- [How the bindings are generated](#how-the-bindings-are-generated)
- [Code Structure](#code-structure)
- [Code defining the NVFM API](#code-defining-the-nvfm-api)
- [Code to load
libnvfm.so](#code-to-load-libnvfmso) - [Code to bridge the auto-generated and manual bindings](#code-to-bridge-the-auto-generated-and-manual-bindings)
- [Manual wrappers around the auto-generated bindings from
c-for-go](#manual-wrappers-around-the-auto-generated-bindings-from-c-for-go) - [Test code](#test-code)
- [Building and Testing](#building-and-testing)
- [Updating the Code](#updating-the-code)
- [Update the Fabric Manager SDK headers](#update-the-fabric-manager-sdk-headers)
- [Regenerate bindings](#regenerate-bindings)
- [Add manual wrappers](#add-manual-wrappers)
- [Releasing](#releasing)
- [Contributing](#contributing)
Overview
This repository provides Go bindings for the NVIDIA Fabric Manager SDK (NVFM).
At present, these bindings are only supported on Linux.
These bindings are not a reimplementation of Fabric Manager in Go, but rather a set of wrappers around the C API provided by libnvfm.so. Fabric Manager itself runs as a daemon/service. Applications using these bindings initialize the local client library with nvfm.Init(), then connect to the running Fabric Manager daemon with nvfm.Connect() before using connection-oriented APIs.
Note: A working Fabric Manager installation with libnvfm.so is not required to compile code that imports these bindings. However, you will get a runtime error if libnvfm.so is not available in your library path at runtime. Connection-oriented APIs also require a running Fabric Manager service.
The vendored SDK headers in gen/nvfm come from the latest available CUDA repository package and will need to be periodically refreshed.
The SDK headers retain the notices provided in NVIDIA's development package.
Fabric Manager SDK Package
libnvfm.so, nv_fm_agent.h, and nv_fm_types.h are shipped in the Fabric Manager SDK/development package, not necessarily in the core Fabric Manager daemon package. NVIDIA documents the SDK as a separate RPM/Debian development package for compiling Fabric Manager API clients. See the NVIDIA Fabric Manager User Guide.
Use the package that matches the installed driver/Fabric Manager branch and version.
| Linux family | Package name to look for | NVIDIA CUDA repo path pattern | | --- | --- | --- | | Ubuntu/Debian | nvidia-fabricmanager-dev or nvidia-fabricmanager-dev- | https://developer.download.nvidia.com/compute/cuda/repos/// | | RHEL/CentOS/Rocky/Alma/Amazon/Fedora | nvidia-fabricmanager-devel or nvidia-fabric-manager-devel | https://developer.download.nvidia.com/compute/cuda/repos/// |
Examples of repo path components are ubuntu2204/x86_64, ubuntu2404/x86_64, rhel8/x86_64, rhel9/x86_64, and rhel10/sbsa.
On Debian/Ubuntu-based systems:
apt-cache search nvidia-fabricmanager-dev apt-cache policy nvidia-fabricmanager-dev nvidia-fabricmanager-dev- sudo apt-get install nvidia-fabricmanager-dev
On RPM-based systems:
dnf repoquery 'nvidia-fabric*manager*devel*' sudo dnf install nvidia-fabricmanager-devel # If your configured repo uses the dashed package name: sudo dnf install nvidia-fabric-manager-devel
Quick Start
The code below shows an example of initializing the local NVFM client library, connecting to Fabric Manager over a Unix domain socket, and querying the number of supported fabric partitions.
package main
import (
"fmt"
"log"
"github.com/NVIDIA/go-nvfm/pkg/nvfm"
)
func main() {
ret := nvfm.Init()
if ret != nvfm.SUCCESS {
log.Fatalf("unable to initialize NVFM: %v", nvfm.ErrorString(ret))
}
defer nvfm.Shutdown()
handle, ret := nvfm.Connect(nvfm.WithUnixSocket("/run/nvidia-fabricmanager/socket"))
if ret != nvfm.SUCCESS {
log.Fatalf("unable to connect to Fabric Manager: %v", nvfm.ErrorString(ret))
}
defer handle.Disconnect()
partitions, ret := handle.GetSupportedFabricPartitions()
if ret != nvfm.SUCCESS {
log.Fatalf("unable to query partitions: %v", nvfm.ErrorString(ret))
}
fmt.Printf("Supported partitions: %d\n", partitions.NumPartitions)
}Sample output:
$ go run main.go Supported partitions: 15
Note: Use nvfm.WithAddress(address) instead of nvfm.WithUnixSocket(path) to connect over TCP.
How the bindings are generated
This project leverages two core technologies:
1. Go's builtin support for cgo () 1. A third-party tool called c-for-go ()
Using these tools, we generate Go bindings for NVFM from the Fabric Manager SDK headers:
nv_fm_agent.hnv_fm_types.h
Most of the process to generate these bindings is automated, but manual code is still used to make the generated bindings more useful from an end user's perspective. The basic flow to generate the bindings is therefore to:
1. Copy the desired Fabric Manager SDK headers into gen/nvfm 1. Run c-for-go using gen/nvfm/nvfm.yml 1. Run go tool cgo -godefs to produce Go struct layouts in types_gen.go 1. Generate package and handle interfaces with gen/nvfm/generateapi.go 1. Keep manual wrappers around the raw generated calls in pkg/nvfm
As an example, consider the generated binding for fmGetSupportedFabricPartitions():
Original API in nv_fm_agent.h:
fmReturn_t fmGetSupportedFabricPartitions(fmHandle_t pFmHandle, fmFabricPartitionList_t *pFmFabricPartition);
Auto-generated Go binding from c-for-go:
func fmGetSupportedFabricPartitions(PFmHandle *nvfmHandle, PFmFabricPartition *FabricPartitionList) Return {
cPFmHandle, cPFmHandleAllocMap := (C.fmHandle_t)(unsafe.Pointer(PFmHandle)), cgoAllocsUnknown
cPFmFabricPartition, cPFmFabricPartitionAllocMap := (*C.fmFabricPartitionList_t)(unsafe.Pointer(PFmFabricPartition)), cgoAllocsUnknown
__ret := C.fmGetSupportedFabricPartitions(cPFmHandle, cPFmFabricPartition)
runtime.KeepAlive(cPFmFabricPartitionAllocMap)...Excerpt shown — open the source for the full document.
Notability
notability 3.0/10Routine library repo from NVIDIA, no major AI launch.