本文介绍了“ nvidia-smi -L”和cuDeviceGetName()之间的ID不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在外壳中运行此命令并获取:

I'm running this command into a shell and get:

C:\Users\me>nvidia-smi -L
GPU 0: Quadro K2000 (UUID: GPU-b1ac50d1-019c-58e1-3598-4877fddd3f17)
GPU 1: Quadro 2000 (UUID: GPU-1f22a253-c329-dfb7-0db4-e005efb6a4c7)

但是在我的代码中,当我运行 cuDeviceGetName(..,ID)其中, ID 是nvidia-smi输出给出的ID,设备已反转:GPU 0变为Quadro 2000,GPU 1变为Quadro K2000。

But in my code, when I run cuDeviceGetName(.., ID) where ID is the ID given by the nvidia-smi output, the devices have been inverted: GPU 0 becomes Quadro 2000 and GPU 1 becomes Quadro K2000.

这是预期的行为还是错误?有谁知道使nvidia-smi获得GPU的真实 ID的解决方法?我可以使用UUID和 nvmlDeviceGetUUID()来获取正确的设备,但是使用nvml API似乎对于我要实现的目标来说太复杂了。

Is this an expected behavior or a bug ? Does anyone know a workaround to make nvidia-smi get the 'real' ID of GPUs ? I could use the UUID to get the proper device with nvmlDeviceGetUUID() but using nvml API seems a bit too complicated for what I'm trying to achieve.

问题进行了讨论

我正在使用CUDA 6.5。

I am using CUDA 6.5.

编辑:我是我看过nvidia-smi的联机帮助页(应该早些做的...)。它指出:

I've had a look at nvidia-smi manpage (should have done that earlier...). It states:

仍在寻找弹奏……

推荐答案

这是预期的行为。

nvidia-smi 枚举PCI顺序。

默认情况下,CUDA驱动程序和运行时API不会。

By default, the CUDA driver and runtime APIs do not.

您链接的问题清楚地表明了如何将两者关联

The question you linked clearly shows how to associate the two numbering/ordering schemes.

无法使nvidia-smi修改其排序方案以匹配CUDA运行时或驱动程序API生成的内容。但是,您可以使用。

There is no way to cause nvidia-smi to modify its ordering scheme to match whatever will be generated by the CUDA runtime or driver APIs. However you can modify the CUDA runtime enumeration order through the use of an environment variable in CUDA 8.

这篇关于“ nvidia-smi -L”和cuDeviceGetName()之间的ID不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:04