Pinokio
FeedAppsRemoteCreate
Download Pinokio
Sign inCreate accountJoin
Sign inCreate accountJoin

Post

Conversation
@lemonweasel·40m

I know this is an old post, but I ran into something similar and have a few workarounds.

First, make sure you update Maestreo. In the bottom left, where the CPU, RAM, VRAM stats are, there's what looks like a little power button. Click that and then the red button (between generations, not during) to dump the RAM and VRAM. This helps if switching models or making changes that update the weights loaded, swapping LORAs etc. This can help. Note that if you're running like 20 queued image gens with the same prompt, this will slow you down slightly since it will just dump and reload the same basic weights, adding a step. But it can keep things from getting off track if you switch modes a lot.

Sometimes, I'm fiding with specific combinations of LORAs for H3, stuff gets stuck in memory anyway. I haven't been able to consistantly recreate it, so I don't know what specifically causes it. But I did write a brute force script to fix it. I'll paste the code below (it's in Rust, so you'll need to have rust installed and compile it to an exe yourself). But I only post code so there's full transparency, and everyone can see there's nothing fishy in it, lol. Never trust a random exe in a comment response, of course. This dumps idle RAM data and refreshes your video driver to purge VRAM. Only use between generations, not during.

If you don't know RUST, just copy and paste to your LLM of choice and ask it to verify it for you to confirm what it's doing, and it can tell you how to compile it.

Note: You're on a GTX card, so generations will be a bit slow for you. Hang in there, GPU prices are starting to fall, maybe by March we won't need to take out a second mortgage to get one, lol.


use std::mem::size_of;

#[repr(C)]
#[derive(Clone, Copy)]
struct KeyboardInput {
vk: u16,
scan: u16,
flags: u32,
time: u32,
extra_info: usize,
}

#[repr(C)]
#[derive(Clone, Copy)]
struct MouseInput {
dx: i32,
dy: i32,
mouse_data: u32,
flags: u32,
time: u32,
extra_info: usize,
}

#[repr(C)]
#[derive(Clone, Copy)]
union InputData {
keyboard: KeyboardInput,
mouse: MouseInput,
}

#[repr(C)]
#[derive(Clone, Copy)]
struct Input {
kind: u32,
data: InputData,
}

#[repr(C)]
#[derive(Clone, Copy)]
struct Luid {
low: u32,
high: i32,
}

#[repr(C)]
struct LuidAndAttributes {
luid: Luid,
attributes: u32,
}

#[repr(C)]
struct TokenPrivileges {
count: u32,
privilege: LuidAndAttributes,
}

#[link(name = "user32")]
unsafe extern "system" {
fn SendInput(count: u32, inputs: *const Input, size: i32) -> u32;
}

#[link(name = "kernel32")]
unsafe extern "system" {
fn GetCurrentProcess() -> isize;
fn GetLastError() -> u32;
fn SetLastError(error: u32);
fn CloseHandle(handle: isize) -> i32;
}

#[link(name = "advapi32")]
unsafe extern "system" {
fn OpenProcessToken(process: isize, access: u32, token: *mut isize) -> i32;
fn LookupPrivilegeValueW(
system_name: *const u16,
name: *const u16,
luid: *mut Luid,
) -> i32;
fn AdjustTokenPrivileges(
token: isize,
disable_all: i32,
new_state: *const TokenPrivileges,
buffer_length: u32,
previous_state: *mut TokenPrivileges,
return_length: *mut u32,
) -> i32;
}

#[link(name = "ntdll")]
unsafe extern "system" {
fn NtSetSystemInformation(
info_class: i32,
info: *const i32,
info_length: u32,
) -> i32;
}

fn key(vk: u16, key_up: bool) -> Input {
Input {
kind: 1, // INPUT_KEYBOARD
data: InputData {
keyboard: KeyboardInput {
vk,
scan: 0,
flags: if key_up { 0x0002 } else { 0 }, // KEYEVENTF_KEYUP
time: 0,
extra_info: 0,
},
},
}
}

fn send_graphics_shortcut() -> Result<(), String> {
let events = [
key(0x5B, false), // Left Windows
key(0x11, false), // Ctrl
key(0x10, false), // Shift
key(b'B' as u16, false),
key(b'B' as u16, true),
key(0x10, true),
key(0x11, true),
key(0x5B, true),
];

let sent = unsafe {
    SendInput(
        events.len() as u32,
        events.as_ptr(),
        size_of::<Input>() as i32,
    )
};

if sent == events.len() as u32 {
    Ok(())
} else {
    Err(format!("SendInput accepted {sent} of {} events", events.len()))
}

}

fn enable_profile_privilege() -> Result<isize, String> {
const TOKEN_ADJUST_PRIVILEGES: u32 = 0x0020;
const TOKEN_QUERY: u32 = 0x0008;
const SE_PRIVILEGE_ENABLED: u32 = 0x0002;
const ERROR_NOT_ALL_ASSIGNED: u32 = 1300;

let mut token: isize = 0;

unsafe {
    if OpenProcessToken(
        GetCurrentProcess(),
        TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
        &mut token,
    ) == 0
    {
        return Err(format!("OpenProcessToken failed: {}", GetLastError()));
    }

    let name: Vec<u16> = "SeProfileSingleProcessPrivilege"
        .encode_utf16()
        .chain(Some(0))
        .collect();

    let mut luid = Luid { low: 0, high: 0 };
    if LookupPrivilegeValueW(std::ptr::null(), name.as_ptr(), &mut luid) == 0 {
        let error = GetLastError();
        CloseHandle(token);
        return Err(format!("LookupPrivilegeValueW failed: {error}"));
    }

    let privileges = TokenPrivileges {
        count: 1,
        privilege: LuidAndAttributes {
            luid,
            attributes: SE_PRIVILEGE_ENABLED,
        },
    };

    SetLastError(0);
    if AdjustTokenPrivileges(token, 0, &privileges, 0, std::ptr::null_mut(), std::ptr::null_mut()) == 0 {
        let error = GetLastError();
        CloseHandle(token);
        return Err(format!("AdjustTokenPrivileges failed: {error}"));
    }

    let error = GetLastError();
    if error == ERROR_NOT_ALL_ASSIGNED {
        CloseHandle(token);
        return Err(
            "The privilege is not present in this process's token. \
             Administrator elevation alone may not be enough."
                .to_string(),
        );
    }
}

Ok(token)

}

fn purge_standby_list() -> Result<(), String> {
const SYSTEM_MEMORY_LIST_INFORMATION: i32 = 80;
const MEMORY_PURGE_STANDBY_LIST: i32 = 4;

let token = enable_profile_privilege()?;

// NTSTATUS values >= 0 indicate success.
let status = unsafe {
    NtSetSystemInformation(
        SYSTEM_MEMORY_LIST_INFORMATION,
        &MEMORY_PURGE_STANDBY_LIST,
        size_of::<i32>() as u32,
    )
};

unsafe {
    CloseHandle(token);
}

if status >= 0 {
    Ok(())
} else {
    Err(format!(
        "NtSetSystemInformation failed with NTSTATUS 0x{:08X}",
        status as u32
    ))
}

}

fn main() {
match send_graphics_shortcut() {
Ok(()) => println!("Graphics shortcut sent."),
Err(e) => eprintln!("Graphics shortcut failed: {e}"),
}

match purge_standby_list() {
    Ok(()) => println!("Standby list purge requested."),
    Err(e) => eprintln!("Standby list purge failed: {e}"),
}

}

Loading conversation…

Replies

Post context

App used

MaestroBlizaine/MaestroView app

Published by

@lemonweasel40 min ago
Pinokio
PrivacyTerms
FeedAppsCreateRemote

Post context

App used

MaestroBlizaine/MaestroView app

Published by

@lemonweasel40 min ago

Related posts

PotionUI 0.2.0: Kits, API keys, Perfect loop videos and a rebuilt details view@oroborus · 5d agoHow to download Ollama models - Everything you need to know@morpheus · 7d agoGod's Eye View: Error: Cannot find module 'C:\pinokio\api\gods-eye-view.git\scripts\pinokio-install.mjs'@diegssvibe · 1mo ago