Hi all,
I want to fill GPU memory fully. by cudaMallocManaged, I alloc a large memory, and init it in a kernel. but there are still a lot of free GPU memory. any help?
At the begining, there is about 7.5G free memory in GPU. After filling 7.5G data, there still is about 5.5G free memory.
here is my code:
#include <cuda.h>
#include <iostream>
using namespace std;
__global__ void incr(char* a, size_t n)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for(int i=tid; i<n; i+=stride)
{
a[i] = 0;
}
}
int main()
{
size_t freeSize, total;
cudaMemGetInfo(&freeSize, &total);
cout<<"free:"<<freeSize<<endl;
char* data;
cudaMallocManaged((void**) & data, freeSize);
incr<<<512, 512>>>(data, freeSize);
cudaDeviceSynchronize();
cudaMemGetInfo(&freeSize, &total);
cout<<"free:"<<freeSize<<endl;
}