CUDA链接错误 - Visual Express 2008 - nvcc致命由于(null)配置文件 [英] CUDA linking error - Visual Express 2008 - nvcc fatal due to (null) configuration file
问题描述
我一直在寻找一个可能的解决方案,我的错误过去2周。我已经成功安装了Cuda 64位编译器(工具)和SDK,以及64位版本的Visual Studio Express 2008和Windows 7 SDK与Framework 3.5。我使用Windows XP 64位。我已经确认VSE能够在64位编译,因为我有所有的64位选项可用我使用下面的网站上的步骤:(因为Visual Express本身不包括64位包) p>
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/ p>
64位安装的注册表更新位于与上述链接相同的页面上的用户注释中。
我已经确认了64位编译能力,因为x64可以从工具 - >选项 - > VC ++目录下的下拉菜单中获得,并且64位编译不会导致整个项目被跳过。我已经包括所有需要的目录64位的cuda工具,64 SDK和Visual Express(\VC\bin\amd64)。
这里是错误信息我试图在64位编译时收到:
1> ------ Build started:配置:版本x64 ------
1>使用CUDA构建规则...编译
1>C:\CUDA\bin64\\\\\\\\\\\\\\\\\\vn C:\Program Files(x86)\Microsoft Visual Studio 9.0 \VC\bin-Xcompiler/ EHsc / W3 / nologo / O2 / Zi / MT-maxrregcount = 32 --compile -ox64 \Release\template.cu.objc:\Documents和Settings \ All Users \Application Data\ NVIDIA Corporation \ NVIDIA GPU计算SDK \C\src\CUDA_Walkthrough_DeviceKernels\模板。 cu
1> nvcc致命错误:在C:/ Program Files(x86)/ Microsoft Visual Studio 9.0 / VC / bin /../下找不到Visual Studio配置文件'(null)'。 。
1>链接...
1> LINK:致命错误LNK1181:无法打开输入文件'。\x64\Release\template.cu.obj'
1>构建日志保存在file:// c:\Documents和Settings \Administrator\My Documents \Visual Studio 2008 \Projects\New\New\x64\Release\BuildLog.htm
1>新 - 1错误,0警告
========== Build:0成功,1失败,0最新,0跳过==========
这里是简单的代码我想编译/以64位元执行:
#include< stdlib.h>
#include< stdio.h>
#include< string.h>
#include< math.h>
#include< cuda.h>
void mypause()
{
printf(按[Enter]继续。
fflush(stdout);
getchar();
}
__global__ void VecAdd1_Kernel(float * A,float * B,float * C,int N)
{
int i = blockDim.x * blockIdx。 x + threadIdx.x;
if(i C [i] = A [i] + B [i] // result应该是一个250x的16x1数组
}
__global__ void VecAdd2_Kernel(float * B,float * C,int N)
{
int i = blockDim.x * blockIdx.x + threadldx.x;
if(i C [i] = C [i] + B [i] // result应该是一个包含400s的16x1数组
}
int main()
{
int N = 16;
float A [16]; float B [16];
size_t size = N * sizeof(float);
for(int i = 0; i {
A [i] = 100.0;
B [i] = 150.0;
}
//在主机内存中分配输入向量h_A和h_B
float * h_A =(float *)malloc(size);
float * h_B =(float *)malloc(size);
float * h_C =(float *)malloc(size);
//初始化输入向量
memset(h_A,0,size); memset(h_B,0,size);
h_A = A; h_B = B;
printf(SUM =%f \\\
,A [1] + B [1]); //简单检查初始化
//分配设备内存中的向量
float * d_A;
cudaMalloc((void **)& d_A,size);
float * d_B;
cudaMalloc((void **)& d_B,size);
float * d_C;
cudaMalloc((void **)& d_C,size);
//将矢量从主机内存复制到设备内存
cudaMemcpy(d_A,h_A,size,cudaMemcpyHostToDevice);
cudaMemcpy(d_B,h_B,size,cudaMemcpyHostToDevice);
//调用内核
int threadsPerBlock = 256;
int blocksPerGrid =(N + threadsPerBlock-1)/ threadsPerBlock;
VecAdd1(blocksPerGrid,threadsPerBlock,d_A,d_B,d_C,N);
VecAdd2(blocksPerGrid,threadsPerBlock,d_B,d_C,N);
//将设备内存中的结果复制到主机内存
// h_C包含主机内存中的结果
cudaMemcpy(h_C,d_C,size,cudaMemcpyDeviceToHost);
for(int i = 0; i {
printf(%f,h_C [i ]);
printf(\\\
);
}
printf(\\\
);
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
free(h_A);
free(h_B);
free(h_C);
mypause();
return 0;
}
/ p>
- 安装Windows SDK(不要忘记为64位操作系统选择所有x64选项)
- 在PATH中包含c:\Program文件(x86)\ Microsoft Microsoft Visual Studio 10.0 \VC\bin\amd64
- 在目录c:中创建文件vcvars64.bat \Program Files(x86)\Microsoft Visual Studio 10.0 \VC\bin\amd64,包含以下内容:
callC:\Program Files \ Microsoft SDKs \Windows \v7。 1 \Bin\SetEnv.cmd/ x64
注意:我这样做是因为:
- 我使用VC ++ Express 2010
- 我在任何目录中都没有vcvars64.bat
I've been searching extensively for a possible solution to my error for the past 2 weeks. I have successfully installed the Cuda 64-bit compiler (tools) and SDK as well as the 64-bit version of Visual Studio Express 2008 and Windows 7 SDK with Framework 3.5. I'm using windows XP 64-bit. I have confirmed that VSE is able to compile in 64-bit as I have all of the 64-bit options available to me using the steps on the following website: (since Visual Express does not inherently include the 64-bit packages)
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/
The registry updates for 64-bit installation are found in a user comment on the same page as the above link.
I have confirmed the 64-bit compile ability since the "x64" is available from the pull-down menu under "Tools->Options->VC++ Directories" and compiling in 64-bit does not result in the entire project being "skipped". I have included all the needed directories for 64-bit cuda tools, 64 SDK and Visual Express (\VC\bin\amd64).
Here's the error message I receive when trying to compile in 64-bit:
1>------ Build started: Project: New, Configuration: Release x64 ------
1>Compiling with CUDA Build Rule...
1>"C:\CUDA\bin64\nvcc.exe" -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -maxrregcount=32 --compile -o "x64\Release\template.cu.obj" "c:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\CUDA_Walkthrough_DeviceKernels\template.cu"
1>nvcc fatal : Visual Studio configuration file '(null)' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/../..'
1>Linking...
1>LINK : fatal error LNK1181: cannot open input file '.\x64\Release\template.cu.obj'
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\New\New\x64\Release\BuildLog.htm"
1>New - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here's the simple code I'm trying to compile/run in 64-bit:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda.h>
void mypause ()
{
printf ( "Press [Enter] to continue . . ." );
fflush ( stdout );
getchar();
}
__global__ void VecAdd1_Kernel(float* A, float* B, float* C, int N)
{
int i = blockDim.x*blockIdx.x+threadIdx.x;
if (i<N)
C[i] = A[i] + B[i]; //result should be a 16x1 array of 250s
}
__global__ void VecAdd2_Kernel(float* B, float* C, int N)
{
int i = blockDim.x*blockIdx.x+threadIdx.x;
if (i<N)
C[i] = C[i] + B[i]; //result should be a 16x1 array of 400s
}
int main()
{
int N = 16;
float A[16];float B[16];
size_t size = N*sizeof(float);
for(int i=0; i<N; i++)
{
A[i] = 100.0;
B[i] = 150.0;
}
// Allocate input vectors h_A and h_B in host memory
float* h_A = (float*)malloc(size);
float* h_B = (float*)malloc(size);
float* h_C = (float*)malloc(size);
//Initialize Input Vectors
memset(h_A,0,size);memset(h_B,0,size);
h_A = A;h_B = B;
printf("SUM = %f\n",A[1]+B[1]); //simple check for initialization
//Allocate vectors in device memory
float* d_A;
cudaMalloc((void**)&d_A,size);
float* d_B;
cudaMalloc((void**)&d_B,size);
float* d_C;
cudaMalloc((void**)&d_C,size);
//Copy vectors from host memory to device memory
cudaMemcpy(d_A,h_A,size,cudaMemcpyHostToDevice);
cudaMemcpy(d_B,h_B,size,cudaMemcpyHostToDevice);
//Invoke kernel
int threadsPerBlock = 256;
int blocksPerGrid = (N+threadsPerBlock-1)/threadsPerBlock;
VecAdd1(blocksPerGrid, threadsPerBlock,d_A,d_B,d_C,N);
VecAdd2(blocksPerGrid, threadsPerBlock,d_B,d_C,N);
//Copy results from device memory to host memory
//h_C contains the result in host memory
cudaMemcpy(h_C,d_C,size,cudaMemcpyDeviceToHost);
for(int i=0; i<N; i++) //output result from the kernel "VecAdd"
{
printf("%f ", h_C[i] );
printf("\n");
}
printf("\n");
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
free(h_A);
free(h_B);
free(h_C);
mypause();
return 0;
}
I solved the problem by
- installing Windows SDK (don't forget to choose all x64 options for 64 bit OS)
- include "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64" in PATH
- create file vcvars64.bat inside directory "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64" with following content: call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
Note: I did this because:
- I am using VC++ Express 2010
- I dont have "vcvars64.bat" in any directory ??
这篇关于CUDA链接错误 - Visual Express 2008 - nvcc致命由于(null)配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!