0

I'm following the Even Easier Introduction to CUDA tutorial. I have literally copied and pasted the complete code. add.cu compiles, however, when I run it, it doesn't print anything. I put in some more print statements and narrowed it down:

printf("Hi\n");
for (int i = 0; i < N; i++) {
    x[i] = 1.0f;
    y[i] = 2.0f;
}
printf("Bye");

It prints "Hi", but never prints "Bye". So something seems to be wrong with the memory initialization. What is going wrong here?

Lin Du
  • 88,126
  • 95
  • 281
  • 483
Poseidon23
  • 23
  • 4
  • add [proper CUDA error checking](https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api) to the code and/or run it with `cuda-memcheck` – Robert Crovella Dec 08 '19 at 05:23
  • `cuda-memcheck` is giving me 'Error: process didn't terminate sucessfully. Cuda error checking gives me an unknown error on `add.cu 30` which is the line I first allocate memory. – Poseidon23 Dec 08 '19 at 05:28
  • 1
    Either unified memory isn't supported in your setup, or you have a broken CUDA install. – Robert Crovella Dec 08 '19 at 05:31
  • Apparently unified memory isn't supported. I set it up using `cudaMemcpy` and it worked. One slight problem: how does one access device memory? – Poseidon23 Dec 08 '19 at 05:39
  • Unified memory isn't supported on fermi and older GPUs, and it is also not supported on 32-bit OS's. In other situations it should work. – Robert Crovella Dec 08 '19 at 05:43
  • I'm running a 1060 TI and 64-bit – Poseidon23 Dec 08 '19 at 05:45
  • What OS are you running on, exactly? Which CUDA version and which driver version? – Robert Crovella Dec 08 '19 at 05:49
  • Windows 10, 64-bit, x64, CUDA 10.2 (according to `nvcc --version`). I'm compiling and running from Visual Studio Build Tools set up with `vcvarsall.bat x64` from `cmd.exe` – Poseidon23 Dec 08 '19 at 05:54

1 Answers1

1

I solved the problem myself. Basically, my device drivers were screwed up. To check if you have the same problem, run Command Prompt as administrator and run nvidia-smi. If you have the same problem, it will give you an error saying it failed to communicate because your device drivers are not up to date or wrong or something of the sort.

Download the latest nvidia driver for your computer (I found mine on Dell Drivers & Downlods) and install it. Now, when you run nvidia-smi as admin on command prompt, it should give you a whole bunch of details about your setup (driver version, Cuda version, etc) like this:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 441.14       Driver Version: 441.14       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105... WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   30C    P8    N/A /  N/A |     78MiB /  4096MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

You should now be able to compile and run Cuda scripts with unified memory.

Poseidon23
  • 23
  • 4