0

我正在尝试使用ManagedCuda编译使用currand library的内核。但是,我找不到告诉 CudaRuntimeCompiler 如何找到 curand.h 的方法。

如果我删除 ' #include <curand.h>' 行,一切正常。但是有了它,我得到:

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.

使用完全限定的 include ( #include <C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\curand.h>) 让我更进一步,所以这显然只是告诉编译器在哪里查找的一个例子。

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"

我尝试将文件夹添加到路径中,但无济于事。

谁知道这个可以在哪里设置?(或者知道 ManagedCuda 的替代包?)

下面的所有代码。

C#代码:

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

内核.c

#include <curand.h>

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

从 NuGet 安装 MangedCuda-100 (10.0.31) 和 ManagedCuda-NVRTC (10.0.31)。

<?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>
4

0 回答 0