笔记本电脑关闭屏幕时关闭屏幕渲染?

发布于 2024-07-10 16:07:03 字数 294 浏览 7 评论 0原文

我有一个漫长的数字运算过程,它充分利用了 OpenGL 离屏渲染的优势。 这一切都运行良好,但是当我在做三明治时让它自行工作时,我通常会发现它在我离开时崩溃了。
我能够确定崩溃发生在我使用的笔记本电脑决定关闭屏幕以节省能源的那一刻。 崩溃本身就在 NVIDIA dll 内部,因此无法知道发生了什么。

明显的解决方案是关闭电源管理功能,关闭屏幕和显卡,但我正在寻找更用户友好的东西。 有没有办法以编程方式执行此操作?
我知道有一个 SETI@home 实现利用了 GPU 处理。 它如何防止显卡进入睡眠状态?

I have a lengthy number-crunching process which takes advantage of quite abit of OpenGL off-screen rendering. It all works well but when I leave it to work on its own while I go make a sandwich I would usually find that it crashed while I was away.
I was able to determine that the crash occurs very close to the moment The laptop I'm using decides to turn off the screen to conserve energy. The crash itself is well inside the NVIDIA dlls so there is no hope to know what's going on.

The obvious solution is to turn off the power management feature that turns the screen and video card off but I'm looking for something more user friendly.
Is there a way to do this programatically?
I know there's a SETI@home implementation which takes advantage of GPU processing. How does it keep the video card from going to sleep?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

西瓜 2024-07-17 16:07:03

I'm not sure what OS you're on, but windows sends a message that it is about to enter a new power state. You can listen for that and then either start processing on the CPU or deny the request to enter a lower-power state.

趁年轻赶紧闹 2024-07-17 16:07:03

为了让遇到类似问题的 Linux 用户受益,我想补充一点,您可以使用 DBUS API。 Python 中的示例脚本(取自链接)用于抑制电源状态更改:

#!/usr/bin/python
import dbus
import time
bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
devobj = bus.get_object('org.freedesktop.PowerManagement', 
                        '/org/freedesktop/PowerManagement')
dev = dbus.Interface (devobj, "org.freedesktop.PowerManagement.Inhibit")
cookie = dev.Inhibit('Nautilus', 'Copying files from /media/SANVOL')
time.sleep(10)
dev.UnInhibit(cookie)

For the benefit of Linux users encountering a similar issue, I thought I'd add that, you can obtain similar notifications and inhibit power state changes using the DBUS API. An example script in Python, taken from the link, to inhibit power state change:

#!/usr/bin/python
import dbus
import time
bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
devobj = bus.get_object('org.freedesktop.PowerManagement', 
                        '/org/freedesktop/PowerManagement')
dev = dbus.Interface (devobj, "org.freedesktop.PowerManagement.Inhibit")
cookie = dev.Inhibit('Nautilus', 'Copying files from /media/SANVOL')
time.sleep(10)
dev.UnInhibit(cookie)
怼怹恏 2024-07-17 16:07:03

根据 MSDN 的说法,有一个 API 允许应用程序告诉 Windows 它仍在工作,并且 Windows 不应进入睡眠状态或关闭显示器。

该函数称为 SetThreadExecutionState ( MSDN)。 它对我有用,使用标志 ES_SYSTEM_REQUIREDES_CONTINUOUS

但请注意,使用此函数不会阻止屏幕保护程序运行,如果屏幕保护程序也使用 OpenGL(或 Direct3D),则可能会干扰您的 OpenGL 应用程序。

According to MSDN, there is an API that allows an application to tell Windows that it is still working and that Windows should not go to sleep or turn off the display.

The function is called SetThreadExecutionState (MSDN). It works for me, using the flags ES_SYSTEM_REQUIRED and ES_CONTINUOUS.

Note, however, that using this function does not stop the screen saver from running, which might interfere with your OpenGL app if the screen saver also uses OpenGL (oder Direct3D).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文