1
votes

My project was compiling fine with CUDA 4.2 development environment on Linux machine.

Recently it was upgraded to CUDA 5.0, and now the compilation fails with the following error messages.

In file included from /opt/cuda/bin/crt/link.stub:79:0:
/tmp/tmpxft_000018c8_00000000-1_GPUReax_dlink.reg.c:2:1: error: redefinition of 'const unsigned char def_module_id_str__NV_MODULE_ID []'
/tmp/tmpxft_000018c8_00000000-1_GPUReax_dlink.reg.c:1:1: error: 'const unsigned char def_module_id_str__NV_MODULE_ID [19]' previously defined here
/tmp/tmpxft_000018c8_00000000-1_GPUReax_dlink.reg.c: In function 'void __cudaRegisterLinkedBinary__NV_MODULE_ID(void (*)(void**), void*, void*)':
/tmp/tmpxft_000018c8_00000000-1_GPUReax_dlink.reg.c:2:1: error: redefinition of 'void __cudaRegisterLinkedBinary__NV_MODULE_ID(void (*)(void**), void*, void*)'
/tmp/tmpxft_000018c8_00000000-1_GPUReax_dlink.reg.c:1:1: error: 'void __cudaRegisterLinkedBinary__NV_MODULE_ID(void (*)(void**), void*, void*)' previously defined here

I am using a linux machine

mctesla 93 $ uname -a
Linux mctesla.cs.purdue.edu 3.7.1 #1 SMP Fri Dec 28 12:08:12 EST 2012 x86_64 Intel(R) Xeon(R) CPU E5606 @ 2.13GHz GenuineIntel GNU/Linux
mctesla 94 $ 

Can someone please comment on how to resolve this issue with CUDA 5.0 environment.

Updates-----

Thanks for the very prompt comments.

I spent all day yesterday chasing this problem.. After looking at the compiler output I noticed the following line.... (separated by * below)

nvcc -I. -I/opt/cuda/include -D__USE_GPU__ -arch=sm_20 -Xptxas=-v -L/opt/cuda/lib64 -lm -lz -lcuda -lcudart GMRES.o QEq.o allocate.o analyze.o bond_orders.o box.o forces.o four_body_interactions.o grid.o init_md.o integrate.o list.o lookup.o neighbors.o param.o pdb_tools.o print_utils.o reset_utils.o restart.o single_body_interactions.o system_props.o three_body_interactions.o traj.o two_body_interactions.o vector.o testmd.o cuda_utils.o cuda_copy.o cuda_init.o reduction.o center_mass.o helpers.o validation.o matrix.o matvec.o -o GPUReax

In file included from /opt/cuda/bin/crt/link.stub:79:0:(*) /tmp/tmpxft_0000345f_00000000-1_GPUReax_dlink.reg.c:2:1: error: redefinition of 'const unsigned char def_module_id_str__NV_MODULE_ID []' /tmp/tmpxft_0000345f_00000000-1_GPUReax_dlink.reg.c:1:1: error: 'const unsigned char def_module_id_str__NV_MODULE_ID [19]' previously defined here


Error is coming from the file link.stub file, which is new in the CUDA 5.0 installation. This file was not present in the CUDA 4.2 installation.

If this helps someone pin point the problem.

Thanks for the help.

Sudhir Kylasa


BTW, this is my Makefile

CC    = g++ 
NVCC   = nvcc

LIBS    = -L/opt/cuda/lib64 -lm -lz -lcuda -lcudart

CFLAGS  = -I.  -Wall -O3 -funroll-loops -fstrict-aliasing
NVCCFLAGS  = -I.  -I/opt/cuda/include -D__USE_GPU__ -arch=sm_20 -Xptxas=-v

#-finline-functions  -finline-limit=15 -g#-DTEST -pg -ldl -rdynamic -g
DEFS    = $(CFLAGS)
NVCCDEFS = $(NVCCFLAGS)

FLAG    = $(DEFS) $(INCS) $(LIBS)
NVCCFLAG = $(NVCCDEFS) $(LIBS)

OBJ      = GMRES.o QEq.o allocate.o analyze.o bond_orders.o \
     box.o forces.o four_body_interactions.o \
     grid.o init_md.o integrate.o list.o \
     lookup.o neighbors.o param.o pdb_tools.o \
     print_utils.o reset_utils.o \
     restart.o single_body_interactions.o \
     system_props.o three_body_interactions.o \
     traj.o two_body_interactions.o vector.o \
     testmd.o \
     cuda_utils.o cuda_copy.o cuda_init.o reduction.o \
     center_mass.o helpers.o validation.o matrix.o matvec.o

all:   beta

beta: $(OBJ) Makefile
   $(NVCC) $(NVCCFLAG) $(OBJ) -o GPUReax

param.o: param.c param.h mytypes.h traj.o
   $(CC) $(DEFS) -c param.c

traj.o: traj.c traj.h mytypes.h 
   $(CC) $(DEFS) -c traj.c

restart.o: restart.c restart.h mytypes.h box.h
   $(CC) $(DEFS) -c restart.c

pdb_tools.o: pdb_tools.c pdb_tools.h mytypes.h box.h list.h restart.h param.h
    $(CC) $(DEFS) -c pdb_tools.c

print_utils.o: print_utils.h print_utils.c
    $(CC) $(DEFS) -c print_utils.c

grid.o: grid.h grid.c
   $(CC) $(DEFS) -c grid.c


analyze.o: analyze.h analyze.c
   $(CC) $(DEFS) -c analyze.c

integrate.o: integrate.h integrate.c
   $(CC) $(DEFS) -c integrate.c

vector.o: vector.h vector.cu
   $(NVCC) $(NVCCDEFS) -c vector.cu

system_props.o: system_props.h system_props.cu
   $(NVCC) $(NVCCDEFS) -c system_props.cu

cuda_copy.o: cuda_copy.h cuda_copy.cu
   $(NVCC) $(NVCCDEFS) -c cuda_copy.cu

cuda_utils.o: cuda_utils.h cuda_utils.cu
   $(NVCC) $(NVCCDEFS) -c cuda_utils.cu

cuda_init.o: cuda_init.h cuda_init.cu
   $(NVCC) $(NVCCDEFS) -c cuda_init.cu

reduction.o: reduction.h reduction.cu
   $(NVCC) $(NVCCDEFS) -c reduction.cu

center_mass.o: center_mass.h center_mass.cu
   $(NVCC) $(NVCCDEFS) -c center_mass.cu

box.o: box.h
   $(NVCC) $(NVCCDEFS) -c box.cu

init_md.o: init_md.h init_md.cu
   $(NVCC) $(NVCCDEFS) -c init_md.cu

helpers.o: helpers.h helpers.cu
   $(NVCC) $(NVCCDEFS) -c helpers.cu

GMRES.o: GMRES.h GMRES.cu
   $(NVCC) $(NVCCDEFS) -c GMRES.cu

neighbors.o: neighbors.cu neighbors.h
   $(NVCC) $(NVCCDEFS) -c neighbors.cu

reset_utils.o: reset_utils.h reset_utils.cu mytypes.h list.h vector.h
   $(NVCC) $(NVCCDEFS) -c reset_utils.cu

list.o: list.h
   $(NVCC) $(NVCCDEFS) -c list.cu

forces.o: forces.h forces.cu
   $(NVCC) $(NVCCDEFS) -c forces.cu

allocate.o: allocate.h allocate.cu
   $(NVCC) $(NVCCDEFS) -c allocate.cu

lookup.o: lookup.h lookup.cu
   $(NVCC) $(NVCCDEFS) -c lookup.cu

two_body_interactions.o: two_body_interactions.h two_body_interactions.cu
   $(NVCC) $(NVCCDEFS) -c two_body_interactions.cu

bond_orders.o: bond_orders.h bond_orders.cu
   $(NVCC) $(NVCCDEFS) -c bond_orders.cu

single_body_interactions.o: single_body_interactions.h single_body_interactions.cu
   $(NVCC) $(NVCCDEFS) -c single_body_interactions.cu

three_body_interactions.o: three_body_interactions.h three_body_interactions.cu
   $(NVCC) $(NVCCDEFS) -c three_body_interactions.cu

four_body_interactions.o: four_body_interactions.h four_body_interactions.cu
   $(NVCC) $(NVCCDEFS) -c four_body_interactions.cu

validation.o: validation.h validation.cu
   $(NVCC) $(NVCCDEFS) -c validation.cu

matrix.o: matrix.h matrix.cu
   $(NVCC) $(NVCCDEFS) -c matrix.cu

QEq.o: QEq.h QEq.cu
   $(NVCC) $(NVCCDEFS) -c QEq.cu

matvec.o: matvec.h matvec.cu
   $(NVCC) $(NVCCDEFS) -c matvec.cu

testmd.o: testmd.cu mytypes.h param.o traj.o restart.o pdb_tools.o list.o vector.o
   $(NVCC) $(NVCCDEFS) -c testmd.cu

clean:
   rm -f *.o *~ core 
1
My guess is that remains of CUDA 4.2 are still on your machine (build environment or project), so that you end up mixing libraries or linking to both versions at the same time. - Roger Dahl
perhaps giving your build command (nvcc command line) might help. If it's a project that you can do a make clean or similar, that may help. Are you able to build other CUDA applications, or do they all fail similarly when trying to build? - Robert Crovella
did you do a make clean ? - Robert Crovella
I did make clean, several times. That won't help. When the CUDA 5.0 was installed, all the sample code present in this installation works. Today, we installed the CUDA 5.0 from scratch on this machine to make sure that this was not an installation issue....it must be something with the new CUDA 5.0 software itself. thats my gut feeling - user1953683
Try this. For compiling your .cu files, you are invoking $(NVCC) ... -c file.cu Try changing that to $(NVCC) ... -dc file.cu (for each file) Also change your beta build command to $(NVCC) -rdc=true -link $(NVCCFLAG) $(OBJ) -o GPUReax and see what the results are - Robert Crovella

1 Answers

1
votes

I had the same problem when I wanted to compile for sm_35. I solved it by replacing in the NVCCFLAGS variable the section that says:

-arch=sm_20 by -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35

Hope it helps.