lxd/devices.go
func findNvidiaMinor(pci string) (string, error) {
	nvidiaPath := fmt.Sprintf("/proc/driver/nvidia/gpus/%s/information", pci)
	buf, err := ioutil.ReadFile(nvidiaPath)
	if err != nil {
		return "", err
	}

	strBuf := strings.TrimSpace(string(buf))
	idx := strings.Index(strBuf, "Device Minor:")
	if idx != -1 {
		idx += len("Device Minor:")
		strBuf = strBuf[idx:]
		strBuf = strings.TrimSpace(strBuf)
		parts := strings.SplitN(strBuf, "\n", 2)
		_, err = strconv.Atoi(parts[0])
		if err == nil {
			return parts[0], nil
		}
	}

	minor, err := findNvidiaMinorOld()
	if err == nil {
		return minor, nil
	}

	return "", err
}
func findNvidiaMinor(pci string) (string, error) {
	nvidiaPath := fmt.Sprintf("/proc/driver/nvidia/gpus/%s/information", pci)
	buf, err := ioutil.ReadFile(nvidiaPath)
	if err != nil {
		return "", err
	}

	strBuf := strings.TrimSpace(string(buf))
	idx := strings.Index(strBuf, "Device Minor:")
	if idx != -1 {
		idx += len("Device Minor:")
		strBuf = strBuf[idx:]
		strBuf = strings.TrimSpace(strBuf)
		parts := strings.SplitN(strBuf, "\n", 2)
		_, err = strconv.Atoi(parts[0])
		if err == nil {
			return parts[0], nil
		}
	}

	minor, err := findNvidiaMinorOld()
	if err == nil {
		return minor, nil
	}

	return "", err
}
// Return string for minor number of nvidia device corresponding to the given pci id