Reputation: 11
Please pardon my noob-ness. Our research group recently purchased a server with 2 NVIDIA Tesla units in it and I'm in charged of setting it up.
The server unit is running Rocks 6.0.
So I install the CUDA SDK downloaded from NVIDIA according this this instruction: http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html
I tried compiling the sample codes NVIDIA provided with the SDK and got a bunch of errors. I thought maybe the Makefile is not configured probably, so I looked around on Stack Overflow and found this piece of test code:
using namespace std;
#include <iostream>
#include <string.h>
#include <unistd.h>
int main (int argc, const char *argv[]) {
//our message
const char *message = "hello world!";
size_t size = strlen(message)+1;
//delcare and allocate a buffer on the device
char *d_buffer;
if (cudaMalloc(&d_buffer,size) != cudaSuccess){
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}
//copy our message to the device buffer
if (cudaMemcpy(d_buffer,message,size,cudaMemcpyHostToDevice)
!= cudaSuccess){
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}
//declare and allocate a buffer on the host
char *h_buffer = (char*)malloc(size);
if (h_buffer == 0){
cerr << "malloc failed" << endl;
exit(1);
}
//copy the device buffer back to the host
if (cudaMemcpy(h_buffer,d_buffer,size,cudaMemcpyDeviceToHost)
!= cudaSuccess) {
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}
cout << h_buffer << endl;
cudaFree(d_buffer);
free(h_buffer);
}
So following the instruction, I compiled the code with:
nvcc -o hello_cuda hello_cuda.cu
And got the following errors:
In file included from /usr/local/cuda-5.0/bin/../include/cuda_runtime.h:76,
from <command-line>:0:
/usr/local/cuda-5.0/bin/../include/common_functions.h:76:15: error: new: No such file or directory
In file included from /usr/local/cuda-5.0/bin/../include/common_functions.h:162,
from /usr/local/cuda-5.0/bin/../include/cuda_runtime.h:76,
from <command-line>:0:
/usr/local/cuda-5.0/bin/../include/math_functions.h:7555:17: error: cmath: No such file or directory
/usr/local/cuda-5.0/bin/../include/math_functions.h:7556:19: error: cstdlib: No such file or directory
hello_cuda.cu:11:20: error: iostream: No such file or directory
These are essentially the same kind of error message I got when compiling the sample codes. My guess is the compiler isn't configured properly, as iostream should just be a standard library of C.
Any thought or pointer to as how I can fix this? It seems to be a very simple problem but I've been pulling my hair out at this for days!
Upvotes: 1
Views: 7122
Reputation: 206
It appears that you don't have a properly installed gcc/g++. The samples don't require boost, the error message states that it cannot find the standard libs (new, cmath, cstdlib).
From section 2.8.1 http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#proper-compiler-install
On both Linux and Windows, properly installed compilers have some form of internal knowledge that enables them to locate system include files, system libraries and dlls, include files and libraries related the compiler installation itself, and include files and libraries that implement libc and libc++.
Upvotes: 1