code: def inspect_cuda_version_and_devices(compiler, settings):
      
      try:
          output = build_and_run(compiler, '''
              #include <cuda.h>
              #include <stdio.h>
  
              __device__ void test(int * in, int * out)
              {
                  int tid = blockIdx.x*blockDim.x + threadIdx.x;
                  out[tid] = in[tid];
              }
  
              int main(int argc, char* argv[]) {
  
                printf("{\\n");
                printf("  \\"cuda_version\\": %d,\\n", CUDA_VERSION);
  
                printf("  \\"devices\\": [\\n");
  
                int nr_of_devices = 0;
                cudaGetDeviceCount(&nr_of_devices);
  
                for(int d=0; d < nr_of_devices; ++d)
                {
                  cudaDeviceProp p;
                  cudaGetDeviceProperties(&p, d);
  
                  printf("    {\\n");
  
                  bool last = (d == nr_of_devices-1);
  
                  printf("      \\"name\\": \\"%s\\",\\n", p.name);
                  printf("      \\"major\\": %d,\\n", p.major);
                  printf("      \\"minor\\": %d,\\n", p.minor);
                  printf("      \\"memory\\": %lu\\n", p.totalGlobalMem);
  
                  printf("    }%s\\n", last ? "" : ",");
                }
  
                printf("  ]\\n");
                printf("}\\n");
  
                return 0;
              }
          ''',
          filename='test.cu',
          include_dirs=settings['include_dirs'],
          library_dirs=settings['library_dirs'],
          libraries=settings['libraries'])
  
      except Exception as e:
          msg = ("Running the CUDA device check "
              "stub failed\n{}".format(str(e)))
          raise InspectCudaException(msg), None, sys.exc_info()[2]
  
      return output
docs: Poor mans deviceQuery. Returns CUDA_VERSION information and
      CUDA device information in JSON format