-1

I'm trying to run the following code:

void wrapper(double *h_res, const double *h_em, const double *h_obs)
{
double *dev_res = 0;
double *dev_em = 0;
double *dev_obs = 0;

int dc;
cudaGetDeviceCount(&dc);

cout << "Device count: " << dc << endl;

}

Same goes for:

cudaStatus = cudaSetDevice(0);
    if (cudaStatus != cudaSuccess)
    {
        cerr << "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?" << endl;
        goto Error;
    }

I get Device count: 0 or cudaSetDevice failed! Do you have a CUDA-capable GPU installed?

Now when I try to run the deviceQuery sample provided with 6.5, I get the following:

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GT 740M"
  CUDA Driver Version / Runtime Version          7.0 / 6.5
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 2048 MBytes (2147483648 bytes)
  ( 2) Multiprocessors, (192) CUDA Cores/MP:     384 CUDA Cores
  GPU Clock rate:                                895 MHz (0.89 GHz)
  Memory Clock rate:                             901 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 262144 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 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 1 copy engine(s)
  Run time limit on kernels:                     Yes
  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):      No
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 7.0, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GT 740M
Result = PASS

How do I fix this? I own an ASUS N56VB if this would be any help...

Muli Yulzary
  • 2,559
  • 3
  • 21
  • 39
  • Why downvote? it is not a legitimate question? – Muli Yulzary Apr 18 '15 at 14:31
  • 2
    Actually printing out the specific numerical error (i.e. `cudaStatus`, returned from `cudaSetDevice()`) and decoding it using [proper cuda error checking](http://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api) might be more useful for figuring out what is the problem. Is this windows or linux? If your laptop is an Optimus style laptop, you may need to have your GPU in the proper state to run CUDA codes. You might also have a problem if you have multiple CUDA toolkits installed in different places. – Robert Crovella Apr 18 '15 at 14:41
  • Thank you for you answer. I did use the proper error checking (check out the second code). This is windows based machine. I have 2 GPU's, Onboard and the 740M. Cuda codes compile just fine and as mentioned the samples from cuda samples run just fine aswell. – Muli Yulzary Apr 18 '15 at 14:47
  • 3
    No, the second code is not a complete error checking approach. Why not read the link I provided and study the difference? You should take the error code returned in `cudaStatus` and pass it through a decoder function. You will then get a text description of the exact error which may be useful. The link I provided shows how to do that. – Robert Crovella Apr 18 '15 at 14:54
  • well for some reason after updating my drivers everything seems to work... will update if there's any change. – Muli Yulzary Apr 18 '15 at 15:03

1 Answers1

1

What I did eventually was update my Graphic Driver and it all worked out.

Muli Yulzary
  • 2,559
  • 3
  • 21
  • 39