0

我正在尝试使用 LiteIDE 运行程序:

// cudatest
package cudatest

import (
    "fmt"
    "github.com/barnex/cuda5/cu"
)

func main() {
    fmt.Println("Hello, your GPU is:", cu.Device(0).Name())
}

我得到的是:

c:/go/bin/go.exe build -i [C:/godev]
# github.com/barnex/cuda5/cu
c:\GoDev\src\github.com\barnex\cuda5\cu\context.go:5:18: fatal error: cuda.h: No such file or directory
//#include <cuda.h>
           ^
compilation terminated.
Error: process exited with code 2.

我安装了来自 NVIDIA 的最新 CUDA SDK。为了让 Go 编译器看到它,我需要做什么?

4

1 回答 1

1

看起来您的 C 编译器不知道哪个目录有 cuda 头文件。你可以告诉 go 使用CGO_CPPFLAGS环境变量为 C 编译器提供额外的选项。您可能希望将其设置为类似

CGO_CPPFLAGS="-isystem /path/to/dir/with/cuda/header/in/it"

https://golang.org/cmd/cgo/

于 2015-03-26T15:43:18.873 回答