GPU out of memory when the total ram usage is 2.8G

Hi,

If you only need to allocate a 2GB memory, it should be fine on TX2.
Just check the maximal chunk can be allocated is 3800MiB.

#include <stdio.h>
#include "cuda.h"
#define ONE_MBYTE (1024*1024)

void printMemInfo()
{
    size_t free_byte ;
    size_t total_byte ;
    cudaError_t cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ;

    if ( cudaSuccess != cuda_status ){
        printf("Error: cudaMemGetInfo fails, %s\n", cudaGetErrorString(cuda_status));
        exit(1);
    }

    double free_db = (double)free_byte ;
    double total_db = (double)total_byte ;
    double used_db = total_db - free_db ;

    printf("GPU memory usage: used = %.2f MB, free = %.2f MB, total = %.2f MB\n", used_db/ONE_MBYTE, free_db/ONE_MBYTE, total_db/ONE_MBYTE);
}

int main(){
    void *p;

    int amount = 0;
    while(true){
        cudaError_t rval = cudaMalloc( &p, long(amount)*ONE_MBYTE);
        printf( "cudaAlloc( ..., %dMByte, ... ) returns %d\n", amount, rval );
        printMemInfo();

        if( rval != cudaSuccess ) break;
        amount += 100;
        cudaFree(p);
    }
    return 0;
}