src/batched_regression.py
def _get_max_batch_size(cols, n_data):
    """
    Calculates the max batch size for this regression given the available memory on the device
    :param cols: Number of cols (predictors)
    :param n_data: Number of observations
    :return: batchSize
    """
    # Take in account the intermediate data structures used, also the precission

    # 2 times X (X and X transpose) + n_data (Y) + XTsXs_gpu (Square cols x cols) + XTsYs (cols x 1) + Invs ( cols, cols) + n (metric)
    # c = cols
    # n = data
    # 2nc + n + c**2 + c + c**2 + n = 2c**2 + 2nc + 2n
    # 90% of free memory in the card
    estimated_scalars_per_regression = 2*(cols**2) + 2*(cols*n_data) + 2*n_data
    free_memory = driver.mem_get_info()[0]
    required_bytes_per_regression = FLOAT_PRECISSION_SIZE * estimated_scalars_per_regression
    # Closest thousand
    max_batch = (int(free_memory/required_bytes_per_regression)/1000)*1000
    return max_batch

    Calculates the max batch size for this regression given the available memory on the device
    :param cols: Number of cols (predictors)
    :param n_data: Number of observations
    :return: batchSize
    
Calculates the max batch size for this regression given the available memory on the device
Calculates the max batch size for this regression given the available memory on the device
def _get_max_batch_size(cols, n_data):
    estimated_scalars_per_regression = 2*(cols**2) + 2*(cols*n_data) + 2*n_data
    free_memory = driver.mem_get_info()[0]
    required_bytes_per_regression = FLOAT_PRECISSION_SIZE * estimated_scalars_per_regression
    max_batch = (int(free_memory/required_bytes_per_regression)/1000)*1000
    return max_batch
def _get_max_batch_size ( cols , n_data ) : estimated_scalars_per_regression = 2 * ( cols ** 2 ) + 2 * ( cols * n_data ) + 2 * n_data free_memory = driver . mem_get_info ( ) [ 0 ] required_bytes_per_regression = FLOAT_PRECISSION_SIZE * estimated_scalars_per_regression max_batch = ( int ( free_memory / required_bytes_per_regression ) / 1000 ) * 1000 return max_batch
Calculates the max batch size for this regression given the available memory on the device
Calculates the max batch size for this regression given the available memory on the device
"""
    Calculates the max batch size for this regression given the available memory on the device
    :param cols: Number of cols (predictors)
    :param n_data: Number of observations
    :return: batchSize
    """ # Take in account the intermediate data structures used, also the precission # 2 times X (X and X transpose) + n_data (Y) + XTsXs_gpu (Square cols x cols) + XTsYs (cols x 1) + Invs ( cols, cols) + n (metric) # c = cols # n = data # 2nc + n + c**2 + c + c**2 + n = 2c**2 + 2nc + 2n # 90% of free memory in the card # Closest thousand
None
cols
Number of cols (predictors)
Number of cols ( predictors )
n_data
Number of observations
Number of observations