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