Linking errors after upgrading to CUDA 5.0

My project was working fine in CUDA 4.2 environment. After upgrading to CUDA 5.0, my project no longer compiles. I get the following linker errors (mentioned below).

My machine information is as follows

mctesla 63 $ 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

Can somebody please help with these error messages.

Appreciate your help.

/tmp/tmpxft_000008e9_00000000-1_GPUReax_dlink.reg.c:2:1: error: redefinition of ‘const unsigned char def_module_id_str__NV_MODULE_ID
/tmp/tmpxft_000008e9_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_000008e9_00000000-1_GPUReax_dlink.reg.c: In function ‘void __cudaRegisterLinkedBinary__NV_MODULE_ID(void ()(void**), void, void*)’:
/tmp/tmpxft_000008e9_00000000-1_GPUReax_dlink.reg.c:2:1: error: redefinition of ‘void __cudaRegisterLinkedBinary__NV_MODULE_ID(void ()(void**), void, void*)’
/tmp/tmpxft_000008e9_00000000-1_GPUReax_dlink.reg.c:1:1: error: ‘void __cudaRegisterLinkedBinary__NV_MODULE_ID(void ()(void**), void, void*)’ previously defined here

Hello,

If the program does not compile any more after going to a newer version , maybe a good place to start is at the release notes. Release Notes :: CUDA Toolkit Documentation Several features were removed and is better to check the notes to see what’s changed from the previous version.

The error messages don’t seem to be pointing in the direction of changes to the API. The compiler clearly compains about the same object being defined twice, in incompatible ways. In the first case, the first instance of an array is unsized, but the second instance is sized to 19 elements. The duplicate definitions seems to occur on line 1 and 2 of the same file, which is a compiler-generated intermediate file. I wonder whether this could be caused by left-over files produced by an older toolchain, either CUDA 4.2 or a CUDA 5.0 release candidate.

First make sure that the final released version of CUDA 5.0 is installed correctly (any permission problems?). I am not sure where the multiply defined objects could be coming from, but check in particular that all CUDA header files are up to date. I recall a number of bug reports against the compiler caused by running the CUDA 5.0 compiler with some pre-5.0 header files. Not sure how that happened, maybe older CUDA header files had been copied to non-standard locations. In all cases the compiler problems disappeared after the old header files were removed and the correct CUDA 5.0 header files were installed.

After checking the CUDA installation, I would suggest doing a fresh build of the entire application from scratch. Depending on your build system, cleanup of the entire build tree may be via “make clobber” or a similar make target. The important thing in this step would be to purge any and all files produced by previous versions of the CUDA toolchain.

If after careful checking of the installation and careful cleaning of the build tree the problem persists, it would be reasonable to assume that this could be a problem with the way the compiler generates intermediate files. In that case, please prepare a self-contained repro app, and file a bug via the registered developer website.

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

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

Could SDK samples be compiled or just your project?

Compilation problems are with only my project.

The SDK samples compile file, no compilation errors with SDK samples.

Just recreate your project from empty template.

My code is a bunch of c code files. I use Make file to compile and build the executable. I do not use any development environment or IDE for my code.

I ran this by one of our compiler folks who thinks this may be related to a known issue in CUDA 5.0. He suggested the following:

As a workaround, […] try to device-link (via -dlink) only the files that have relocatable device code (this should only happen when [there are] multiple files with executable device code).

If that does not help, please file a bug report, attaching self-contained repro code, so the compiler team can have a look. The problem could be due to a previously unknown issue. The only way to know for sure is to examine code that fails in reproducible manner. Thanks.

I’ve run into a similar issue when trying to compile a .cpp file that contains #include <cuda_runtime.h> with c++/g++ and then linking to .cu files compiled with nvcc. The fix is to remove include and compile .cpp file using nvcc (requires rename to .cu). (Separable compilation was in use at the time.)