CUDA 5.0没有了cutil_inline.h怎么办?

因为电脑前些日子装了CUDA 5.0,发现运行以前含有cutil.h头文件的代码出问题了,百度了一下,说是5.0不再支持这些头文件了,现在该怎么办呢?



#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "cutil_inline.h"
texture<float, 2, cudaReadModeElementType> texRef; 
__global__ void transformKernel(float* output, int width, int height, float theta) 
{
// Calculate normalized texture coordinates 
unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; 
unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; 
float u = x / (float)width; 
float v = y / (float)height; 

// Transform coordinates 
u -= 0.5f; 
v -= 0.5f; 
float tu = u*cosf(theta)- v*sinf(theta) + 0.5f; 
float tv = v*cosf(theta)+ u*sinf(theta) + 0.5f; 
// Read from texture and write to global memory 
output[y * width + x] = tex2D(texRef, tu, tv); 
}

// Host code 
int main() 
{ 
  float angle = 0.5f; // angle to rotate image by (in radians)
  // load image from disk
  float* h_data = NULL;
  unsigned int width, height;
  cutLoadPGMf("lena_bw.pgm", &h_data, &width, &height);
   
  // Allocate CUDA array in device memory 
  cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat); 
  cudaArray* cuArray; 
  cudaMallocArray(&cuArray, &channelDesc, width, height); 

   // Copy to device memory some data located at address h_data 
   // in host memory 
  unsigned int size = width * height * sizeof(float);
  cudaMemcpyToArray(cuArray, 0, 0, h_data, size, cudaMemcpyHostToDevice); 
// Set texture parameters 
texRef.addressMode[0] = cudaAddressModeWrap; 
texRef.addressMode[1] = cudaAddressModeWrap; 
texRef.filterMode = cudaFilterModeLinear; 
texRef.normalized = true; 

// Bind the array to the texture reference 
cudaBindTextureToArray(texRef, cuArray, channelDesc); 

// Allocate result of transformation in device memory 
float* output; 
cudaMalloc(&output, width * height * sizeof(float)); 

// Invoke kernel 
dim3 dimBlock(16, 16); 
dim3 dimGrid(width / dimBlock.x, height / dimBlock.y); 
transformKernel<<<dimGrid, dimBlock>>>(output, width, height, angle); 

// Free device memory 
cudaFreeArray(cuArray); 
cudaFree(output); 

}

因为没有了07.#include “cutil_inline.h”,所以我就用5.0中的#include “helper_image.h”,并且将cutLoadPGMf()改成 sdkLoadPGM(),但是仍然提示错误!!!
错误如下:
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>E:\Visual C++ 2010\CudaPractice\Debug\CudaPractice.exe : fatal error LNK1120: 1 个无法解析的外部命令

任何时候都不推荐你用例子里面的那些cut*开头的例程/宏,他们不是CUDA的一部分。

根据多年的经验看,错误的抄袭/使用它们带来的负面后果远远大于正面作用。不建议你使用。

同时,如同NV在说明里的说法一样,我也不对这些非CUDA的API/宏给予任何技术支持。

建立立刻停止使用。

此外,说找不到main()的话,请注意:
(0)您的代码是否含有main函数
(1)main所在的文件是否参与编译,
(2)该文件是否成功的生成.obj文件
(3)该.obj文件是否参与链接。

您的2楼的最后一个信息表明,连接器没有找到_main(cdecl, x86,从前缀和后缀推断),而不是编译错误。

好的。以后我会注意的。

我发现我的文件夹里没有生成.obj文件~

嗯嗯。那就想办法继续找到为何导致没有生成.obj, 一个较大的可能是该文件忘记参与编译了?(不要笑,当你找不到理由的时候不妨考虑这条)。

版主,您太好了啊!!!!

最近还行,你还好吗?

刚开始学,1000次kernel循环就会出现蓝屏死机现象,但是数据传递又出现很大的delay!!!!哎!

这个已经给你解释过了,请看你的原帖我的回复。