# cudaMalloc difference between Tesla Device and Geforce Device? cudaMalloc on complete global memory

**URL:** <https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739>\
**Category:** CUDA Programming and Performance\
**Created:** [June 1, 2011, 10:55am UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739 "2011-06-01T10:55:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![svbettscheider](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@svbettscheider](https://forums.developer.nvidia.com/u/svbettscheider)\
**Post date:** [June 1, 2011, 10:55am UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/1 "2011-06-01T10:55:13Z")

</div>

Hi,

are there differences between GeForce 310M and Tesla Devices(Tesla C1060 or Tesla C2050) if i use cudaMalloc?

I want do allocate the whole global memory of the device.

Example for GeForce 310M:

> [@](#):
>
> quote from deviceQuery:
> 
> Total amount of global memory: 1073479680 bytes

my code

```auto
cudaMalloc(mem,1054437333*sizeof(char));

```

for allocate memory(btw.1054437333 != 1073479680 but one byte more the allocate failed)

> [@](#):
>
> cudaMemGetInfo( &free\_byte, &total\_byte );

to get some information about the memory status.

Output:

GPU memory usage: used = 1023.750000, free = 0.000000 MB, total = 1023.750000 MB \<\<\< OK :) that is what i want.

But with a Tesla Device(Tesla C1060 or Tesla C2050) i canÂ´t allocate memory.

Example for Tesla C1060:

> [@](#):
>
> quote from deviceQuery:
> 
> Total amount of global memory: 4294770688 bytes

my code

```auto
cudaMalloc(mem,3294770688*sizeof(char));

```

for allocate memory

> [@](#):
>
> cudaMemGetInfo( &free\_byte, &total\_byte );

to get some information about the memory status.

Output:

GPU memory usage: used = 40.746338, free = 4055.066162 MB, total = 4095.812500 MB FAIL :( used should be 3,xxx GIG

Greets

Sven

---

<div class="post-metadata">

**Author:** ![avidday](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/avidday/32/59219_2.png) [@avidday](https://forums.developer.nvidia.com/u/avidday)\
**Post date:** [June 1, 2011, 11:04am UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/2 "2011-06-01T11:04:17Z")

</div>

```auto
cudaMalloc(mem,3294770688*sizeof(char));

```

A “naked” constant like that will be treated as a signed integer, which has a maximum value of 2147483648. So you are probably the victim of integer overflow. Try explicitly casting the constant to a size\_t, or specifying the constant as an unsigned long, so either:

```auto
cudaMalloc(mem,sizeof(3294770688)*sizeof(char));

```

or

```auto
cudaMalloc(mem,3294770688ul*sizeof(char));

```

and see what happens.

---

<div class="post-metadata">

**Author:** ![svbettscheider](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@svbettscheider](https://forums.developer.nvidia.com/u/svbettscheider)\
**Post date:** [June 1, 2011, 12:00pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/3 "2011-06-01T12:00:42Z")

</div>

Both solutions not worked. :( The output is always used 40.746338, free = 4055.066162 MB, total = 4095.812500 MB…

---

<div class="post-metadata">

**Author:** ![avidday](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/avidday/32/59219_2.png) [@avidday](https://forums.developer.nvidia.com/u/avidday)\
**Post date:** [June 1, 2011, 12:04pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/4 "2011-06-01T12:04:42Z")

</div>

What operating system is this on? And what status are the cudaMalloc calls returning?

---

<div class="post-metadata">

**Author:** ![svbettscheider](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@svbettscheider](https://forums.developer.nvidia.com/u/svbettscheider)\
**Post date:** [June 1, 2011, 12:08pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/5 "2011-06-01T12:08:25Z")

</div>

//edit sorry it is not cudaSuccess!!! I get Segmentation fault.

cudaError\_t cuda\_status2 = cudaMalloc(mem,3004437333ul\*sizeof(char)); \<\<\< Seg\_Fault follows

cudaMalloc(mem,3004437333ul\*sizeof(char)); No Seg\_Fault

[b]//edit2  
cudaError\_t cuda\_status2 \<\< second var with cudaError\_t caused the error. Seg\_Fault.

Status is cudaSuccess!!!

printf(cudaGetErrorString(cuda\_status)) → no error!!!  
[/b]

System is Ubuntu Server.  
Linux cuda 2.6.35-22-server #33-Ubuntu SMP Sun Sep 19 20:48:58 UTC 2010 x86\_64 GNU/Linux

nvcc --version  
nvcc: NVIDIA (R) Cuda compiler driver  
Copyright (c) 2005-2010 NVIDIA Corporation  
Built on Wed\_Nov\_\_3\_16:16:57\_PDT\_2010  
Cuda compilation tools, release 3.2, V0.2.1221

CUDA Driver Version: 3.20  
CUDA Runtime Version: 3.20  
CUDA Capability Major/Minor version number: 1.3

---

<div class="post-metadata">

**Author:** ![svbettscheider](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@svbettscheider](https://forums.developer.nvidia.com/u/svbettscheider)\
**Post date:** [June 1, 2011, 1:29pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/6 "2011-06-01T13:29:15Z")

</div>

With followong code i get

```auto
int a=0;

while(a<140){

        double inputData[999999];

        int *dev_inputData;

        cudaMalloc((void**)&dev_inputData,999999*sizeof(double));

        cudaMemcpy(dev_inputData,inputData,999999*sizeof(double),cudaMemcpyHostToDevice);

a++;

}

```

GPU memory usage: used = 1116.938232, free = 2978.874268 MB, total = 4095.812500 MB

but the Code

```auto
void** mem;

void* dev_mem;

cudaMalloc(mem,(999999*140)*sizeof(double));

cudaMemcpy(dev_mem,mem,(999999*140)*sizeof(double),cudaMemcpyHostToDevice);

```

GPU memory usage: used = 40.746338, free = 4055.066162 MB, total = 4095.812500 MB

---

<div class="post-metadata">

**Author:** ![svbettscheider](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@svbettscheider](https://forums.developer.nvidia.com/u/svbettscheider)\
**Post date:** [June 1, 2011, 1:34pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-difference-between-tesla-device-and-geforce-device-cudamalloc-on-complete-global-memory/22739/7 "2011-06-01T13:34:58Z")

</div>

mhm ok.

Solution for Tesla

```auto
void** mem;

cudaMalloc(&mem,1054437333*sizeof(char));

```

this worked on Tesla Device. But on my geforce 310M not.

Solution for geforce 310M without &

```auto
void** mem;

cudaMalloc(mem,1054437333*sizeof(char));

```
