예제 #1
0
        private static bool GetDeviceByPciBusID(string fullPciBusID, out NvmlDevice device, out string errorMessage)
        {
            device = new NvmlDevice();

            var response =
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PInvokeWindows.NvmlDeviceGetHandleByPciBusId(fullPciBusID, ref device)
                : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? PInvokeLinux.NvmlDeviceGetHandleByPciBusId(fullPciBusID, ref device)
                : 12;

            errorMessage = (response == SUCCESS)
                 ? string.Empty
                 : NvmlErrorString(response);

            return(response == SUCCESS);
        }