GPU 设备编号不匹配

GPU device number doesn't match

我正在为 Caffe 使用 GPU。当我执行 nvidia-smi 时,它显示

| NVIDIA-SMI 352.63     Driver Version: 352.63         |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 750 Ti  Off  | 0000:01:00.0      On |                  N/A |
| 44%   52C    P0     2W /  38W |    464MiB /  2047MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Quadro M4000        Off  | 0000:02:00.0     Off |                  N/A |
| 59%   74C    P0    66W / 120W |   7434MiB /  8191MiB |     95%      Default |


+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0      1428    G   /usr/lib/xorg/Xorg                             316MiB |
|    0      2200    G   compiz                                         139MiB |
|    1     29863    C   ./caffe-segnet/build/tools/caffe              7413MiB |
+-----------------------------------------------------------------------------+

但是当我运行caffe并选择GPU 1时,它会告诉我内存不足。如果我选择 GPU 0 build/tools/caffe train -gpu 0 -solver solver.prototxt,它可以 运行。

这是为什么?

Nvidia CUDA 使用自己的设备编号,基于哪个设备被认为是最快的。但是,也有可能通过其 PCI 总线 ID 获取设备。

cudaError_t cudaDeviceGetByPCIBusId ( int* device, char* pciBusId )

反之亦然,您可以获得特定设备的总线 ID。

cudaError_t cudaDeviceGetPCIBusId ( char* pciBusId, int  len, int  device )

总线 ID 将是您 table 中的值 0000:01:00.00000:02:00.0。它们的格式为 [domain]:[bus]:[device].[function].

参见 [1] and [2]