Problem with cudaMalloc3DArray cudaMalloc3DArray gives an "out of memory" error or a seg fau

I’m just starting with CUDA and I’m having problems creating a 3D texture. I have a 3D array of floats of dimensions 201x201x256 and I get an “out of memory” error when allocating using cudaMalloc3DArray. I’m working on a Tesla c2050 so I have more than enough memory for this, so I must be doing something wrong. A snippet of my code follows

size_t Nx = 256;

		size_t Ny = 201;

		size_t Nz = 201;

		// create extent for patient geometry

		size_t dimX = Nx*sizeof(float);

		size_t dimY = Ny*sizeof(float);

		size_t dimZ = Nz*sizeof(float);

		cudaExtent extGeom = make_cudaExtent(dimX,dimY,dimZ);

		

		// allocate device memory for terma and copy data

		cudaArray arrTerma = 0;

		cudaChannelFormatDesc chanTerma = cudaCreateChannelDesc<float>();

		cudaSafeCall( cudaMalloc3DArray(&arrTerma, &chanTerma, extGeom));

I suspected that the problem was in the different dimension in width, so I changed to be 256x256x256 and now I get a segmentation fault.

I would appreciate any help with this :)

[s]As far as I understand cudaMalloc3DArray you don’t need to use sizeof(float) in your cudaExtent, the normal number of elements per dimension is enough.

The datatype comes from cudaChannelFormatDesc. This probably explains the out of memory error.[/s]

Seems like I was wrong with this.

After some searching I found this post http://forums.nvidia.com/index.php?showtopic=165400

I am not sure why you get a segmentation fault when you set the size to 256^3. Is there maybe some other operation that uses this size and now tries to access memory that is not allocated?

[s]As far as I understand cudaMalloc3DArray you don’t need to use sizeof(float) in your cudaExtent, the normal number of elements per dimension is enough.

The datatype comes from cudaChannelFormatDesc. This probably explains the out of memory error.[/s]

Seems like I was wrong with this.

After some searching I found this post http://forums.nvidia.com/index.php?showtopic=165400

I am not sure why you get a segmentation fault when you set the size to 256^3. Is there maybe some other operation that uses this size and now tries to access memory that is not allocated?