Browse Source

more nvidia capabilities safety (#2509)

pull/2510/head
Jason Dove 8 months ago committed by GitHub
parent
commit
dd92a65742
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 54
      ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs

54
ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs

@ -122,20 +122,27 @@ public class HardwareCapabilitiesFactory : IHardwareCapabilitiesFactory
return string.Empty; return string.Empty;
} }
Option<List<CudaDevice>> maybeDevices = CudaHelper.GetDevices(); try
foreach (List<CudaDevice> devices in maybeDevices.Where(list => list.Count > 0))
{ {
var sb = new StringBuilder(); Option<List<CudaDevice>> maybeDevices = CudaHelper.GetDevices();
foreach (CudaDevice device in devices) foreach (List<CudaDevice> devices in maybeDevices.Where(list => list.Count > 0))
{ {
sb.AppendLine( var sb = new StringBuilder();
CultureInfo.InvariantCulture, foreach (CudaDevice device in devices)
$"GPU #{device.Handle} < {device.Model} > has Compute SM {device.Version.Major}.{device.Version.Minor}"); {
sb.AppendLine(
CultureInfo.InvariantCulture,
$"GPU #{device.Handle} < {device.Model} > has Compute SM {device.Version.Major}.{device.Version.Minor}");
sb.AppendLine(CudaHelper.GetDeviceDetails(device)); sb.AppendLine(CudaHelper.GetDeviceDetails(device));
} }
return sb.ToString(); return sb.ToString();
}
}
catch (FileNotFoundException)
{
// do nothing
} }
// if we don't have a list of cuda devices, fall back to ffmpeg check // if we don't have a list of cuda devices, fall back to ffmpeg check
@ -522,17 +529,24 @@ public class HardwareCapabilitiesFactory : IHardwareCapabilitiesFactory
return new NvidiaHardwareCapabilities(cudaDevice, ffmpegCapabilities, _logger); return new NvidiaHardwareCapabilities(cudaDevice, ffmpegCapabilities, _logger);
} }
Option<List<CudaDevice>> maybeDevices = CudaHelper.GetDevices(); try
foreach (CudaDevice firstDevice in maybeDevices.Map(list => list.HeadOrNone()))
{ {
_logger.LogDebug( Option<List<CudaDevice>> maybeDevices = CudaHelper.GetDevices();
"Detected NVIDIA GPU model {Model} architecture SM {Major}.{Minor}", foreach (CudaDevice firstDevice in maybeDevices.Map(list => list.HeadOrNone()))
firstDevice.Model, {
firstDevice.Version.Major, _logger.LogDebug(
firstDevice.Version.Minor); "Detected NVIDIA GPU model {Model} architecture SM {Major}.{Minor}",
firstDevice.Model,
_memoryCache.Set(CudaDeviceKey, firstDevice); firstDevice.Version.Major,
return new NvidiaHardwareCapabilities(firstDevice, ffmpegCapabilities, _logger); firstDevice.Version.Minor);
_memoryCache.Set(CudaDeviceKey, firstDevice);
return new NvidiaHardwareCapabilities(firstDevice, ffmpegCapabilities, _logger);
}
}
catch (FileNotFoundException)
{
// do nothing
} }
_logger.LogWarning( _logger.LogWarning(

Loading…
Cancel
Save