using eig to find the eigenvalues and eigenvectors of a large matrix on GPU

Hi,
I have matrix A with 7936*7936 dimensions. I use eig to find its eigenvalues and eigenvectors, the command is [vect,eigen]=eig(A). But if I perform this calculations on GPU, it is more slower than cpu. My code on GPU is as follows
A=rand(7936,7936,'gpuArray');
[vect,eigen]=eig(A);
I do not know why is this calculations on GPU is so slowly? Are there some other good methods to accelerate the eig on GPU?
Thanks very much!

2 Comments

For your purposes, could you switch to single precision?
Thanks for your reply. I have tested for swithc the matrix to single, but is also very slowly, it looks like the GPU does not work, and the calclulation is still performed on CPU.

Sign in to comment.

 Accepted Answer

It might be a question of your hardware. On the GTX 1050 in R2020b, I see only about a 10% speed-up in double precision and about 50% in single-precision. On the GTX 1080 Ti in R2020a, I see a factor of 2 speed-up at both precisions.
gd=gpuDevice;
Ac=rand(2500);
Ag=gpuArray(Ac);
tic;
[vect,eigen]=eig(Ac);
toc;
tic;
[vect,eigen]=eig(Ag);
wait(gd)
toc
Elapsed time is 9.484250 seconds.
Elapsed time is 5.183906 seconds.

7 Comments

Dear Matt,
Thanks for your reply. I have tested my hardware by using gpuDevice in matlab 2020b, my GPU is GeForce RTX 2080 Ti. I do find that for a large matrix (i,e,, 8000*8000 matrix) with elements being complex numbers, the calculations is very slowly, it looks like that the GPU does not work, and the calclulation of eig is still performed on CPU. I do not know the reason for that. Since the matrix is complex and hermitian, can the GPU support the eig for a complex matrix? Moreover, is the GPU related to my licenses? mybe my licenses of matlab can not support the eig culculations of a larger complex matrix?
Looking forward to your reply again.
Is the matrix the only one on the GPU? Maybe you are near the memory limits of the card.
I just test the only one complex matrix with 8000*8000, the memeory of my card is 11GB.
As long as you have the Parallel Computing Toolbox license you should be ok (except possibly if you are farming out to a Distributed Computing server)
Thanks for your reply. I have the Parallel Computing Toolbox license. How to check the GPU works or not? and How to check the memory used by the GPU data?
If gpuArray(1) returns a value, then MATLAB detected your GPU and an acceptable driver.
You might want to look at gpubench in the Add-On Explorer
How to check the memory used by the GPU data?
gpuDevice() will display that.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 23 Oct 2021

Commented:

on 26 Oct 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!