Hello there,
I have two files:
file.cu:
//file.cu
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
....
file.cuh:
//file.cuh
#pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <vector>
....
the normal .cu file works fine, but in the header file file.cuh I get:
Error C1083 Cannot open include file: ‘cuda_runtime.h’: No such file or directory
Both files sit in the same project in the same directory. Also Visual Studio’s IntelliSense doesn’t find an error in file.cuh and autocompletes “cuda_runtime.h” normally. Only when I compile I get this error…
What I want to do is:
//file.cuh
#pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <vector>
....
and
//file.cu
#include "file.cuh"
....
The same error occurs for other include files (like device_launch_parameters.h) but not for non-cuda files like .
When I supply the full path to cuda_runtime.h in the header files, the error disappears.
Why can’t my .cuh header files see the cuda include directory, but .cu files can?
CUDA9.1, Windows 10 Pro 64bit, Visual Studio 2017 (tool chain v140 for VS 2015)
Thanks
Ben
I assume this is in a project already set up for CUDA runtime usage.
Obviously the file.cu is getting processed by nvcc. Are you attempting to include file.cuh in any non-.cu source files?
What happens if you do:
#include <cuda_runtime.h>
instead of:
#include "cuda_runtime.h"
?
Hi,
Yes I want to use file.cuh from outside Cuda as well.
Changing “” to <> doesn’t change anything
Sounds like your project is not set up properly then.
If you want to use that .cuh file in a non-.cu file, you will need to make sure the Additional include paths specified in your project includes the search path for cuda_runtime.h or any other files you need. Otherwise the VS cl.exe compiler will not know where to find cuda_runtime.h This sort of project setup requirement would be true for any header file that is not already known by cl.exe, and that includes CUDA header files.
When you include it in a .cu file, that file is processed by nvcc, and nvcc knows where to find cuda_runtime.h
Great it works now.
Thanks a lot.
I thought there was something wrong with my CudaProject and tried to fix its settings, but as you explained, the problem was actually caused by another project inside the same solution that tried to include the .cuh file from CudaProject.
Thanks for the explanation.
Cheers