ManagedCuda kernel cannot find curand.h

279 Views Asked by At

I'm trying to use ManagedCuda to compile a kernel that uses the currand library. However, I cannot find a way to tell the CudaRuntimeCompiler how to find curand.h.

If I remove the '#include <curand.h>' line, everything works. However with it I get:

Exception: ErrorCompilation: Compilation error.
Test(1): catastrophic error: cannot open source file "curand.h"

1 catastrophic error detected in the compilation of "Test".
Compilation terminated.

Using a fully qualified include (#include <C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\curand.h>) gets me a bit further, so it's obviously just a case of telling the compiler where to look.

Exception: ErrorCompilation: Compilation error.
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\curand.h(59): catastrophic error: cannot open source file "cuda_runtime.h"

I've tried adding the folders to the path, to no avail.

Anyone know where this can be set? (Or know of an alternative package to ManagedCuda?)

All code below.

C# Code:

        static void Main(string[] args)
        {
            var rtc = new CudaRuntimeCompiler(GetKernel(), "Test");

            string[] compileArgs = new string[0];

            try
            {
                rtc.Compile(compileArgs);
            }
            catch (Exception e)
            {
                string log = rtc.GetLogAsString();
                Console.WriteLine($"Exception: {e.Message}");
                Console.WriteLine(log);
                Console.ReadKey();
            }

            rtc.Dispose();
        }

        static string GetKernel()
        {
            return File.ReadAllText("Kernel.c");
        }

Kernel.c

#include <curand.h>

extern "C"
{
    __global__ void DoNothing()
    {
    }
}

With MangedCuda-100 (10.0.31) and ManagedCuda-NVRTC (10.0.31) installed from NuGet.

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="ManagedCuda-100" version="10.0.31" targetFramework="net472" />
  <package id="ManagedCuda-NVRTC" version="10.0.31" targetFramework="net472" />
</packages>
0

There are 0 best solutions below