Hi,
I encountered strange errors today when I tried to use textures in my CUDA application. Basically, the application stopped at certain CUDA calls and took up 100% CPU usage.
The reason for this is most likely that I modified the Makefile from the template project from the SDK, because I was annoyed by the kernel only being compiled when I changed the normal .cu file. I added my_kernel.cu to the CUFILES. As a result, I had to declare my_kernel and a member, tex, as externs - see the attached code.
The problem seems to come from the extern texture, it works fine if I uncomment the cudaBindTextureToArray line.
But if I don’t, cuda gives me an “unspecified driver error”, the first call of cublasInit() yields a return value of 1 (CUBLAS_STATUS_NOT_INITIALIZED), and the second one causes the program to hang as described.
Other cuda (cudaMalloc, etc) calls produce similar effects.
The solution for me was to remove the kernel from the Makefile and to #include it in the .cu file - as in the template project.
I use version 1.0 on suse linux, with a geforce 8800 GTS.
Does anyone have an idea why this happens?
my.cu:
#include <stdio.h>
#include "cublas.h"
extern texture<float2,2> tex;
extern __global__ void my_kernel(char*);
int main(int argc, char** argv){
cublasStatus s = cublasInit();
printf("error %d\n",s);
s = cublasInit();
printf("error %d\n",s);
cudaChannelFormatDesc dXdesc = cudaCreateChannelDesc<float2>();
cudaArray* dXcolarr;
cudaMallocArray(&dXcolarr, &dXdesc, 128, 20);
cudaBindTextureToArray(colXtex, dXcolarr);
my_kernel<<< dim3(2,2), dim3(2,2) >>>( "hello world");
}
my_kernel.cu:
texture<float2,2> colXtex;
__global__ void my_kernel(char* arg) {
// do something
}