Installation cannot find magma or magmablas libraries

Open discussion for MAGMA

Installation cannot find magma or magmablas libraries

Postby dna » Wed Jun 13, 2012 4:52 pm

Hi,
I'm having a lot of trouble installing and interfacing MAGMA-1.2.0 with my Fortran codes. I have a workstation running Ubuntu 10.4.3 (64 bit). It has four NVIDIA Tesla C2050 GPUs. I have installed the default BLAS (1.2-2build1) and LAPACK (3.2.1-2) from the standard Ubuntu repositories. I currently use these libraries in my codes. I have also installed ATLAS (3.6.0-24ubuntu1) from the Ubuntu repositories though I have never used it. CUDA Toolkit 4.1 is installed and works correctly (I use it with CULA library). The default Fortran compiler installed on my system is gfortran (4.4) though sometimes I do compile with gfortran-4.5

After unpacking the installation program into folder /usr/local/magma-1.2.0 I copied make.inc.atlas to make.inc and tweaked it to my system:
Code: Select all
#//////////////////////////////////////////////////////////////////////////////
#   -- MAGMA (version 1.2.0) --
#      Univ. of Tennessee, Knoxville
#      Univ. of California, Berkeley
#      Univ. of Colorado, Denver
#      May 2012
#//////////////////////////////////////////////////////////////////////////////

#
# GPU_TARGET specifies for which GPU you want to compile MAGMA:
#     "Tesla" (NVIDIA compute capability 1.x cards)
#     "Fermi" (NVIDIA compute capability 2.x cards)
# See http://developer.nvidia.com/cuda-gpus

GPU_TARGET = Fermi

CC        = gcc
NVCC      = nvcc
FORT      = gfortran

ARCH      = ar
ARCHFLAGS = cr
RANLIB    = ranlib

OPTS      = -O3 -DADD_
FOPTS     = -O3 -DADD_ -x f95-cpp-input
NVOPTS    = --compiler-options -fno-strict-aliasing -DUNIX -O3 -DADD_
LDOPTS    = -fPIC -Xlinker -zmuldefs

LIB       = -lblas -latlas -lcublas -lm

CUDADIR   = /usr/local/cuda

LIBDIR    = -L$(CUDADIR)/lib64
INC       = -I$(CUDADIR)/include

LIBMAGMA     = $(MAGMA_DIR)/lib/magma.a
LIBMAGMABLAS = $(MAGMA_DIR)/lib/magmablas.a


Upon trying to install it using the terminal command 'sudo make' it gets part way through and develops this error:

make[1]: Entering directory `/usr/local/magma-1.2.0/magmablas'
nvcc --compiler-options -fno-strict-aliasing -DUNIX -O3 -DADD_ -arch sm_20 -DGPUSHMEM=200 -I/usr/local/cuda/include -I../include -I../control -c zauxiliary.cu -o zauxiliary.cu_o
make[1]: nvcc: Command not found
make[1]: *** [zauxiliary.cu_o] Error 127
make[1]: Leaving directory `/usr/local/magma-1.2.0/magmablas'
make: *** [libmagmablas] Error 2


Basically, it cannot find the nvcc command. One workaround I found was to enter a superuser environment by entering 'sudo -i' at the Terminal and then reentering the magma directory and redoing the make. The installation can now find nvcc.
Q1) Why couldn't your makefile find nvcc when installing with superuser rights? (I was unable to install the program without superuser rights)

The installation continues until it gets into the testing directory. I receive this error:
gcc -O3 -DADD_ -DHAVE_CUBLAS -DGPUSHMEM=200 -fPIC -Xlinker -zmuldefs -DGPUSHMEM=200 testing_zgemm.o -o testing_zgemm lin/liblapacktest.a -L../lib \
-lcuda -lmagma -lmagmablas -L/usr/local/cuda/lib64 -lblas -latlas -lcublas -lm
/usr/bin/ld: cannot find -lmagma
/usr/bin/ld: cannot find -lmagmablas
collect2: ld returned 1 exit status
make[1]: *** [testing_zgemm] Error 1
make[1]: Leaving directory `/usr/local/magma-1.2.0/testing'
make: *** [test] Error 2


Basically, it can't find the magma or magmablas libraries. Both magma.a and magmablas.a exist in the default folder /usr/local/magma-1.2.0/lib.
Q2) How do I fix this error?

I also want to test a simple Fortran implementation of the CPU interface for GESV, and there is no consistent and simple documentation of how to implement and compile this. I have created a sample code named magmatest.f03. The compilation/linking commands are commented at the beginning. I also run into similar problems encountered in the installation in that it cannot find the magma or magmablas libraries. I'm assuming this is the same problem as above.
Q3) If I can get past the above error, is there anything wrong with this sample code and then compilation/linking commands?

Code: Select all
PROGRAM magmatest
! Compilation/Linking Commands in terminal
!gcc -O3 -I/usr/local/cuda/src -I/usr/local/cuda/include -c fortran.cpp
!gfortran-4.5 -O3 -fno-underscoring -I/usr/local/cuda/include -I/usr/local/magma-1.2.0/include -c magmatest.f03
!gfortran-4.5 -O3 -fPIC magmatest.o fortran.o -L/usr/local/magma-1.2.0/lib -I/usr/local/magma-1.2.0/include -lcuda -lmagma -lmagmablas -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -latlas -lcublas -llapack -lm

IMPLICIT NONE

INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
INTEGER, PARAMETER :: REKIND = SELECTED_REAL_KIND(p=13, r=200)
!INTEGER, PARAMETER :: REKIND = SELECTED_REAL_KIND(p=6, r=37)

INTEGER :: errstat, ii, jj, lda, ldb, n, nrhs
INTEGER, DIMENSION(:), ALLOCATABLE :: ipiv
REAL(kind=REKIND) :: timea, timeb
REAL(kind=REKIND), DIMENSION(:,:), ALLOCATABLE :: A, B, X
CHARACTER(len=100) :: errmesg

INTERFACE MAGMA_GESV
     SUBROUTINE MAGMA_SGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) BIND(C, NAME='MAGMA_SGESV')
     USE ISO_C_BINDING
     IMPLICIT NONE
     INTEGER(C_INT), INTENT(IN) :: N, NRHS, LDA, LDB
     INTEGER(C_INT), INTENT(OUT) :: INFO
     REAL(C_FLOAT), DIMENSION(LDA, N), INTENT(INOUT) :: A
     REAL(C_FLOAT), DIMENSION(LDB, NRHS), INTENT(INOUT) :: B
     INTEGER(C_INT), DIMENSION(N), INTENT(OUT) :: IPIV
     END SUBROUTINE MAGMA_SGESV

     SUBROUTINE MAGMA_DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) BIND(C, NAME='MAGMA_DGESV')
     USE ISO_C_BINDING
     IMPLICIT NONE
     INTEGER(C_INT), INTENT(IN) :: N, NRHS, LDA, LDB
     INTEGER(C_INT), INTENT(OUT) :: INFO
     REAL(C_DOUBLE), DIMENSION(LDA, N), INTENT(INOUT) :: A
     REAL(C_DOUBLE), DIMENSION(LDB, NRHS), INTENT(INOUT) :: B
     INTEGER(C_INT), DIMENSION(N), INTENT(OUT) :: IPIV
     END SUBROUTINE MAGMA_DGESV
END INTERFACE MAGMA_GESV

n = 100
nrhs = 1
lda = n
ldb = n

ALLOCATE(A(lda,n), B(ldb,nrhs), ipiv(n), X(ldb,nrhs), STAT=errstat, ERRMSG=errmesg)
IF(errstat/=0) WRITE(*,*) 'Error allocating variables. Code:', errstat, 'Message:', errmesg

CALL RANDOM_SEED()
DO ii = 1, lda
     DO jj = 1, n
          CALL RANDOM_NUMBER(A(ii,jj))
     END DO
END DO
DO ii = 1, ldb
     DO jj = 1, nrhs
          CALL RANDOM_NUMBER(B(ii,jj))
     END DO
END DO

CALL CUBLAS_INIT()

X = B

CALL MAGMA_GESV(n, nrhs, A, lda, ipiv, B, ldb, errstat)
IF(errstat /=0) WRITE(*,*) 'Error with MAGMA_GESV. Code: ', errstat

CALL CUBLAS_SHUTDOWN()
DEALLOCATE(A, B, ipiv, X, STAT=errstat, ERRMSG=errmesg)
IF(errstat/=0) WRITE(*,*) 'Error deallocating variables. Code:', errstat, 'Message:', errmesg
END PROGRAM magmatest


Thank you for any help you can provide.
-DNA
dna
 
Posts: 2
Joined: Mon Jun 04, 2012 11:42 am
Location: Cincinnati, Ohio

Re: Installation cannot find magma or magmablas libraries

Postby fletchjp » Sun Jul 01, 2012 5:25 pm

I had noticed your query and the lack of a reply. I am not part of the MAGMA team, but have used MAGMA versions for some time and I have Ubuntu 10.4.

I have always kept magma in my user filestore and never put it into /usr/local so my setup is different.

I have CUDA installed where it defaults. To enable MAGMA to find nvcc I usually have this in the make.inc

Code: Select all
CUDADIR=/usr/local/cuda
NVCC=$(CUDADIR)/bin/nvcc


I am not sure why you cannot find the magma and magmablas libraries. In my installation the testing directory is in the same tree as the magma libraries, but it may not be for your setup.

I don't know if you are familiar with this way of specifying a directory so that dynamic libraries are found at run time:

Code: Select all
CUDAFLAGS=-Xlinker -R/usr/local/cuda/lib


I use this to avoid having to worry about setting
Code: Select all
LD_LIBRARY_PATH
and to support different versions in the same makefile.

I hope this helps.

John
fletchjp
 
Posts: 170
Joined: Mon Dec 27, 2010 7:29 pm

Re: Installation cannot find magma or magmablas libraries

Postby dna » Thu Jul 12, 2012 4:18 pm

I did find a way around my problems. First I upgraded to Ubuntu 12.04 LTS, CUDA Toolkit 4.1, the latest GPU drivers, and then I was able to install MAGMA-1.2.1.

You have to use the 4.5 versions of gcc and gfortran because the CUDA toolkit hasn't fixed its procedures to use 4.6 (which is the current version in the Ubuntu repositories for Pangolin). I also had to create soft links in the cuda installation folder for gcc-4.5, g++-4.5, and gfortran-4.5. Using "sudo make" still doesn't work correctly so I think I had to go into super user mode by doing "sudo su" (the other three sudo options didn't work either: sudo -i make, sudo bash). I also had to link to cudart and lapack. I installed everything and the testing programs work so I assume everything is working.
If I can get my programs to work using MAGMA, I don't plan on fooling around with the installation again. Now just to get the correct gfortran compiling and linking flags

Thanks for your reply John
-dna




Here is my new make.inc:

Code: Select all
#//////////////////////////////////////////////////////////////////////////////
#   -- MAGMA (version 1.2.1) --
#      Univ. of Tennessee, Knoxville
#      Univ. of California, Berkeley
#      Univ. of Colorado, Denver
#      June 2012
#//////////////////////////////////////////////////////////////////////////////

#
# GPU_TARGET specifies for which GPU you want to compile MAGMA:
#     "Tesla" (NVIDIA compute capability 1.x cards)
#     "Fermi" (NVIDIA compute capability 2.x cards)
# See http://developer.nvidia.com/cuda-gpus

GPU_TARGET = Fermi

CC        = gcc-4.5
NVCC      = nvcc
FORT      = gfortran-4.5

ARCH      = ar
ARCHFLAGS = cr
RANLIB    = ranlib

OPTS      = -O3 -DADD_
F77OPTS   = -O3 -DADD_
FOPTS     = -O3 -DADD_ -x f95-cpp-input
NVOPTS    = -O3 -DADD_ --compiler-options -fno-strict-aliasing -DUNIX
LDOPTS    = -fPIC -Xlinker -zmuldefs

LIB       = -lblas -latlas -lcublas -lcudart -llapack -lm

CUDADIR   = /usr/local/cuda

LIBDIR    = -L$(CUDADIR)/lib64
INC       = -I$(CUDADIR)/include
dna
 
Posts: 2
Joined: Mon Jun 04, 2012 11:42 am
Location: Cincinnati, Ohio

Re: Installation cannot find magma or magmablas libraries

Postby fletchjp » Sat Jul 14, 2012 3:06 am

Thank you for your thanks.

What you say is useful information for me. I am considering upgrading to Ubuntu 12.04 to stay compatible with what other people are using, and you say that there are some compatibility problems and what they are. That is very helpful.

Best wishes

John
fletchjp
 
Posts: 170
Joined: Mon Dec 27, 2010 7:29 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 1 guest