windows - 命令对可执行文件执行右键单击操作并选择一个选项,如 "Run with Graphics Processor"

标签 windows command-prompt nvidia

我想在 Windows 命令提示符中编写一个命令来复制以下内容:

  1. 右键单击可执行文件
  2. 选择“使用图形处理器运行”
  3. 选择“高性能 NVIDIA 处理器”

有办法吗?

最佳答案

根据 NVIDIA 的技术说明,Enabling High Performance Graphics Rendering on Optimus Systems ,您可以通过导出名为 NvOptimusEnablement 的全局变量(其值设置为 1)来确保您的应用程序使用高性能图形模式。

Starting with the Release 302 drivers, application developers can direct the Optimus driver at runtime to use the High Performance Graphics to render any application–even those applications for which there is no existing application profile. They can do this by exporting a global variable named NvOptimusEnablement. The Optimus driver looks for the existence and value of the export. Only the LSB of the DWORD matters at this time. A value of 0x00000001 indicates that rendering should be performed using High Performance Graphics. A value of 0x00000000 indicates that this method should be ignored

Example Usage:

extern "C" {
    _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}

(此示例代码使用 __declspec(export) 指示编译器自动将符号导出为数据,即 assumes Microsoft's compiler ,尽管 GCC 现在支持它作为 MSVC 兼容性的扩展。)

或者,同一文档说您可以静态链接到 NVIDIA 驱动程序 DLL 之一以实现相同的效果:

For any application without an existing application profile, there is a set of libraries which, when statically linked to a given application executable, will direct the Optimus driver to render the application using High Performance Graphics. As of Release 302, the current list of libraries are vcamp110.dll, vcamp110d.dll, nvapi.dll, nvapi64.dll, opencl.dll, nvcuda.dll, and cudart*.*.

请注意,此解决方案将对 NVIDIA 驱动程序实现依赖,而导出变量则不会。

关于windows - 命令对可执行文件执行右键单击操作并选择一个选项,如 "Run with Graphics Processor",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55391738/

相关文章:

Python 程序共存于 Windows

windows - Windows XP下检测是否以管理员权限运行

c++ - CString 成员函数 CompareNoCase 是否支持其他语言(非英语)?

c# - Process.Start(...) 抛出 "The system cannot find the file specified"

gpu - 替代 nvidia-smi 来测量 GPU 利用率?

Ubuntu 没有检测到第二个 nVidia GPU

c# - 从公共(public)服务器上的 PHP 页面向 C# 发送数据/命令

python - Sublime Text 3 subl 命令在 Windows 10 中不起作用

windows - 如何从命令行打开 WinSCP GUI 并登录服务器

matlab - 对于大型阵列,GPU在Matlab中的gpuArray矩阵上崩溃