Example #1
0
        public NVidiaGpu(int adapterIndex, NvPhysicalGpuHandle handle)
        {
            AdapterHandle = handle;
            _gpuIdentifer = new NVidiaGpuIdentifer(this);

            GpuModelName = NvApi.NvApiGpuGetFullName(handle, out var gpuName) == NvStatus.Ok ? gpuName.Trim() : "Unknown";

            if (NvApi.GetPciIdentifiers != null && NvApi.GetPciIdentifiers(AdapterHandle, out var deviceId, out var subSystemId, out var revisionId, out var extDeviceId) == NvStatus.Ok)
            {
                DeviceId    = $"0x{deviceId:X}";
                SubSystemId = $"0x{subSystemId:X}";
                RevisionId  = $"0x{revisionId:X}";
            }

            if (NvApi.GetBusSlotId != null && NvApi.GetBusId(AdapterHandle, out _busId) != NvStatus.Ok)
            {
                throw new Exception("Unable to obtain bus slot id");
            }

            GpuFullName = $"NVIDIA {GpuModelName}";
        }