Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cutorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorBoris Fomitchev <borisfom@users.noreply.github.com>2016-11-24 01:38:57 +0300
committerSoumith Chintala <soumith@gmail.com>2016-11-24 01:38:57 +0300
commitf5932241e86087821a4c61dbde2c39a03d7c9883 (patch)
treee36533a796dc81b1c3cf75a7bc04ea41006891c0 /init.c
parent2d75d411560df62f4ac291143f6b0f2e15378031 (diff)
Implemented cudaMemGetInfo for caching allocator (#600)
* Implemented cudaMemGetInfo for caching allocator
Diffstat (limited to 'init.c')
-rw-r--r--init.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/init.c b/init.c
index 69f5583..124be5c 100644
--- a/init.c
+++ b/init.c
@@ -698,13 +698,14 @@ static int cutorch_getMemoryUsage(lua_State *L) {
size_t totalBytes = 0;
int curDevice;
THCudaCheck(cudaGetDevice(&curDevice));
+ THCState *state = cutorch_getstate(L);
int device = luaL_optint(L, 1, -10);
if (device == -10) { /* no argument passed, current device mem usage */
- THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes));
+ THCudaCheck(THCudaMemGetInfo(state, &freeBytes, &totalBytes));
} else { /* argument was given, particular device's memory usage */
THCudaCheck(cudaSetDevice(device-1)); /* zero indexed */
- THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes));
+ THCudaCheck(THCudaMemGetInfo(state, &freeBytes, &totalBytes));
THCudaCheck(cudaSetDevice(curDevice));
}
lua_pushnumber(L, freeBytes);