gpt4 book ai didi

visual-studio-2010 - CUDA Visual Studio 2010 Express 构建错误

转载 作者:行者123 更新时间:2023-12-01 04:01:10 24 4
gpt4 key购买 nike

我正在尝试在 64 位 Windows 7 上使用 Visual Studio 2010 Express 在 Windows 上开始 CUDA 编程。我花了一段时间设置环境,我刚刚编写了我的第一个程序 helloWorld.cu :)

目前我正在使用以下程序:

#include <stdio.h>


__global__ void add(int a, int b, int *c){
*c = a + b;
}

int main(void){
int c;
int *dev_c;
HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );

add<<<1,1>>>(2, 7, dev_c);

HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int), cudaMemcpyDeviceToHost ) );

printf("2 + 7 = %d\n", c);
cudaFree( dev_c );

return 0;
}

这是使用 Windows7.1SDK 平台工具集构建的输出:
1>  C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version  -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include"  -G   --keep-dir "x64\Debug" -maxrregcount=0  --machine 64 --compile  -g    -Xcompiler "/EHsc /W1 /nologo /O2 /Zi  /MD  " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu" 
1>nvcc : fatal error : '-ccbin': expected a number
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code -1.

但是,使用 v100 平台工具集时出现此错误:
C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include"  -G   --keep-dir "x64\Debug" -maxrregcount=0  --machine 64 --compile  -g    -Xcompiler "/EHsc /W1 /nologo /O2 /Zi  /MD  " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu" 
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\math.h(455): error : dllexport/dllimport requires external linkage
1>C:/Users/User/documents/visual studio 2010/Projects/CudaTest2/CudaTest2/hello.cu(12): error : identifier "HANDLE_ERROR" is undefined
1>c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\math_functions.h(2900): error : function "hypotf" was referenced but not defined
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

有人能指出我正确的方向吗?我已经阅读了几乎所有关于相关问题、安装和卸载工具的帖子,但仍然无法获得正确的构建。

最佳答案

以下对我有用。编辑文件 *C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.prop*s。搜索 PlatformToolset 并为 Windows7.1SDK 添加一个条目。将值设置为 2010。

<CudaClVersion Condition="'$(PlatformToolset)' == 'Windows7.1SDK'">2010</CudaClVersion>

关于visual-studio-2010 - CUDA Visual Studio 2010 Express 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13396878/

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