|
|
|
@ -28,55 +28,65 @@ public partial class LoginWindow : Window |
|
|
|
|
private void checkNvidia() |
|
|
|
|
{ |
|
|
|
|
string nvidiaVersion = ""; |
|
|
|
|
using (Process process = new Process()) |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
process.StartInfo.FileName = "nvidia-smi"; |
|
|
|
|
process.StartInfo.Arguments = "--query-gpu=driver_version --format=csv,noheader,nounits"; |
|
|
|
|
process.StartInfo.UseShellExecute = false; |
|
|
|
|
process.StartInfo.CreateNoWindow = true; |
|
|
|
|
process.StartInfo.RedirectStandardOutput = true; |
|
|
|
|
process.StartInfo.RedirectStandardError = true; |
|
|
|
|
using (Process process = new Process()) |
|
|
|
|
{ |
|
|
|
|
process.StartInfo.FileName = "nvidia-smi"; |
|
|
|
|
process.StartInfo.Arguments = "--query-gpu=driver_version --format=csv,noheader,nounits"; |
|
|
|
|
process.StartInfo.UseShellExecute = false; |
|
|
|
|
process.StartInfo.CreateNoWindow = true; |
|
|
|
|
process.StartInfo.RedirectStandardOutput = true; |
|
|
|
|
process.StartInfo.RedirectStandardError = true; |
|
|
|
|
|
|
|
|
|
// 使用StringBuilder来捕获输出和错误信息 |
|
|
|
|
StringBuilder outputBuilder = new StringBuilder(); |
|
|
|
|
StringBuilder errorBuilder = new StringBuilder(); |
|
|
|
|
// 使用StringBuilder来捕获输出和错误信息 |
|
|
|
|
StringBuilder outputBuilder = new StringBuilder(); |
|
|
|
|
StringBuilder errorBuilder = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
process.OutputDataReceived += (sender, e) => |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) |
|
|
|
|
outputBuilder.AppendLine(e.Data); |
|
|
|
|
}; |
|
|
|
|
process.ErrorDataReceived += (sender, e) => |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) |
|
|
|
|
errorBuilder.AppendLine(e.Data); |
|
|
|
|
}; |
|
|
|
|
process.OutputDataReceived += (sender, e) => |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) |
|
|
|
|
outputBuilder.AppendLine(e.Data); |
|
|
|
|
}; |
|
|
|
|
process.ErrorDataReceived += (sender, e) => |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) |
|
|
|
|
errorBuilder.AppendLine(e.Data); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
process.Start(); |
|
|
|
|
process.Start(); |
|
|
|
|
|
|
|
|
|
// 开始异步读取输出和错误流 |
|
|
|
|
process.BeginOutputReadLine(); |
|
|
|
|
process.BeginErrorReadLine(); |
|
|
|
|
// 开始异步读取输出和错误流 |
|
|
|
|
process.BeginOutputReadLine(); |
|
|
|
|
process.BeginErrorReadLine(); |
|
|
|
|
|
|
|
|
|
process.WaitForExit(); |
|
|
|
|
process.WaitForExit(); |
|
|
|
|
|
|
|
|
|
// 获取完整的输出和错误信息 |
|
|
|
|
string outputMsg = outputBuilder.ToString(); |
|
|
|
|
string errorMsg = errorBuilder.ToString(); |
|
|
|
|
nvidiaVersion = (string.IsNullOrWhiteSpace(errorMsg)?outputMsg:errorMsg).Trim(); |
|
|
|
|
if (process.ExitCode == 0 || !string.IsNullOrWhiteSpace(nvidiaVersion)) |
|
|
|
|
{ |
|
|
|
|
if (CompareVersions(nvidiaVersion, "528.33") <= 0) |
|
|
|
|
// 获取完整的输出和错误信息 |
|
|
|
|
string outputMsg = outputBuilder.ToString(); |
|
|
|
|
string errorMsg = errorBuilder.ToString(); |
|
|
|
|
nvidiaVersion = (string.IsNullOrWhiteSpace(errorMsg) ? outputMsg : errorMsg).Trim(); |
|
|
|
|
if (process.ExitCode == 0 || !string.IsNullOrWhiteSpace(nvidiaVersion)) |
|
|
|
|
{ |
|
|
|
|
if (CompareVersions(nvidiaVersion, "528.33") <= 0) |
|
|
|
|
{ |
|
|
|
|
MessageBox messageBox = new MessageBox(); |
|
|
|
|
messageBox.Show(MultilingualHelper.getString("NotNvidiaVersionLow") |
|
|
|
|
.Replace("%version", nvidiaVersion)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
MessageBox messageBox = new MessageBox(); |
|
|
|
|
messageBox.Show(MultilingualHelper.getString("NotNvidiaVersionLow").Replace("%version", nvidiaVersion)); |
|
|
|
|
messageBox.Show(MultilingualHelper.getString("NotNvidia")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
MessageBox messageBox = new MessageBox(); |
|
|
|
|
messageBox.Show(MultilingualHelper.getString("NotNvidia")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error(ex.Message); |
|
|
|
|
MessageBox messageBox = new MessageBox(); |
|
|
|
|
messageBox.Show(MultilingualHelper.getString("NotNvidia")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|