CUDA Communication Error in Ubuntu 12.04

I searched everywhere for a solution to my problem: I cannot run a .cpp file using CUDA. I think this is a module error, since I get the following error:

g++ -L/usr/local/cuda/lib64 -L~/NVIDIA_GPU_Computing_SDK/shared/lib/linux -L~/NVIDIA_GPU_Computing_SDK/C/common/lib/linux -L~/NVIDIA_GPU_Computing_SDK/C/lib -lcutil -lcudpp -lcuda -lcudart -lcurand -o my_file my_file.o /usr/bin/ld: cannot find -lcutil /usr/bin/ld: cannot find -lcudpp 

My makefile looks like this:

 EXECUTABLE := my_file SDKPATH := ~/NVIDIA_GPU_Computing_SDK CUDAPATH := /usr/local/cuda LDFLAGS := -L$(CUDAPATH)/lib64 -L$(SDKPATH)/shared/lib/linux -L$(SDKPATH)/C/common/lib/linux -L$(SDKPATH)/C/lib -lcutil -lcudpp -lcuda -lcudart -lcurand CXFLAGS := -I$(CUDAPATH)/include -I$(SDKPATH)/shared/inc -I$(SDKPATH)/C/common/inc CXX := g++ NVCC := $(CUDAPATH)/bin/nvcc $(EXECUTABLE): my_file.o $(CXX) $(LDFLAGS) -o $(EXECUTABLE) my_file.o my_file.o: my_file.cu $(NVCC) $(CXFLAGS) -c my_file.cu 

When I try to run the file manually instead, I get the following output:

 /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' my_file.o: In function `__cudaUnregisterBinaryUtil()': tmpxft_00000e8f_00000000-1_my_file.cudafe1.cpp:(.text+0xf): undefined reference to `__cudaUnregisterFatBinary' my_file.o: In function `__sti____cudaRegisterAll_59_tmpxft_00000e8f_00000000_4_my_file_cpp1_ii_71dc03a4()': tmpxft_00000e8f_00000000-1_my_file.cudafe1.cpp:(.text+0x1f): undefined reference to `__cudaRegisterFatBinary' collect2: ld returned 1 exit status 

I'm just a noob when it comes to linux. Someone can shed light on this situation.

Hello

+4
source share
1 answer

You have a problem with the order at the assembly stage of your assembly. Since the libraries you specify are provided before the files that require them, they are discarded. If you change your makefile to something like:

 LDFLAGS := -L$(CUDAPATH)/lib64 -L$(SDKPATH)/shared/lib/linux -L$(SDKPATH)/C/common/lib/linux LIBS := -lcutil -lcudpp -lcuda -lcudart -lcurand .... $(EXECUTABLE): my_file.o $(CXX) $(LDFLAGS) -o $(EXECUTABLE) my_file.o $(LIBS) 

You must find the problem.

+3
source

Source: https://habr.com/ru/post/1446752/


All Articles