Cuda 5.0链接错误

时间:2013-01-06 23:36:42

标签: cuda nvcc

我的项目在Linux机器上使用CUDA 4.2开发环境编译得很好。

最近它已升级到CUDA 5.0,现在编译失败并显示以下错误消息。

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

我正在使用linux机器

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 $ 

有人可以评论如何使用CUDA 5.0环境解决此问题。

更新-----

感谢非常迅速的评论。

我昨天花了一整天时间追逐这个问题..看了编译器输出后我注意到了以下行....(由 * 分隔)

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

包含在/opt/cuda/bin/crt/link.stub:79:0中的文件:( * ) /tmp/tmpxft_0000345f_00000000-1_GPUReax_dlink.reg.c:2:1:错误:重新定义'const unsigned char def_module_id_str__NV_MODULE_ID []' /tmp/tmpxft_0000345f_00000000-1_GPUReax_dlink.reg.c:1:1:错误:'const unsigned char def_module_id_str__NV_MODULE_ID [19]'此处已定义


错误来自文件link.stub文件,这是CUDA 5.0安装中的新增内容。此文件在CUDA 4.2安装中不存在。

如果这有助于某人指出问题所在。

感谢您的帮助。

Sudhir Kylasa


BTW,这是我的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 个答案:

答案 0 :(得分:1)

当我想为sm_35编译时,我遇到了同样的问题。我通过在NVCCFLAGS变量中替换了以下部分来解决它:

-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

希望它有所帮助。

相关问题