我试图在Ubuntu14.04上安装CUDA-7.5,我在主板上插入了GTX950和Tesla K40。
lspci _ grep -i -i命令提供以下结果:
01:00.0 3D controlloer: NVIDIA Corporation GK110BGL [Tesla K40c] (rev a1)
02:00.0 VGA compatible controller: NVIDIA Corporation GM206 [GeForece GTX 950] (rev a1)
02:00.1 Audio device: NVIDIA Corporation Device 0fba (rev a1)我认为我已经成功地在我的计算机上安装了CUDA-7.5,因为我实际上可以在NVIDIA_CUDA-7.5_Samples/bin/x86_64/linux/release/.中运行NVIDIA_CUDA-7.5_Samples/bin/x86_64/linux/release/.示例。
但我有一个问题:
有什么命令可以告诉我我在使用特斯拉K40吗?
发布于 2016-08-03 07:52:21
在cuda示例中,deviceQuery用于测试是否正确安装了cuda,并显示了有关每张卡的基本信息。这将告诉您每个cuda设备的设备编号。
例如,我在服务器上运行它:
$ ./deviceQuery |egrep '^Device [0-9]+'
Device 0: "GeForce GTX 980 Ti"
Device 1: "GeForce GTX 980 Ti"
Device 2: "GeForce GTX 980 Ti"
Device 3: "GeForce GTX 980 Ti"在您的cuda应用程序中,使用cudaSetDevice()选择要运行的卡。查看示例源代码,了解如何使用它。
发布于 2016-08-03 12:46:23
我想扩展halfelfs的答案。他提出的解决办法肯定是正确的,但我不认为它是一般性的。只要依赖于从命令行返回的硬编码设备号,操作系统就可能一次变成陷阱--不管原因是什么--操作系统更改了先前分配的设备号。
我的建议是:
int getDeviceNumberByName( const char * deviceName )
{
int deviceCount;
cudaGetDeviceCount ( &deviceCount );
for ( int currentDevice = 0 ; currentDevice < deviceCount ; ++currentDevice )
{
cudaDeviceProp deviceProperties;
cudaGetDeviceProperties( &deviceProperties, currentDevice );
if ( 0 == strcmp( deviceProperties.name, deviceName )
return currentDevice;
}
return -1; // not found
}有了这个功能,您就非常灵活了,即使您更改了底层硬件,它也可以工作。
描述:
获取已安装的NVIDIA设备的总数,并读取每个设备的属性。检查设备名称是否与所提供的设备名称匹配,如果它确实返回设备编号,否则返回-1 (如果没有找到)。
https://stackoverflow.com/questions/38736972
复制相似问题