Skip to content

Commit

Permalink
allow total memory hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
OrellBuehler committed May 19, 2024
1 parent 9c45678 commit 1cd2c29
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "utlist.h"

#define ENV_NVSHARE_ENABLE_SINGLE_OVERSUB "NVSHARE_ENABLE_SINGLE_OVERSUB"
#define ENV_NVSHARE_HIDE_MEMINFO_RESERVE_MIB "NVSHARE_HIDE_MEMINFO_RESERVE_MIB"

#define MEMINFO_RESERVE_MIB 1536 /* MiB */
#define KERN_SYNC_DURATION_BIG 10 /* seconds */
Expand Down Expand Up @@ -84,6 +85,7 @@ int pending_kernel_window = 1;
pthread_mutex_t kcount_mutex;

int enable_single_oversub = 0;
int hide_meminfo_reserve_mib = 0;
int nvml_ok = 1;

/* Representation of a CUDA memory allocation */
Expand Down Expand Up @@ -330,6 +332,11 @@ static void initialize_libnvshare(void)
log_warn("Enabling GPU memory oversubscription for this"
" application");
}
value = getenv(ENV_NVSHARE_HIDE_MEMINFO_RESERVE_MIB);
if (value != NULL) {
hide_meminfo_reserve_mib = 1;
log_warn("Hiding %d MiB from CUDA memory info", MEMINFO_RESERVE_MIB);
}

bootstrap_cuda();
}
Expand Down Expand Up @@ -782,6 +789,10 @@ CUresult cuMemGetInfo(size_t *free, size_t *total)
reserve_mib = (MEMINFO_RESERVE_MIB) MiB;
*free = *total - (size_t) reserve_mib;

if (hide_meminfo_reserve_mib == 1) {
*total -= reserve_mib;
}

log_debug("nvshare's cuMemGetInfo returning free=%.2f MiB,"
" total=%.2f MiB", toMiB(*free), toMiB(*total));
return result;
Expand Down

0 comments on commit 1cd2c29

Please sign in to comment.