Nvidia称Optimus是一个革命性的技术,它可以延长笔记本电脑续航时间,同时获得很好的性能。这种技术使得硬件能够自己选择使用那个显卡来计算。一般使用GPU计算的应用、视频、3D游戏等会被安排在高性能的NVIDIA GPU上执行,一些像Office、Web冲浪,电子邮件类似的应用会被安排在集成显卡上执行。
如果你的笔记本有两块显卡,一块是Intel的集成显卡(IGP),一块是Nvidia的独立GPU,你的笔记本一般采用了Optimus技术。在使用CUDA的时候,务必要理解Optimus,才能很好的使用你的笔记本来开发CUDA程序。
1、在运行自己的CUDA程序时,小心自己的程序找不到CUDA设备!(因为实现默认的是IGP奥)
2、在使用Direct3D与CUDA、OpenGL与CUDA互操作时,开发人员要注意一些限制!
针对以上限制,注意说明:
1、查询CUDA设备:
// CUDA Runtime API Version
inline int cutGetMaxGflopsDeviceId()
{
int current_device = 0, sm_per_multiproc = 0;
int max_compute_perf = 0, max_perf_device = 0;
int device_count = 0, best_SM_arch = 0;
int arch_cores_sm[3] = { 1, 8, 32 };
cudaDeviceProp deviceProp;
cudaGetDeviceCount( &device_count );
// Find the best major SM Architecture GPU device
while ( current_device < device_count ) {
cudaGetDeviceProperties( &deviceProp, current_device );
if (deviceProp.major > 0 && deviceProp.major < 9999) {
best_SM_arch = max(best_SM_arch, deviceProp.major);
}
current_device++;
}
// Find the best CUDA capable GPU device
current_device = 0;
while( current_device < device_count ) {
cudaGetDeviceProperties( &deviceProp, current_device );
if (deviceProp.major == 9999 && deviceProp.minor == 9999) {
sm_per_multiproc = 1;
} else if (deviceProp.major <= 2) {
sm_per_multiproc = arch_cores_sm[deviceProp.major];
} else { // Device has SM major > 2
sm_per_multiproc = arch_cores_sm[2];
}
int compute_perf = deviceProp.multiProcessorCount *
sm_per_multiproc * deviceProp.clockRate;
if( compute_perf > max_compute_perf ) {
// If we find GPU of SM major > 2, search only these
if ( best_SM_arch > 2 ) {
// If device==best_SM_arch, choose this, or else pass
if (deviceProp.major == best_SM_arch) {
max_compute_perf = compute_perf;
max_perf_device = current_device;
}
} else {
max_compute_perf = compute_perf;
max_perf_device = current_device;
}
}
++current_device;
}
cudaGetDeviceProperties(&deviceProp, max_compute_perf_device);
printf("\nDevice %d: \"%s\"\n", max__perf_device,
deviceProp.name);
printf("Compute Capability : %d.%d\n",
deviceProp.major, deviceProp.minor);
return max_perf_device;
}
声明下哈,这个代码并不是我写的,在参考文献里粘贴的奥。这是官方给出的代码。大家可以参考着写出适合自己的代码,要是你想直接考走就用,建议你还是别看了,直接请别人给你做得了!!
2、Direct3D与CUDA、OpenGL与CUDA互操作:
代码以蔽之!
// CUDA/Direct3D9 interop
// You will need to create the D3D9 context first
IDirect3DDevice9 * g_pD3D9Device; // Initialize D3D9 rendering device
// After creation, bind your D3D9 context to CUDA
cudaD3D9SetDirect3DDevice(g_pD3D9Device);
// CUDA/Direct3D9 interop
// You will need to create the D3D9 context first
IDirect3DDevice9 * g_pD3D9Device; // Initialize D3D9 rendering device
// After creation, bind your D3D9 context to CUDA
cudaD3D9SetDirect3DDevice(g_pD3D9Device);
// CUDA/Direct3D11 interop
// You will need to first create the D3D11 context first
ID3D11Device * g_pD3D11Device; // Initialize D3D11 rendering device
// After creation, bind your D3D11 context to CUDA
cudaD3D11SetDirect3DDevice(g_pD3D11Device);
// For CUDA/OpenGL interop
// You will need to create the OpenGL Context first
// After creation, bind your D3D11 context to CUDA
cudaGLSetGLDevice(deviceID);
会写上面这些代码,并且可以熟练使用这些互操作接口后,你不一定能得到正确的结果奥,或者你的程序根本就不能运行!呵呵,这是为什么那。很可能的原因是你在使用cuda提供的互操作接口之前,DX、OpenGL的图形上下文可能已经被用在了IGP上了,所以会导致失败。解决方法:
1.使用支持Optimus功能的笔记本用户可以在Nvidia Control panel的3DSettings->Manage3DSettings中将需要运行的程序加入到列表中,并将它们的preferred processor设置为High-performance Nvidia processor。
2.程序编写者应该按照最新的方法修改代码。方法是首先创建一个不与设备绑定的OpenGL/D3D上下文;然后枚举所有CUDA设备并创建CUDA上下文;再把CUDA上下文所在设备与OpenGL/D3D上下文绑定;最后再将CUDA上下文与OpenGL/D3D上下文绑定。
参考:
【1】:NVIDIA CUDA Developer Guide for NVIDIA Optimus Platforms
【2】:http://hpcbbs.it168.com/forum.php?mod=viewthread&tid=5958&fromuid=26008496
分享到:
相关推荐
NVIDIA Optimus双显卡怎么切换.docx
NVIDIA Optimus双显卡切换方法.docx
双显卡怎么切换,使用NVIDIA OPTIMUS进行双显卡切换.docx
nvidia optimus tools,此为64位系统用于测试及查看双显卡自动切换情况,是否正常工作!网上找了好久才找到!拿出来共享!看看你的小本双显卡自动切换工作了吗!
伴侣擎天柱NVIDIA Optimus GPU切换器 用 :heart_with_ribbon: 为了安装的Ubuntu sudo apt install mate-optimus费朵拉sudo dnf install mate-optimus配置除非您具有兼容的系统并且安装了适当的驱动程序,否则MATE ...
如何编译Linux服务器和Linux客户端 Linux 服务器和客户端默认使用项目Makefile构建: $ cd 5_Simulations/fluidsGL/ $ make 如何编译Android客户端 Android客户端编译需要Android SDK和NDK。 使用提供的Makefile ...
这是在bash中NVIDIA optimus笔记本电脑上切换图形的方法,它通过使用NVIDIA optimus解决方案直接在该设备上显示X服务器,但是问题在于缺乏轻松选择INTEL集成图形的能力。 这组bash脚本通过隐含一组在登录时运行的...
采用optimus技术新版NVIDIA显卡驱动如何鉴别独立显卡是否启用?.docx
用户可以通过如下方法对于NVIDIA Optimus进行手动切换设置
Optimus双显卡切换技术非常智能化,可根据机器运行状态自动切换双显卡,也可手动实现
适用于NVIDIA Optimus的GPU加速的Python 3内核 这个小技巧可让您轻松地通过NVIDIA的Optimus硬件切换到GPU加速的硬件。 在配备了两种不同GPU的笔记本电脑中可以找到这种装备:集成的Intel GPU和专用的功能更强大的...
智能显卡切换!NVDIA-optimus技术解析.pdf
智能显卡切换!NVDIA-optimus技术解析.doc
前端开源库-optimus擎天柱,集群管理器
Laravel开发-laravel-optimus 拉拉维尔的擎天柱桥。基于Knuth的乘法散列方法的ID模糊。
OPTIMUS入门手册,软件公司编写的教程,非常实用,入门必备教材。
一个帮助工具,使Optimus Player能够使用 AirPlay 2 流式传输音频。 AirPlay 2 是 Apple 设备使用的专有 AirPlay 流媒体协议的第二个版本。AirPlay 2 专注于音频,具有增强的缓冲、立体声对和多房间音频。 AirPlay...
Linux上不正确支持使用Nvidia卡进行GPU卸载和电源管理( ),这可能会使您难以充分发挥Optimus笔记本电脑的性能。 optimus-manager通过允许您在Nvidia GPU上运行整个桌面会话来解决此问题,而Intel / AMD GPU仅充当N
擎天柱Optimus 是一个 Python Web 框架项目构造器。 现在 optimus 支持创建Tornado项目结构。安装Optimus 在上可用。 安装它使用pip : $ pip install py-optimus在你的 python 环境中运行以下命令: git clone git@...
资源分类:Python库 所属语言:Python 资源全名:optimus-sdk-0.0.11.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059