Пример #1
0
        public override bool InitializeHardware()
        {
            Logger.Debug("Initializing hardware ...");

            if (NvApi.NvApiEnumPhysicalGpUs == null || NvApi.NvApiGetPhysicalGpUsFromDisplay == null || NvApi.NvApiEnumNvidiaDisplayHandle == null)
            {
                Logger.Debug("Unable to init hardware, NvApiEnumPhysicalGpUs, NvApiEnumNvidiaDisplayHandle and NvApiGetPhysicalGpUsFromDisplay are null pointer");
                return(false);
            }

            NvStatus status;
            var      handles = new NvPhysicalGpuHandle[NvApi.MaxPhysicalGpus];

            if ((status = NvApi.NvApiEnumPhysicalGpUs(handles, out var gpuCount)) != NvStatus.Ok)
            {
                Logger.Error($"Unable to enumerate physical gpus, the API status is: {status}");
                return(false);
            }

            for (var gpuIndex = 0; gpuIndex < gpuCount; gpuIndex++)
            {
                var ngpu = new NVidiaGpu(gpuIndex, handles[gpuIndex]);
                Logger.Debug($"Adding GPU {ngpu}");
                ngpu.InitializeSensors();
                Hardware.Add(ngpu);
            }

            return(true);
        }
Пример #2
0
        public override bool Open()
        {
            try {
                InitializeHardware();
            } catch (Exception e) {
                Logger.Error("Unable to initialize module hardware", e);
                return(false);
            }

            return(true);
        }