Dear Sir/Madam,
I am a postgraduate student at National Technical University of Athens (N.T.U.A) and I use CUDA for my study.
I need some helpful informations about MAGMA and CUDA. Any guidance you can give me on CUDA (installation and the compiling) will be valuable.
The data of the machine x64 and CUDA in my project are the following.
----------------------------------
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
----------------------------------
VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 635M]
NVIDIA CUDA 6.5
----------------------------------
The challenging issues on my project are :
0) to which directory I must installed magma files?
1) which version of fortran I should download?
2) which version of MAGMA 1.6 is the best for CUDA 6.5?
3)what is the difference between make.inc.acml – make.inc.atlas – make.inc.goto - ...
4) which paths I should modify?
5) which the compile command?
How to compile this example?
I would greatly appreciate it if you provide me with any information on the above. I look forward to hearing of you. Τhank you in advance for your time.
Best regards.
Example:
# include < stdio.h >
# include < cuda.h >
# include " magma.h "
# include " magma_lapack.h "
int main ( int argc , char ** argv ){
magma_init ();
magma_timestr_t start , end ;
float gpu_time ;
magma_int_t * piv , info ; // piv - array of indices of inter -
magma_int_t m = 8192 , n =8192; // changed rows ; a - m * n matrix
magma_int_t nrhs = 100;
// b - n * nrhs , c - m * nrhs matrices
magma_int_t mn = m * n ;
// size of a
magma_int_t nnrhs = n * nrhs ;
// size of b
magma_int_t mnrhs = m * nrhs ;
// size of c
float * a ;
// a - m * n matrix on the host
float * b ;
// b - n * nrhs matrix on the host
float * c ;
// c - m * nrhs matrix on the host
float * d_a ;
// d_a - m * n matrix a on the device
float * d_c ;
// d_c - m * nrhs matrix c on the device
magma_int_t ione = 1;
magma_int_t ISEED [4] = {0 ,0 ,0 ,1};
// seed
magma_err_t err ;
const float alpha = 1.0;
// alpha =1
const float beta = 0.0;
// beta =0
// allocate matrices
err = m agma_s malloc _cpu ( &a , mn );
// host memory for a
err = m agma_s malloc _cpu ( &b , nnrhs ); // host memory for b
err = m agma_s malloc _cpu ( &c , mnrhs ); // host memory for c
err = magma_smalloc ( & d_a , mn );
// device memory for a
err = magma_smalloc ( &d_c , mnrhs ); // device memory for c
piv =( magma_int_t *) malloc ( m * sizeof ( magma_int_t )); // host mem .
// generate matrices
// for piv
lapackf77_slarnv (&ione , ISEED ,&mn , a );
// random a
lapackf77_slaset ( MagmaUpperLowerStr ,&n ,&nrhs ,&alpha ,&alpha ,
b ,&n ); // b - n * nrhs matrix of ones
printf ( " upper left corner of the expected solution :\ n " );
magma_sprint ( 4 , 4 , b , m ); // part of the expected solution
// right hand side c = a * b
blasf77_sgemm ( " N " ," N " ,&m ,&nrhs ,&n ,&alpha ,a ,&m ,b ,&m ,&beta ,c ,&m );
magma_ssetmatrix ( m , n , a , m , d_a , m );
// copy a -> d_a
magma_ssetmatrix ( m , nrhs , c , m , d_c , m ); // copy c -> d_c
// MAGMA
// solve the linear system d_a * x = d_c , d_a -m * n matrix ,
// d_c -m * nrhs matrix , d_c is overwritten by the solution ;
// LU decomposition with partial pivoting and row interchanges
// is used , row i is interchanged with row piv ( i )
start = get_current_time ();
magma sgetrf gpu( m, n, d a, m, piv, &info);
magma sgetrs gpu(MagmaNoTrans,m,nrhs,d a,m,piv,d c,m,&info);
end = get_current_time ();
gpu_time = GetTimerValue ( start , end )/1e3 ;
printf ( " magma_sgetrf_gpu + magma_sgetrs_gpu time : %7.5 f sec .\ n " ,
gpu_time ); // Magma time
magma_sgetmatrix ( m , nrhs , d_c , m , c , m );
printf ( " upper left corner of the Magma solution :\ n " );
magma_sprint ( 4 , 4 , c , m );
// part of the Magma solution
free ( a );
free ( b );
free ( c );
free ( piv );
magma_free ( d_a );
magma_free ( d_c );
magma_finalize ();
return 0;
}
// upper left corner of the expected solution :
// [
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
// 1.0000 1.0000 1.0000 1.0000
// ];
// magma_sgetrf_gpu + magma_sgetrs_gpu time : 1.98868 sec .
//
// upper left corner of the Magma solution :
// [
//0.9999 0.9999 0.9999 0.9999
//1.0223 1.0223 1.0223 1.0223
// 1.0001 1.0001 1.0001 1.0001
//0.9871 0.9871 0.9871 0.9871
// ];
Installation MAGMA for CUDA 6.5 on UBUNTU 12.04 X64
-
KONSTANTINOS_KOLOVOS
- Posts: 6
- Joined: Thu May 14, 2015 7:46 am
Re: Installation MAGMA for CUDA 6.5 on UBUNTU 12.04 X64
In general, it is best to use latest MAGMA release (for any version of CUDA).
You can install MAGMA wherever you like. The default is /usr/local/magma/ but you can change that using prefix, e.g.
make install prefix=/opt/magma
The different make.inc.* files define how to compile and link using various compilers & libraries.
We test MAGMA using Intel's icc/icpc/ifort and with GNU gcc/g++/gfortran. Again, the latest releases are usually the best.
You need a BLAS & LAPACK library installed, which can be any of ACML, ATLAS + LAPACK from netlib, Intel MKL, OpenBLAS, or others. (Goto BLAS is deprecated and included only for historic reasons.) In some cases, the LAPACK library is part of the "BLAS" library, in others you need to download LAPACK from netlib.
Ubuntu probably has BLAS and LAPACK packages available.
The README discusses which paths you need, depending on which make.inc file you choose. Basically, MAGMA needs to know where to look for your BLAS, LAPACK, and CUDA libraries. Especially if the libraries come with your OS (Ubuntu), these may be in your system paths, simply using /usr.
-mark
You can install MAGMA wherever you like. The default is /usr/local/magma/ but you can change that using prefix, e.g.
make install prefix=/opt/magma
The different make.inc.* files define how to compile and link using various compilers & libraries.
We test MAGMA using Intel's icc/icpc/ifort and with GNU gcc/g++/gfortran. Again, the latest releases are usually the best.
You need a BLAS & LAPACK library installed, which can be any of ACML, ATLAS + LAPACK from netlib, Intel MKL, OpenBLAS, or others. (Goto BLAS is deprecated and included only for historic reasons.) In some cases, the LAPACK library is part of the "BLAS" library, in others you need to download LAPACK from netlib.
Ubuntu probably has BLAS and LAPACK packages available.
The README discusses which paths you need, depending on which make.inc file you choose. Basically, MAGMA needs to know where to look for your BLAS, LAPACK, and CUDA libraries. Especially if the libraries come with your OS (Ubuntu), these may be in your system paths, simply using /usr.
-mark
-
KONSTANTINOS_KOLOVOS
- Posts: 6
- Joined: Thu May 14, 2015 7:46 am
Re: Installation MAGMA for CUDA 6.5 on UBUNTU 12.04 X64
Please help with advice to get CUDA 6.5 working on Ubuntu 12.04. The problem is with getting the NVIDIA driver to load.
I am very pleased to find that Konstantinos has a working system:
I downloaded the latest version which is 352.21 and attempted to load it. It loads but did not update the linux kernel module, so that it failed like this:
304.125 is my current set of drivers.
After that the only way to get the computer to work was to uninstall 352.21
I have two other versions, 340.76 and 346.87
CUDA 6.5 says it needs at least 340 to work.
If anyone with a working system could please tell me which drivers work for them.
Thank you
John
I am very pleased to find that Konstantinos has a working system:
At the moment the problem I have is that CUDA 6.5 needs an update of the NVIDIA drivers.KONSTANTINOS_KOLOVOS wrote:Dear Sir/Madam,
The data of the machine x64 and CUDA in my project are the following.
----------------------------------
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
----------------------------------
VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 635M]
NVIDIA CUDA 6.5
----------------------------------
I downloaded the latest version which is 352.21 and attempted to load it. It loads but did not update the linux kernel module, so that it failed like this:
Code: Select all
Jul 23 14:39:40 fletcher-desktop kernel: [ 32.634951] NVRM: API mismatch: the client has the version 352.21, but
Jul 23 14:39:40 fletcher-desktop kernel: [ 32.634952] NVRM: this kernel module has the version 304.125. Please
Jul 23 14:39:40 fletcher-desktop kernel: [ 32.634953] NVRM: make sure that this kernel module and all NVIDIA driver
Jul 23 14:39:40 fletcher-desktop kernel: [ 32.634953] NVRM: components have the same version.
After that the only way to get the computer to work was to uninstall 352.21
I have two other versions, 340.76 and 346.87
CUDA 6.5 says it needs at least 340 to work.
If anyone with a working system could please tell me which drivers work for them.
Thank you
John