Managed Cuda : ErrorIllegalAddress: While executing a kernel, the device encountered a load or store instruction on an invalid memory address.

Jan 20, 2015 at 9:36 PM
I am using Managed Cuda 6.5. The graphic card is GTX 770 (Compute capability 3.0). I am having problem to run my program on platform target X64 but I do not have any problem with X86. I am successfully allocating memory on device using for example the following code

CudaDeviceVariable<double> d_input = new CudaDeviceVariable<double>(input.Length). CudaDeviceVariable<double> d_output = new CudaDeviceVariable<double>(output.Length).

But when it comes to run the kernel such as

inToLSTM.BlockDimensions = threadsPerBlock;
inToLSTM.GridDimensions = numberofBlock;
inToLSTM.Run(d_input.DevicePointer,d_output.DevicePointer);
it will give me the following error:

"ErrorIllegalAddress: While executing a kernel, the device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created)."

The kernel looks like this:

global void InToLSTM(double input,double output)
{
 int idx=threadIdx.x+blockDim.x*blockIdx.x;
__shared__ double sharedvar[1024];
sharedvar[threadIdx.x]=input[threadIdx.x];


__syncthreads();
if( 0 == threadIdx.x ) 
{
    double sum = 0;
    for( int i = 0; i < blockDim.x; i++ )
    {
        sum += sharedvar[i];
    }
    output[blockIdx.x]=sum;
}
As I said it works when I use platform target X86 like

Image

But it is not working when I change the platform target to X64 like

Image
Coordinator
Jan 20, 2015 at 10:20 PM
Is this in some way related to the problems in
https://managedcuda.codeplex.com/workitem/3
or
http://stackoverflow.com/questions/27514539/managedcuda-illegaladdress-while-executing-a-kernel ?

Could you please provide the compiled ptx file and the source code of the kernel (if possible), so that I can test the kernel on my system?
(You can also write me a personal mail through codeplex, if you don't want everyone to see the code)

Cheers,
Michael
Coordinator
Jan 21, 2015 at 7:29 PM
You get this error message if you compile to ptx at 32 bit and run C#/.net in 64 bit. Can you check if this is the case?
Marked as answer by saeedm on 1/21/2015 at 4:56 PM
Jan 21, 2015 at 11:12 PM
kunzmi wrote:
You get this error message if you compile to ptx at 32 bit and run C#/.net in 64 bit. Can you check if this is the case?
I sent you an email. I tried several things. I tried to compile the kernel with 64 bit. But it did not work in any case.
So please check the sample project that I sent for you and if you could run the C# project with 64 bit, please let me
know how can I do that. Thanks.
Jan 21, 2015 at 11:56 PM
You are right Kunzmi, The problem is solved. The problem was by changing the platform target for kernel, the ptx file would automatically be saved in another folder
(called x64). So we need to customize the path directory of the 64 bit ptx so that the C# code will load the right ptx file.

Thanks for your answer,