Skip to content

Commit

Permalink
Multi-GPU support for srmd-ncnn-vulkan&Fix bug
Browse files Browse the repository at this point in the history
v2.51.02-beta:
- 为srmd-ncnn-vulkan加入多gpu支持.
- 性能优化.
- 修复bug:重复检测waifu2x-ncnn-vulkan可用显卡时,软件会崩溃.
- 其他改进(忘了还改啥了).
  • Loading branch information
AaronFeng753 committed Jun 22, 2020
1 parent 743f020 commit 79c0f79
Show file tree
Hide file tree
Showing 12 changed files with 2,151 additions and 1,921 deletions.
6 changes: 3 additions & 3 deletions SRC/Waifu2x-Extension-QT/Waifu2x-Extension-QT.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.1, 2020-06-19T13:59:44. -->
<!-- Written by QtCreator 4.10.1, 2020-06-22T09:59:28. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -73,7 +73,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.13.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.13.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5132.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down Expand Up @@ -323,7 +323,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/workspace/Waifu2x-Extension-QT/build-Waifu2x-Extension-QT-Desktop_Qt_5_13_2_MinGW_64_bit-Release</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/workspace/Waifu2x-Extension-QT/build-Waifu2x-Extension-QT-Desktop_Qt_5_13_2_MinGW_64_bit-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
901 changes: 455 additions & 446 deletions SRC/Waifu2x-Extension-QT/language_Chinese.ts

Large diffs are not rendered by default.

901 changes: 455 additions & 446 deletions SRC/Waifu2x-Extension-QT/language_English.ts

Large diffs are not rendered by default.

901 changes: 455 additions & 446 deletions SRC/Waifu2x-Extension-QT/language_Japanese.ts

Large diffs are not rendered by default.

901 changes: 455 additions & 446 deletions SRC/Waifu2x-Extension-QT/language_TraditionalChinese.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions SRC/Waifu2x-Extension-QT/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ int main(int argc, char *argv[])

/*
Change log:
v2.51.02-beta:
- 为srmd-ncnn-vulkan加入多gpu支持.
- 性能优化.
- 修复bug:重复检测waifu2x-ncnn-vulkan可用显卡时,软件会崩溃.
- 其他改进(忘了还改啥了).
v2.51.01-beta:
- 为waifu2x-ncnn-vulkan加入多gpu支持.
v2.46.08.1-beta:
Expand Down
23 changes: 20 additions & 3 deletions SRC/Waifu2x-Extension-QT/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MainWindow : public QMainWindow
MainWindow(QWidget *parent = nullptr);
void changeEvent(QEvent *e);
//=======================
QString VERSION = "v2.51.01-beta";//软件版本号
QString VERSION = "v2.51.02-beta";//软件版本号
bool isBetaVer = true;
QString LastStableVer = "v2.45.18";
//=======================
Expand Down Expand Up @@ -214,6 +214,7 @@ class MainWindow : public QMainWindow
int SRMD_NCNN_Vulkan_Video(int rowNum);
int SRMD_NCNN_Vulkan_Video_BySegment(int rowNum);
int SRMD_NCNN_Vulkan_Video_scale(QMap<QString, QString> Sub_Thread_info,int *Sub_video_ThreadNumRunning,bool *Frame_failed);
QString SrmdNcnnVulkan_ReadSettings();
//=================================
int Waifu2x_Caffe_Image(int rowNum);//Caffe放大图片线程
//Caffe放大GIF线程:1.主线程,拆分,调度放大子线程,组装&压缩;2.放大子线程,负责放大所有帧以及调整大小
Expand Down Expand Up @@ -281,11 +282,19 @@ class MainWindow : public QMainWindow
bool isCompatible_Realsr_NCNN_Vulkan=false;

//============================== 多显卡 ==========================================
//waifu2x-ncnn-vulkan
int GPU_ID_Waifu2x_NCNN_Vulkan_MultiGPU = 0;
QMap<QString,QString> Waifu2x_NCNN_Vulkan_MultiGPU();
QMutex MultiGPU_QMutex_Waifu2xNCNNVulkan;
QList<QMap<QString, QString>> GPUIDs_List_MultiGPU_Waifu2xNCNNVulkan;
void AddGPU_MultiGPU_Waifu2xNCNNVulkan(QString GPUID);

//SRMD-ncnn-vulkan
int GPU_ID_SrmdNcnnVulkan_MultiGPU = 0;
QMap<QString,QString> SrmdNcnnVulkan_MultiGPU();
QMutex MultiGPU_QMutex_SrmdNcnnVulkan;
QList<QMap<QString, QString>> GPUIDs_List_MultiGPU_SrmdNcnnVulkan;
void AddGPU_MultiGPU_SrmdNcnnVulkan(QString GPUID);
//================================ progressbar ===================================
int Progressbar_MaxVal = 0;//进度条最大值
int Progressbar_CurrentVal = 0;//进度条当前值
Expand Down Expand Up @@ -587,8 +596,6 @@ private slots:

void on_pushButton_DetectGPUID_srmd_clicked();

void on_comboBox_GPUID_srmd_currentIndexChanged(int index);

void on_checkBox_AudioDenoise_stateChanged(int arg1);

void on_tabWidget_currentChanged(int index);
Expand Down Expand Up @@ -663,6 +670,16 @@ private slots:

void on_checkBox_MultiGPU_Waifu2xNCNNVulkan_stateChanged(int arg1);

void on_checkBox_MultiGPU_SrmdNCNNVulkan_stateChanged(int arg1);

void on_checkBox_MultiGPU_SrmdNCNNVulkan_clicked();

void on_comboBox_GPUIDs_MultiGPU_SrmdNCNNVulkan_currentIndexChanged(int index);

void on_checkBox_isEnable_CurrentGPU_MultiGPU_SrmdNCNNVulkan_clicked();

void on_spinBox_TileSize_CurrentGPU_MultiGPU_SrmdNCNNVulkan_valueChanged(int arg1);

signals:
void Send_SystemTray_NewMessage(QString message);

Expand Down
144 changes: 111 additions & 33 deletions SRC/Waifu2x-Extension-QT/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ Realsr-ncnn-vulkan [ Speed:☆ Image Quality:★★★ ]
<item row="2" column="0" colspan="8">
<widget class="QTabWidget" name="tabWidget_Engines">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
Expand Down Expand Up @@ -2556,6 +2556,99 @@ Smaller Block size means waifu2x will use less GPU memory and run slower.</strin
- [ Speed:★☆ Image Quality:★★★ ]</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_36">
<item row="1" column="0">
<widget class="QLabel" name="label_41">
<property name="text">
<string>GPU ID:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_GPUSettings_MultiGPU_SrmdNCNNVulkan">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
<property name="title">
<string>GPU Settings(Multi-GPU)</string>
</property>
<layout class="QGridLayout" name="gridLayout_41">
<item row="0" column="3">
<widget class="QLabel" name="label_68">
<property name="text">
<string>Tile size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="spinBox_TileSize_CurrentGPU_MultiGPU_SrmdNCNNVulkan">
<property name="minimum">
<number>32</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkBox_isEnable_CurrentGPU_MultiGPU_SrmdNCNNVulkan">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_69">
<property name="text">
<string>GPU ID:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_GPUIDs_MultiGPU_SrmdNCNNVulkan">
<property name="currentText">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_GPUID_srmd">
<property name="toolTip">
<string>Select the GPU to use when enabling the &quot;srmd-ncnn-vulkan&quot; engine.</string>
</property>
<property name="currentText">
<string notr="true">auto</string>
</property>
<item>
<property name="text">
<string notr="true">auto</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_40">
<property name="toolTip">
Expand All @@ -2568,10 +2661,16 @@ Smaller tile size means SRMD will use less GPU memory and run slower.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_41">
<item row="0" column="2">
<widget class="QCheckBox" name="checkBox_TTA_srmd">
<property name="toolTip">
<string>TTA(Test-Time Augmentation):
The processing time is eight times longer than when unchecked,
and the peak signal-to-noise ratio (PSNR) is increased by 0.15,
but the effect may not be obvious. It is not recommended to enable it.</string>
</property>
<property name="text">
<string>GPU ID:</string>
<string notr="true">TTA</string>
</property>
</widget>
</item>
Expand All @@ -2596,35 +2695,7 @@ Smaller tile size means SRMD will use less GPU memory and run slower.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkBox_TTA_srmd">
<property name="toolTip">
<string>TTA(Test-Time Augmentation):
The processing time is eight times longer than when unchecked,
and the peak signal-to-noise ratio (PSNR) is increased by 0.15,
but the effect may not be obvious. It is not recommended to enable it.</string>
</property>
<property name="text">
<string notr="true">TTA</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="comboBox_GPUID_srmd">
<property name="toolTip">
<string>Select the GPU to use when enabling the &quot;srmd-ncnn-vulkan&quot; engine.</string>
</property>
<property name="currentText">
<string notr="true">auto</string>
</property>
<item>
<property name="text">
<string notr="true">auto</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="2" column="0" colspan="3">
<widget class="QPushButton" name="pushButton_DetectGPUID_srmd">
<property name="styleSheet">
<string notr="true">QPushButton{
Expand Down Expand Up @@ -2661,6 +2732,13 @@ padding:10px;
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBox_MultiGPU_SrmdNCNNVulkan">
<property name="text">
<string>Enable Multi-GPU</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
Expand Down
12 changes: 0 additions & 12 deletions SRC/Waifu2x-Extension-QT/realsr_ncnn_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
int MainWindow::Realsr_NCNN_Vulkan_Image(int rowNum)
{
//============================= 读取设置 ================================
int TileSize = ui->spinBox_TileSize->value();
bool DelOriginal = ui->checkBox_DelOriginal->isChecked();
bool SaveAsJPG = ui->checkBox_SaveAsJPG->isChecked();
//======
Expand Down Expand Up @@ -93,9 +92,6 @@ int MainWindow::Realsr_NCNN_Vulkan_Image(int rowNum)
QProcess *Waifu2x = new QProcess();
QString Waifu2x_folder_path = Current_Path+"/realsr-ncnn-vulkan";
QString program = Waifu2x_folder_path+"/realsr-ncnn-vulkan_waifu2xEX.exe";
//===========
QString TTA_cmd="";
if(TTA_isEnabled)TTA_cmd=" -x ";
//==========
int ScaleRatio_tmp=0;
//如果设定的scaleRatio不是偶数,则+1,并输出到tmp
Expand Down Expand Up @@ -618,7 +614,6 @@ int MainWindow::Realsr_NCNN_Vulkan_GIF_scale(QMap<QString, QString> Sub_Thread_i
QString SourceFile_fullPath = Sub_Thread_info["SourceFile_fullPath"];
QString Frame_fileName = Sub_Thread_info["Frame_fileName"];
//===========
int TileSize = ui->spinBox_TileSize->value();
int ScaleRatio = ui->spinBox_ScaleRatio_gif->value();
bool TTA_isEnabled = ui->checkBox_TTA_vulkan->isChecked();
QString Frame_fileFullPath = SplitFramesFolderPath+"/"+Frame_fileName;
Expand Down Expand Up @@ -646,9 +641,6 @@ int MainWindow::Realsr_NCNN_Vulkan_GIF_scale(QMap<QString, QString> Sub_Thread_i
QProcess *Waifu2x = new QProcess();
QString Waifu2x_folder_path = Current_Path+"/realsr-ncnn-vulkan";
QString program = Waifu2x_folder_path+"/realsr-ncnn-vulkan_waifu2xEX.exe";
//===========
QString TTA_cmd="";
if(TTA_isEnabled)TTA_cmd=" -x ";
//=================
//======
int ScaleRatio_tmp=0;
Expand Down Expand Up @@ -1683,7 +1675,6 @@ int MainWindow::Realsr_NCNN_Vulkan_Video_scale(QMap<QString,QString> Sub_Thread_
QString SourceFile_fullPath = Sub_Thread_info["SourceFile_fullPath"];
QString Frame_fileName = Sub_Thread_info["Frame_fileName"];
//================
int TileSize = ui->spinBox_TileSize->value();
int ScaleRatio = ui->spinBox_ScaleRatio_video->value();
bool TTA_isEnabled = ui->checkBox_TTA_vulkan->isChecked();
//========================================================================
Expand Down Expand Up @@ -1714,9 +1705,6 @@ int MainWindow::Realsr_NCNN_Vulkan_Video_scale(QMap<QString,QString> Sub_Thread_
QString Waifu2x_folder_path = Current_Path+"/realsr-ncnn-vulkan";
QString program = Waifu2x_folder_path+"/realsr-ncnn-vulkan_waifu2xEX.exe";
//===========
QString TTA_cmd="";
if(TTA_isEnabled)TTA_cmd=" -x ";
//===========
int ScaleRatio_tmp=0;
if((ScaleRatio%2)==0)
{
Expand Down
17 changes: 15 additions & 2 deletions SRC/Waifu2x-Extension-QT/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ int MainWindow::Settings_Save()
//==
configIniWrite->setValue("/settings/comboBox_GPUID_RealsrNCNNVulkan", ui->comboBox_GPUID_RealsrNCNNVulkan->currentIndex());
configIniWrite->setValue("/settings/Available_GPUID_Realsr_ncnn_vulkan", Available_GPUID_Realsr_ncnn_vulkan);
//==
configIniWrite->setValue("/settings/comboBox_TargetProcessor_converter", ui->comboBox_TargetProcessor_converter->currentIndex());
configIniWrite->setValue("/settings/Available_ProcessorList_converter", Available_ProcessorList_converter);
//==
configIniWrite->setValue("/settings/comboBox_GPUID_srmd", ui->comboBox_GPUID_srmd->currentIndex());
configIniWrite->setValue("/settings/Available_GPUID_srmd", Available_GPUID_srmd);
configIniWrite->setValue("/settings/GPUIDs_List_MultiGPU_SrmdNcnnVulkan", QVariant::fromValue(GPUIDs_List_MultiGPU_SrmdNcnnVulkan));
configIniWrite->setValue("/settings/checkBox_MultiGPU_SrmdNCNNVulkan", ui->checkBox_MultiGPU_SrmdNCNNVulkan->isChecked());
//================== 存储 扩展名 =================================
configIniWrite->setValue("/settings/ImageEXT", ui->Ext_image->text());
configIniWrite->setValue("/settings/VideoEXT", ui->Ext_video->text());
Expand Down Expand Up @@ -283,14 +287,15 @@ int MainWindow::Settings_Read_Apply()
//Waifu2x-NCNN-Vulkan
Available_GPUID = Settings_Read_value("/settings/Available_GPUID_Waifu2xNCNNVulkan").toStringList();
Waifu2x_DetectGPU_finished();
ui->comboBox_GPUID->setCurrentIndex(Settings_Read_value("/settings/CurrentGPUID_Waifu2xNCNNVulkan").toInt());
//读取多显卡设定
GPUIDs_List_MultiGPU_Waifu2xNCNNVulkan = Settings_Read_value("/settings/GPUIDs_List_MultiGPU_Waifu2xNCNNVulkan").value<QList<QMap<QString, QString>> >();
if(GPUIDs_List_MultiGPU_Waifu2xNCNNVulkan.isEmpty()==false)
{
QMap<QString,QString> GPUInfo_waifu2xNcnnVulkan = GPUIDs_List_MultiGPU_Waifu2xNCNNVulkan.at(ui->comboBox_GPUIDs_MultiGPU_Waifu2xNCNNVulkan->currentIndex());
ui->checkBox_isEnable_CurrentGPU_MultiGPU_Waifu2xNCNNVulkan->setChecked(GPUInfo_waifu2xNcnnVulkan["isEnabled"] == "true");
ui->spinBox_TileSize_CurrentGPU_MultiGPU_Waifu2xNCNNVulkan->setValue(GPUInfo_waifu2xNcnnVulkan["TileSize"].toInt());
}
ui->comboBox_GPUID->setCurrentIndex(Settings_Read_value("/settings/CurrentGPUID_Waifu2xNCNNVulkan").toInt());
ui->checkBox_MultiGPU_Waifu2xNCNNVulkan->setChecked(Settings_Read_value("/settings/checkBox_MultiGPU_Waifu2xNCNNVulkan").toBool());
//Realsr_ncnn_vulkan
Available_GPUID_Realsr_ncnn_vulkan = Settings_Read_value("/settings/Available_GPUID_Realsr_ncnn_vulkan").toStringList();
Expand All @@ -305,7 +310,15 @@ int MainWindow::Settings_Read_Apply()
Available_GPUID_srmd = Settings_Read_value("/settings/Available_GPUID_srmd").toStringList();
SRMD_DetectGPU_finished();
ui->comboBox_GPUID_srmd->setCurrentIndex(Settings_Read_value("/settings/comboBox_GPUID_srmd").toInt());
on_comboBox_GPUID_srmd_currentIndexChanged(0);
//读取多显卡设定
GPUIDs_List_MultiGPU_SrmdNcnnVulkan = Settings_Read_value("/settings/GPUIDs_List_MultiGPU_SrmdNcnnVulkan").value<QList<QMap<QString, QString>> >();
if(GPUIDs_List_MultiGPU_SrmdNcnnVulkan.isEmpty()==false)
{
QMap<QString,QString> GPUInfo_SrmdNcnnVulkan = GPUIDs_List_MultiGPU_SrmdNcnnVulkan.at(ui->comboBox_GPUIDs_MultiGPU_SrmdNCNNVulkan->currentIndex());
ui->checkBox_isEnable_CurrentGPU_MultiGPU_SrmdNCNNVulkan->setChecked(GPUInfo_SrmdNcnnVulkan["isEnabled"] == "true");
ui->spinBox_TileSize_CurrentGPU_MultiGPU_SrmdNCNNVulkan->setValue(GPUInfo_SrmdNcnnVulkan["TileSize"].toInt());
}
ui->checkBox_MultiGPU_SrmdNCNNVulkan->setChecked(Settings_Read_value("/settings/checkBox_MultiGPU_SrmdNCNNVulkan").toBool());
//================= 加载 扩展名 ===========================
ui->Ext_image->setText(Settings_Read_value("/settings/ImageEXT").toString());
ui->Ext_video->setText(Settings_Read_value("/settings/VideoEXT").toString());
Expand Down

0 comments on commit 79c0f79

Please sign in to comment.