我一直在到处寻找解决问题的方法:我无法使用 CUDA 运行 .cpp 文件。我认为这是一个模块错误,因为我收到以下错误:
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
我的生成文件如下所示:
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
当我尝试手动运行文件时,我得到以下输出:
/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
当谈到 linux 时,我是一个完全的菜鸟。任何人都可以对这种情况有所了解。
问候