Ejemplo n.º 1
0
func devicesArgs() ([]string, error) {
	var args []string

	cdevs, err := nvidia.GetControlDevicePaths()
	if err != nil {
		return nil, err
	}
	for i := range cdevs {
		args = append(args, fmt.Sprintf("--device=%s", cdevs[i]))
	}

	devs, err := nvidia.LookupDevices(nvidia.LookupMinimal)
	if err != nil {
		return nil, err
	}

	if len(GPU) == 0 {
		for i := range devs {
			args = append(args, fmt.Sprintf("--device=%s", devs[i].Path))
		}
	} else {
		devs, err := nvidia.FilterDevices(devs, GPU)
		if err != nil {
			return nil, err
		}
		for i := range devs {
			args = append(args, fmt.Sprintf("--device=%s", devs[i].Path))
		}
	}
	return args, nil
}
Ejemplo n.º 2
0
func dockerCLIDevices(ids []string) ([]string, error) {
	devs := make([]string, 0, len(Devices))

	if len(ids) == 1 && (ids[0] == "*" || ids[0] == "") {
		for i := range Devices {
			devs = append(devs, Devices[i].Path)
		}
	} else {
		d, err := nvidia.FilterDevices(Devices, ids)
		if err != nil {
			return nil, err
		}
		for i := range d {
			devs = append(devs, d[i].Path)
		}
	}
	return devs, nil
}