0

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>
BJury
  • 2,526
  • 3
  • 16
  • 27
  • https://github.com/kunzmi/managedCuda/blob/e796f78f8ec72bfea1dfe1974f1aaa5d758ef020/NVRTC/CudaRuntimeCompiler.cs#L28 -- as per the linked duplicate, you have to supply include files/sources as separate arguments to the NVRTC session – talonmies Jul 10 '19 at 07:50
  • @talonmies Why has this been marked as a duplicate to a question that does not even mention ManagedCuda? I don't have a problem compiling currand into ptx files, but I can't get it to compile using ManagedCuda. The 'solution' in that question is 'generate random numbers on the CPU and upload it' which is madness and doesn't answer the question here. – BJury Jul 13 '19 at 11:34
  • @talonmies Note, this is *not* a cuda problem, nvcc works fine, its a problem with ManagedCuda. – BJury Jul 13 '19 at 11:38

0 Answers0