Cannot debug both gpus under nsight

Hi,

I have an issue under Nsight 5.2 using CUDA 8.0 under Visual Studio 2015. Hardware is:

  • GPU 1: Titan X Pascal (headless)
  • GPU 2: GTX 1080 (display)

This is running under Alienware 17 laptop using external Amplifier to host the Titan X.

They seem to be functioning ok as you can see below in the output of deviceQuery.exe:

Detected 2 CUDA Capable device(s)

Device 0: "TITAN X (Pascal)"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    6.1
  Total amount of global memory:                 12288 MBytes (12884901888 bytes)
  (28) Multiprocessors, (128) CUDA Cores/MP:     3584 CUDA Cores
  GPU Max Clock rate:                            1531 MHz (1.53 GHz)
  Memory Clock rate:                             5005 Mhz
  Memory Bus Width:                              384-bit
  L2 Cache Size:                                 3145728 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 2 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

Device 1: "GeForce GTX 1080"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    6.1
  Total amount of global memory:                 8192 MBytes (8589934592 bytes)
  (20) Multiprocessors, (128) CUDA Cores/MP:     2560 CUDA Cores
  GPU Max Clock rate:                            1734 MHz (1.73 GHz)
  Memory Clock rate:                             5005 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 2, Device0 = TITAN X (Pascal), Device1 = GeForce GTX 1080
Result = PASS

Also I can run the CUDA sample MonteCarloMultGPU with successful results:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\bin\win64\Release>MonteCarloMultiGPU.exe
MonteCarloMultiGPU.exe Starting...

Using single CPU thread for multiple GPUs
MonteCarloMultiGPU
==================
Parallelization method  = streamed
Problem scaling         = weak
Number of GPUs          = 2
Total number of options = 16384
Number of paths         = 262144
main(): generating input data...
main(): starting 2 host threads...
main(): GPU statistics, streamed
GPU Device #0: TITAN X (Pascal)
Options         : 8192
Simulation paths: 262144
GPU Device #1: GeForce GTX 1080
Options         : 8192
Simulation paths: 262144

Total time (ms.): 29.850859
        Note: This is elapsed time for all to compute.
Options per sec.: 548861.932953
main(): comparing Monte Carlo and Black-Scholes results...
Shutting down...
Test Summary...
L1 norm        : 4.817114E-004
Average reserve: 11.345570

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

Test passed

The problem is that I can only debug GPU device function on Device 1 (GTX 1080) (set via cudaSetDevice(1)). If I put a breakpoint and use device 0 it will not break. Also if I put a printf in the device function, then Device 1 will output the result to the console, but device 0 will not. The test code that will debug device 1 but not device 0 is below.

#include <stdio.h>
#include <math.h>
#include <cuda_runtime.h>
#include <curand_kernel.h>
#include <curand.h>
#include "device_launch_parameters.h"

class MyClass
{
public:
	int n;
	__device__ MyClass(int n)
	{
		this->n = n;
	}
};

__global__ void Test()
{
	int n = 1;
	MyClass* pClass = new MyClass(n);
	printf("n is %i", pClass->n);
}


void main()
{
	cudaSetDevice(0);

	Test << < 1, 1 >> > ();
}

Any ideas?

What happens if you run the code with cuda-memcheck ?

You should put the Titan X into TCC mode via NVSMI, which may make a difference with nsight.
I have been able to profile 2 GPUs in a Windows system via NVVP profile from the command terminal, so that also may be a possible solution.