Something wrong is going on,
look at what I did this morning (log of my shell):
$ su -
Password:
lsmod | grep nvidia
nvidia 12319475 0
./devdriver_5.0_linux_64_302.06.03.run
Verifying archive integrity… OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 302.06.03…
logout
$ g++ main_copy_error.cpp -I /usr/local/cuda/include -L /usr/local/cuda/lib64 -lcudart
./a.out
i:0 SRC: 0.840188 DST: 0.285239
Aborted (core dumped)
$ vi main_copy_error_2.cpp << This is the code you posted
$ g++ main_copy_error_2.cpp -I /usr/local/cuda/include -L /usr/local/cuda/lib64 -lcudart
main_copy_error_2.cpp: In function ‘int main()’:
main_copy_error_2.cpp:30: error: ‘printf’ was not declared in this scope
main_copy_error_2.cpp:32: error: ‘printf’ was not declared in this scope
main_copy_error_2.cpp:49: error: ‘printf’ was not declared in this scope
$ vi main_copy_error_2.cpp << I added the #include <stdio.h>
$ g++ main_copy_error_2.cpp -I /usr/local/cuda/include -L /usr/local/cuda/lib64 -lcudart
$ ./a.out
no error
done!
From this moment even mine doesn’t fail anymore:
$ g++ main_copy_error.cpp -I /usr/local/cuda/include -L /usr/local/cuda/lib64 -lcudart -o main_copy_error
$ g++ main_copy_error_2.cpp -I /usr/local/cuda/include -L /usr/local/cuda/lib64 -lcudart -o main_copy_error_2
$ ./main_copy_error
$ ./main_copy_error_2
no error
done!
And this is very strange! I guess there is a race condition somewhere.
I’m still able to make the test failing if in another shell I run the following code:
// interfere code
#include <cuda_runtime_api.h>
int main() {
float* myVectorDevice0;
float* myVectorDevice1;
const size_t myVectorSize = (1<<19);
while(true) {
cudaSetDevice(0);
cudaMalloc((void**)&myVectorDevice0, myVectorSize*sizeof(float));
cudaSetDevice(1);
cudaMalloc((void**)&myVectorDevice1, myVectorSize*sizeof(float));
cudaFree(myVectorDevice0);
cudaFree(myVectorDevice1);
}
}
Executing your test case in a loop I get the random fails:
$ for ((;<img src='http://forums.nvidia.com/public/style_emoticons/<#EMO_DIR#>/wink.gif' class='bbc_emoticon' alt=';)' />) ; do ./main_copy_error_2; done
no error
done!
no error
done!
no error
done!
no error
done!
no error
done!
no error
done!
no error
i:141824 SRC: 0.0912551 DST: 0
Aborted (core dumped)
no error
i:0 SRC: 0.840188 DST: 0.688742
Aborted (core dumped)
no error
done!
no error
done!
no error
done!
no error
i:0 SRC: 0.840188 DST: 0.688742
Aborted (core dumped)
no error
i:262144 SRC: 0.688742 DST: 0.840188
Aborted (core dumped)
no error
done!
no error
done!
no error
done!
no error
done!
no error
i:403968 SRC: 0.510556 DST: 0
Aborted (core dumped)
no error
done!
no error
done!
no error
i:0 SRC: 0.840188 DST: 0.688742
Aborted (core dumped)
no error
i:141824 SRC: 0.0912551 DST: 0
Aborted (core dumped)
no error
i:262144 SRC: 0.688742 DST: 0.840188
Aborted (core dumped)
no error
done!
so as you can see if another process is allocating/freeing memory this simple tests case randomly
fails.
And here the nvidia-smi and the lspci output
$ nvidia-smi
Fri Jun 29 10:32:02 2012
+------------------------------------------------------+
| NVIDIA-SMI 3.302... Driver Version: 302.06.03 |
|-------------------------------+----------------------+----------------------+
| GPU Name | Bus-Id Disp. | Volatile ECC SB / DB |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla C2050 | 0000:02:00.0 Off | Off |
| 30% 78C P0 N/A / N/A | 0% 6MB / 3071MB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla C2050 | 0000:03:00.0 Off | Off |
| 30% 67C P0 N/A / N/A | 0% 6MB / 3071MB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 2 Tesla C2050 | 0000:83:00.0 Off | Off |
| 30% 79C P0 N/A / N/A | 0% 6MB / 3071MB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 3 Tesla C2050 | 0000:84:00.0 Off | Off |
| 30% 77C P0 N/A / N/A | 0% 6MB / 3071MB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Compute processes: GPU Memory |
| GPU PID Process name Usage |
|=============================================================================|
| No running compute processes found |
+-----------------------------------------------------------------------------+
-+-[0000:80]-+-00.0-[0000:81]--
| +-01.0-[0000:82]--
| +-03.0-[0000:83]--+-00.0
| | \-00.1
| +-07.0-[0000:84]--+-00.0
| | \-00.1
| +-13.0
| +-14.0
| +-14.1
| +-14.2
| +-14.3
| +-16.0
| +-16.1
| +-16.2
| +-16.3
| +-16.4
| +-16.5
| +-16.6
| \-16.7
\-[0000:00]-+-00.0
+-01.0-[0000:01]----00.0
+-03.0-[0000:02]--+-00.0
| \-00.1
+-07.0-[0000:03]--+-00.0
| \-00.1
+-13.0
+-14.0
+-16.0
+-16.1
+-16.2
+-16.3
+-16.4
+-16.5
+-16.6
+-16.7
+-1a.0
+-1a.1
+-1a.2
+-1a.7
+-1b.0
+-1c.0-[0000:04]----00.0
+-1c.4-[0000:05]----00.0
+-1c.5-[0000:06]----00.0
+-1d.0
+-1d.1
+-1d.2
+-1d.7
+-1e.0-[0000:07]----01.0
+-1f.0
+-1f.2
\-1f.3