gpt4 book ai didi

linux - nvcc: 没有那个文件或目录

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:05:02 35 4
gpt4 key购买 nike

请原谅我的菜鸟。我们的研究小组最近购买了一台服务器,其中装有 2 个 NVIDIA Tesla 单元,我负责设置它。

服务器单元正在运行 Rocks 6.0。

所以我根据以下说明安装从 NVIDIA 下载的 CUDA SDK:http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html

我尝试编译 NVIDIA 随 SDK 提供的示例代码,但遇到了一堆错误。我想可能是 Makefile 没有配置好,所以我在 Stack Overflow 上看了看,发现了这段测试代码:

using namespace std;

#include <iostream>
#include <string.h>
#include <unistd.h>

int main (int argc, const char *argv[]) {

//our message
const char *message = "hello world!";
size_t size = strlen(message)+1;

//delcare and allocate a buffer on the device
char *d_buffer;
if (cudaMalloc(&d_buffer,size) != cudaSuccess){
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}

//copy our message to the device buffer
if (cudaMemcpy(d_buffer,message,size,cudaMemcpyHostToDevice)
!= cudaSuccess){
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}

//declare and allocate a buffer on the host
char *h_buffer = (char*)malloc(size);
if (h_buffer == 0){
cerr << "malloc failed" << endl;
exit(1);
}

//copy the device buffer back to the host
if (cudaMemcpy(h_buffer,d_buffer,size,cudaMemcpyDeviceToHost)
!= cudaSuccess) {
cerr << cudaGetErrorString(cudaGetLastError()) << endl;
exit(1);
}

cout << h_buffer << endl;
cudaFree(d_buffer);
free(h_buffer);
}

所以按照说明,我编译了代码:

nvcc -o hello_cuda hello_cuda.cu

并得到以下错误:

In file included from /usr/local/cuda-5.0/bin/../include/cuda_runtime.h:76,
from <command-line>:0:
/usr/local/cuda-5.0/bin/../include/common_functions.h:76:15: error: new: No such file or directory
In file included from /usr/local/cuda-5.0/bin/../include/common_functions.h:162,
from /usr/local/cuda-5.0/bin/../include/cuda_runtime.h:76,
from <command-line>:0:
/usr/local/cuda-5.0/bin/../include/math_functions.h:7555:17: error: cmath: No such file or directory
/usr/local/cuda-5.0/bin/../include/math_functions.h:7556:19: error: cstdlib: No such file or directory
hello_cuda.cu:11:20: error: iostream: No such file or directory

这些基本上是我在编译示例代码时收到的相同类型的错误消息。我的猜测是编译器配置不正确,因为 iostream 应该只是 C 的标准库。

有什么想法或建议可以解决这个问题吗?这似乎是一个非常简单的问题,但我已经为此绞尽脑汁好几天了!

最佳答案

您似乎没有正确安装 gcc/g++。示例不需要提升,错误消息指出它找不到标准库(new、cmath、cstdlib)。

来自第 2.8.1 节 http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#proper-compiler-install

On both Linux and Windows, properly installed compilers have some form of internal knowledge that enables them to locate system include files, system libraries and dlls, include files and libraries related the compiler installation itself, and include files and libraries that implement libc and libc++.

关于linux - nvcc: 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14637578/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com