add HardwareMonitor (Windows Only)
This commit is contained in:
parent
fcd59de6fb
commit
eaae7624a7
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -57,6 +57,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
args: install upx
|
args: install upx
|
||||||
- run: |
|
- run: |
|
||||||
|
Start-BitsTransfer https://github.com/josStorer/LibreHardwareMonitor.Console/releases/download/v0.1.0/LibreHardwareMonitor.Console.zip ./LibreHardwareMonitor.Console.zip
|
||||||
|
Expand-Archive ./LibreHardwareMonitor.Console.zip -DestinationPath ./components/LibreHardwareMonitor.Console
|
||||||
Start-BitsTransfer https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip ./python-3.10.11-embed-amd64.zip
|
Start-BitsTransfer https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip ./python-3.10.11-embed-amd64.zip
|
||||||
Expand-Archive ./python-3.10.11-embed-amd64.zip -DestinationPath ./py310
|
Expand-Archive ./python-3.10.11-embed-amd64.zip -DestinationPath ./py310
|
||||||
$content=Get-Content "./py310/python310._pth"; $content | ForEach-Object {if ($_.ReadCount -eq 3) {"Lib\\site-packages"} else {$_}} | Set-Content ./py310/python310._pth
|
$content=Get-Content "./py310/python310._pth"; $content | ForEach-Object {if ($_.ReadCount -eq 3) {"Lib\\site-packages"} else {$_}} | Set-Content ./py310/python310._pth
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package backend_golang
|
package backend_golang
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -8,6 +9,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/minio/selfupdate"
|
"github.com/minio/selfupdate"
|
||||||
@ -41,6 +43,7 @@ func (a *App) OnStartup(ctx context.Context) {
|
|||||||
a.cmdPrefix = "cd " + a.exDir + " && "
|
a.cmdPrefix = "cd " + a.exDir + " && "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.Chmod("./backend-rust/webgpu_server", 0777)
|
||||||
os.Mkdir(a.exDir+"models", os.ModePerm)
|
os.Mkdir(a.exDir+"models", os.ModePerm)
|
||||||
os.Mkdir(a.exDir+"lora-models", os.ModePerm)
|
os.Mkdir(a.exDir+"lora-models", os.ModePerm)
|
||||||
os.Mkdir(a.exDir+"finetune/json2binidx_tool/data", os.ModePerm)
|
os.Mkdir(a.exDir+"finetune/json2binidx_tool/data", os.ModePerm)
|
||||||
@ -50,7 +53,18 @@ func (a *App) OnStartup(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.downloadLoop()
|
a.downloadLoop()
|
||||||
|
a.watchFs()
|
||||||
|
a.monitorHardware()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) OnBeforeClose(ctx context.Context) bool {
|
||||||
|
if monitor != nil {
|
||||||
|
monitor.Process.Kill()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) watchFs() {
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
watcher.Add("./lora-models")
|
watcher.Add("./lora-models")
|
||||||
@ -62,7 +76,7 @@ func (a *App) OnStartup(ctx context.Context) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wruntime.EventsEmit(ctx, "fsnotify", event.Name)
|
wruntime.EventsEmit(a.ctx, "fsnotify", event.Name)
|
||||||
case _, ok := <-watcher.Errors:
|
case _, ok := <-watcher.Errors:
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@ -73,6 +87,36 @@ func (a *App) OnStartup(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var monitor *exec.Cmd
|
||||||
|
|
||||||
|
func (a *App) monitorHardware() {
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor = exec.Command("./components/LibreHardwareMonitor.Console/LibreHardwareMonitor.Console.exe")
|
||||||
|
stdout, err := monitor.StdoutPipe()
|
||||||
|
if err != nil {
|
||||||
|
monitor = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
reader := bufio.NewReader(stdout)
|
||||||
|
for {
|
||||||
|
line, _, err := reader.ReadLine()
|
||||||
|
if err != nil {
|
||||||
|
wruntime.EventsEmit(a.ctx, "monitorerr", err.Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
wruntime.EventsEmit(a.ctx, "monitor", string(line))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
monitor.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||||
|
monitor.Start()
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) UpdateApp(url string) (broken bool, err error) {
|
func (a *App) UpdateApp(url string) (broken bool, err error) {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -245,5 +245,8 @@
|
|||||||
"Please convert model to safe tensors format first": "モデルを安全なテンソル形式に変換してください",
|
"Please convert model to safe tensors format first": "モデルを安全なテンソル形式に変換してください",
|
||||||
"Convert To Safe Tensors Format": "安全なテンソル形式に変換",
|
"Convert To Safe Tensors Format": "安全なテンソル形式に変換",
|
||||||
"Please change Strategy to WebGPU to use safetensors format": "StrategyをWebGPUに変更して、安全なテンソル形式を使用してください",
|
"Please change Strategy to WebGPU to use safetensors format": "StrategyをWebGPUに変更して、安全なテンソル形式を使用してください",
|
||||||
"Preview Only": "プレビューのみ"
|
"Preview Only": "プレビューのみ",
|
||||||
|
"RAM": "RAM",
|
||||||
|
"VRAM": "VRAM",
|
||||||
|
"GPU Usage": "GPU使用率"
|
||||||
}
|
}
|
@ -245,5 +245,8 @@
|
|||||||
"Please convert model to safe tensors format first": "请先将模型转换为Safetensors格式",
|
"Please convert model to safe tensors format first": "请先将模型转换为Safetensors格式",
|
||||||
"Convert To Safe Tensors Format": "转换为Safetensors格式",
|
"Convert To Safe Tensors Format": "转换为Safetensors格式",
|
||||||
"Please change Strategy to WebGPU to use safetensors format": "请将Strategy改为WebGPU以使用safetensors格式",
|
"Please change Strategy to WebGPU to use safetensors format": "请将Strategy改为WebGPU以使用safetensors格式",
|
||||||
"Preview Only": "仅预览"
|
"Preview Only": "仅预览",
|
||||||
|
"RAM": "内存",
|
||||||
|
"VRAM": "显存",
|
||||||
|
"GPU Usage": "GPU占用"
|
||||||
}
|
}
|
@ -2,11 +2,12 @@ import commonStore, { Platform } from './stores/commonStore';
|
|||||||
import { GetPlatform, ListDirFiles, ReadJson } from '../wailsjs/go/backend_golang/App';
|
import { GetPlatform, ListDirFiles, ReadJson } from '../wailsjs/go/backend_golang/App';
|
||||||
import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshLocalModels, refreshModels } from './utils';
|
import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshLocalModels, refreshModels } from './utils';
|
||||||
import { getStatus } from './apis';
|
import { getStatus } from './apis';
|
||||||
import { EventsOn } from '../wailsjs/runtime';
|
import { EventsOn, WindowSetTitle } from '../wailsjs/runtime';
|
||||||
import manifest from '../../manifest.json';
|
import manifest from '../../manifest.json';
|
||||||
import { defaultModelConfigs, defaultModelConfigsMac } from './pages/defaultConfigs';
|
import { defaultModelConfigs, defaultModelConfigsMac } from './pages/defaultConfigs';
|
||||||
import { Preset } from './pages/PresetsManager/PresetsButton';
|
import { Preset } from './pages/PresetsManager/PresetsButton';
|
||||||
import { wslHandler } from './pages/Train';
|
import { wslHandler } from './pages/Train';
|
||||||
|
import { t } from 'i18next';
|
||||||
|
|
||||||
export async function startup() {
|
export async function startup() {
|
||||||
downloadProgramFiles();
|
downloadProgramFiles();
|
||||||
@ -23,6 +24,8 @@ export async function startup() {
|
|||||||
|
|
||||||
initPresets();
|
initPresets();
|
||||||
|
|
||||||
|
initHardwareMonitor();
|
||||||
|
|
||||||
await GetPlatform().then(p => commonStore.setPlatform(p as Platform));
|
await GetPlatform().then(p => commonStore.setPlatform(p as Platform));
|
||||||
await initConfig();
|
await initConfig();
|
||||||
|
|
||||||
@ -117,3 +120,20 @@ async function initLocalModelsNotify() {
|
|||||||
refreshLocalModels({ models: commonStore.modelSourceList }, false); //TODO fix bug that only add models
|
refreshLocalModels({ models: commonStore.modelSourceList }, false); //TODO fix bug that only add models
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type monitorData = {
|
||||||
|
usedMemory: number;
|
||||||
|
totalMemory: number;
|
||||||
|
gpuUsage: number;
|
||||||
|
gpuPower: number;
|
||||||
|
usedVram: number;
|
||||||
|
totalVram: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initHardwareMonitor() {
|
||||||
|
EventsOn('monitor', (data: string) => {
|
||||||
|
const results: monitorData = JSON.parse(data);
|
||||||
|
if (results)
|
||||||
|
WindowSetTitle(`RWKV-Runner (${t('RAM')}: ${results.usedMemory.toFixed(1)}/${results.totalMemory.toFixed(1)} GB, ${t('VRAM')}: ${(results.usedVram / 1024).toFixed(1)}/${(results.totalVram / 1024).toFixed(1)} GB, ${t('GPU Usage')}: ${results.gpuUsage}%)`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
6
main.go
6
main.go
@ -61,6 +61,9 @@ var midi embed.FS
|
|||||||
//go:embed assets/sound-font
|
//go:embed assets/sound-font
|
||||||
var midiAssets embed.FS
|
var midiAssets embed.FS
|
||||||
|
|
||||||
|
//go:embed components
|
||||||
|
var components embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if buildInfo, ok := debug.ReadBuildInfo(); !ok || strings.Contains(buildInfo.String(), "-ldflags") {
|
if buildInfo, ok := debug.ReadBuildInfo(); !ok || strings.Contains(buildInfo.String(), "-ldflags") {
|
||||||
backend.CopyEmbed(cyac)
|
backend.CopyEmbed(cyac)
|
||||||
@ -70,8 +73,8 @@ func main() {
|
|||||||
backend.CopyEmbed(finetune)
|
backend.CopyEmbed(finetune)
|
||||||
backend.CopyEmbed(midi)
|
backend.CopyEmbed(midi)
|
||||||
backend.CopyEmbed(midiAssets)
|
backend.CopyEmbed(midiAssets)
|
||||||
|
backend.CopyEmbed(components)
|
||||||
}
|
}
|
||||||
os.Chmod("./backend-rust/webgpu_server", 0777)
|
|
||||||
|
|
||||||
// Create an instance of the app structure
|
// Create an instance of the app structure
|
||||||
app := backend.NewApp()
|
app := backend.NewApp()
|
||||||
@ -104,6 +107,7 @@ func main() {
|
|||||||
Handler: NewFileLoader(),
|
Handler: NewFileLoader(),
|
||||||
},
|
},
|
||||||
OnStartup: app.OnStartup,
|
OnStartup: app.OnStartup,
|
||||||
|
OnBeforeClose: app.OnBeforeClose,
|
||||||
Bind: []any{
|
Bind: []any{
|
||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user