Hello all:
I have been attempting unsuccessfully to compile my CUDA kernel file with my existing c++ application. I’ve been stuck for a while and have been searching for topics with the same error code but have yet to find a solution.
From what I have read this error can be seen when a path file contains spaces or if you are using the wrong dashes with compiler options and I can’t see how either case applies to me. Thanks for looking.
*Update
I have compiled a minimum non-working example to try to narrow down the problem:
main.cpp
#include <iostream>
void cuda_function(int a, int b);
int main(int argc, char *argv[])
{
cuda_function(2,2);
}
MyKernel.cu
#ifndef _MY_KERNEL_
#define _MY_KERNEL_
__global__ void hello_world()
{
//statements
Printf("Hello, world from the device!\n");
}
void cuda_function(int a, int b)
{
//cuda_function
hello_world<<<a,b>>>();
}
#endif
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.9)
SET(PROJECTNAME mwv)
PROJECT(${PROJECTNAME})
SET(PROJECT_SRCS
main.cpp
MyKernel.cu
)
SET(CMAKE_CXX_FLAGS "-std=c++0x -O2")
FIND_PACKAGE(CUDA REQUIRED)
SET(CUDA_INCLUDE_DIRS "/usr/local/cuda/include" ${CUDA_INCLUDE_DIRS})
SET(CUDA_LIBRARIES ${CUDA_LIBRARIES} "/usr/local/cuda/lib64/libcudart.so" "/usr/lib64/libcuda.so" "/usr/local/cuda/lib64/libcublas.so")
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
SET(LIBRARIES ${CUDA_LIBRARIES})
CUDA_ADD_EXECUTABLE(${PROJECTNAME} ${PROJECT_SRCS})
TARGET_LINK_LIBRARIES(${PROJECTNAME} ${LIBRARIES})
ERROR:
santos@cs-cg-dev:~/research/FEM/MWV/build$ make VERBOSE=1
/usr/bin/cmake -H/home/santos/research/FEM/MWV -B/home/santos/research/FEM/MWV/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/santos/research/FEM/MWV/build/CMakeFiles /home/santos/research/FEM/MWV/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/santos/research/FEM/MWV/build'
make -f CMakeFiles/mwv.dir/build.make CMakeFiles/mwv.dir/depend
make[2]: Entering directory `/home/santos/research/FEM/MWV/build'
/usr/bin/cmake -E cmake_progress_report /home/santos/research/FEM/MWV/build/CMakeFiles 1
[ 50%] Building NVCC (Device) object CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o
cd /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir && /usr/bin/cmake -E make_directory /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//.
cd /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir && /usr/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o -D generated_cubin_file:STRING=/home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o.cubin.txt -P /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//mwv_generated_MyKernel.cu.o.cmake
-- Removing /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o
/usr/bin/cmake -E remove /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o
-- Generating dependency file: /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//mwv_generated_MyKernel.cu.o.NVCC-depend
/usr/local/cuda-7.0/bin/nvcc -M -D__CUDACC__ /home/santos/research/FEM/MWV/MyKernel.cu -o /home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//mwv_generated_MyKernel.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -Xcompiler ,\"-std=c++0x\",\"-O2\",\"-g\" -DNVCC -I/usr/local/cuda/include /usr/local/cuda-7.0/include -I/usr/local/cuda/include -I/usr/local/cuda-7.0/include
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
CMake Error at mwv_generated_MyKernel.cu.o.cmake:206 (message):
Error generating
/home/santos/research/FEM/MWV/build/CMakeFiles/mwv.dir//./mwv_generated_MyKernel.cu.o
make[2]: *** [CMakeFiles/mwv.dir/./mwv_generated_MyKernel.cu.o] Error 1
make[2]: Leaving directory `/home/santos/research/FEM/MWV/build'
make[1]: *** [CMakeFiles/mwv.dir/all] Error 2
make[1]: Leaving directory `/home/santos/research/FEM/MWV/build'
make: *** [all] Error 2
santos@cs-cg-dev:~/research/FEM/MWV/build$