我想在 Windows 命令提示符中编写一个命令来复制以下内容:
- 右键单击可执行文件
- 选择“使用图形处理器运行”
- 选择“高性能 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 of0x00000001
indicates that rendering should be performed using High Performance Graphics. A value of0x00000000
indicates that this method should be ignoredExample 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
, andcudart*.*
.
请注意,此解决方案将对 NVIDIA 驱动程序实现依赖,而导出变量则不会。
关于windows - 命令对可执行文件执行右键单击操作并选择一个选项,如 "Run with Graphics Processor",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55391738/