[mvapich-discuss] Error compiling with CUDA code with

Mohamad Amirul Abdullah amirul.abdullah at mimos.my
Wed Jan 1 20:53:00 EST 2014


Hi,

Im having problem to compile CUDA code with mpicc that was installed together with MVAPICH2.20b. It seems that some of the the compiler unable to read some symbol in libcudart. Im able to compile with nvcc seperately without error (without MPI code inside). I have try few method to compile this but it still prompt out same error. How to debug this problem? The sample code and sample makefile is show below.

Error
mpicc -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcudart  mpiTest.c
/usr/bin/ld: /tmp/ccsxy5CZ.o: undefined reference to symbol 'cudaMalloc'
/usr/bin/ld: note: 'cudaMalloc' is defined in DSO /usr/local/cuda/lib64/libcudart.so so try adding it to the linker command line
/usr/local/cuda/lib64/libcudart.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [mpi] Error 1

Makefile
MPI=mpicc
NVCCINCLUDE=-I/usr/local/cuda/include
NVCCLIB=-L/usr/local/cuda/lib64 -lcudart

all: mpi

<https://owa.mimos.my/owa/?ae=Item&a=New&t=IPM.Note&cc=MTQuMS40MzguMCxlbi1VUyw1LEhUTUwsMCww&pspid=_1388624998532_18076859#>
mpi:
    $(MPI) $(NVCCINCLUDE) $(NVCCLIB) mpiTest.c
clean:
    rm -rf *o hello


MVAPICH setting
root at gpu0: mpiname -a
MVAPICH2 2.0b Fri Nov  8 11:17:40 EST 2013 ch3:mrail

Compilation
CC: gcc    -g
CXX: g++   -g
F77: no -L/lib -L/lib   -g
FC: no   -g

Configuration
--disable-fast --enable-g=dbg --enable-cuda --with-cuda-include=/usr/local/cuda/include --with-cuda-libpath=/usr/local/cuda/lib64 --disable-fc --disable-f77

Code
#include <mpi.h>
#include <cuda_runtime_api.h>

int main(int argc, char **argv){
  int myrank;
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  printf("check rank :%i\n",myrank);
  int *d_temp;

  cudaMalloc((void**)&d_temp,sizeof(int)*10);

 if (myrank == 0) {
   printf("1\n");
  } else {
   printf("1\n");
  }
  cudaFree (d_temp);
  MPI_Finalize();
  return 0;
}

Regards,
-Amirul-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cse.ohio-state.edu/pipermail/mvapich-discuss/attachments/20140102/07373e16/attachment.html>


More information about the mvapich-discuss mailing list