[SOLVED] nvcc fatal : A single input file is required for a non-link phase when an outputfile is s

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.

I have compiled a minimum non-working example to try to narrow down the problem:


#include <iostream>
void cuda_function(int a, int b);

int main(int argc, char *argv[]) 


#ifndef _MY_KERNEL_
#define _MY_KERNEL_

__global__ void hello_world()
    Printf("Hello, world from the device!\n");

void cuda_function(int a, int b)





cmake_minimum_required(VERSION 2.8.9)



SET(CMAKE_CXX_FLAGS "-std=c++0x -O2")

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")





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

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

Ahhh CMake. Isn’t it fun?

Conveniently, in between these two lines:

[ 28%] Building NVCC (Device) object CMakeFiles/lobovox.dir//./lobovox_generated_LoboVoxDevice.cu.o
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

CMake chooses not to show you the actual nvcc command line that generated the error in the 2nd line above.

You should see if there is some sort of verbose option so you can see exactly what CMake is generating by way of commands to nvcc:


If you can, it should be fairly obvious to figure out. My guess is that this line is not written quite right:

set(CUDA_INCLUDE_DIRS /usr/local/cuda/include/ ${CUDA_INCLUDE_DIRS})

Thank you for the help. I will keep working on a solution. I have updated the original error message with the verbose option.

You would want to scrutinize the nvcc command line carefully. This looks suspicious to me (in particular the leading comma):

-Xcompiler ,"-std=c++0x","-O2","-g"

In general, the compiler driver nvcc will interprete anything that is not a well-formed option as a file name, which may cause it to find that more than one file was specified. I am also wondering about the “//” in the path name.

This is not correct:

-I/usr/local/cuda/include /usr/local/cuda-7.0/include

and it is arising from the line I previously indicated. You might try just deleting this line altogether:

set(CUDA_INCLUDE_DIRS /usr/local/cuda/include/ ${CUDA_INCLUDE_DIRS})

Since it looks to me like CUDA_INCLUDE_DIRS is already correctly set for your CUDA 7.0 install.

Thank you both for your help. After removing these lines I was able to compile.

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")