Skip to content

Commit

Permalink
GPU memory issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
luigicarratino committed Aug 10, 2017
1 parent 868e33e commit 08ea50b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Experiments/test_TIMIT.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
trp = randperm(ntr,m);
Xuni = Xtr(trp,:);

T = 25;
T = 15;

cobj = [];

Expand Down
6 changes: 3 additions & 3 deletions FALKON/falkon.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,17 @@
if useGPU && ~issparse(A) && ~issparse(B)
gD = gpuDevice();
dbmem = gD.AvailableMemory/8;
d = size(A,2);
d = 2*size(A,2);
nmax_gpu = floor((sqrt(d^2 + kerMemCoefficient*dbmem)-d)/kerMemCoefficient);
nmax_ram = floor(sqrt(freeDoubles));
nmax = min(nmax_gpu, nmax_ram);

if nmax > size(A,1) && size(A,1) <= size(B,1)
nmaxA = size(A,1);
nmaxB = min(floor(dbmem/(d + nmaxA*(kerMemCoefficient + d))), floor(freeDoubles/nmaxA));
nmaxB = min(floor((dbmem - nmaxA*(kerMemCoefficient + d))/(nmaxA + kerMemCoefficient + d)), floor(freeDoubles/nmaxA));
elseif nmax > size(B,1)
nmaxB = size(B,1);
nmaxA = min(floor(dbmem/(d + nmaxB*(kerMemCoefficient + d))), floor(freeDoubles/nmaxB));
nmaxA = min(floor((dbmem - nmaxB*(kerMemCoefficient + d))/(nmaxB + kerMemCoefficient + d)), floor(freeDoubles/nmaxB));
else
nmaxA = nmax;
nmaxB = nmax;
Expand Down
8 changes: 6 additions & 2 deletions FALKON/gaussianKernel.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@


function D = res(X1, X2, sigma)
D = -2.0*X1*X2';

sq1 = sum(X1.^2,2);
clear X1

sq2 = sum(X2.^2,2)';

D = X1*X2';

clear X2
clear X1

D = -2.0*D;

D = bsxfun(@plus, D, sq2);
clear sq2
Expand Down

0 comments on commit 08ea50b

Please sign in to comment.