Skip to content

Commit

Permalink
fixed gpu list
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Nov 13, 2020
1 parent dde0298 commit 9ea170e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
int * getFreeGpuList(int *numFree) {
int * gpuList;
int nDevices;
int i, count = 0;
int i, j = 0, count = 0;

cudaGetDeviceCount(&nDevices);
gpuList = (int *) malloc(nDevices * sizeof(int));
Expand All @@ -18,11 +18,11 @@ int * getFreeGpuList(int *numFree) {
size_t totalMem;
cudaMemGetInfo(&freeMem, &totalMem);
if (freeMem > .9 * totalMem) {
gpuList[i] = i;
gpuList[j] = i;
count++;
j++;
}
}
*numFree = count;
free(gpuList);
return gpuList;
}

0 comments on commit 9ea170e

Please sign in to comment.