Пример #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
}
Пример #2
0
func dockerCLIArgs(devs, vols []string) (*dockerArgs, error) {
	cdevs, err := nvidia.GetControlDevicePaths()
	if err != nil {
		return nil, err
	}
	devs, err = dockerCLIDevices(devs)
	if err != nil {
		return nil, err
	}
	vols, err = dockerCLIVolumes(vols)
	if err != nil {
		return nil, err
	}
	return &dockerArgs{
		VolumeDriver: nvidia.DockerPlugin,
		Volumes:      vols,
		Devices:      append(cdevs, devs...),
	}, nil
}