Page 1 of 2

trying to build magma-2.1.0 on Windows

Posted: Sun Nov 06, 2016 10:02 am
by Fractarno
I'm currently trying to build magma-2.1.0 on Windows. My impression is that magma seems to be a great library but it takes very long to get it running on Windows. Especially it seems not easy to configure the build in the right way.

My environment is Windows 10, CUDA 7.5, Microsoft Visual Studio 11.0. I’ve downloaded LAPACK and BLAS from and the Intel Redistributable package from ... or-windows

The first problem is that on 64-bit Windows systems, 32-bit versions of the CUDA Toolkit scientific libraries, including cuBLAS, cuSPARSE, cuFFT, cuRAND, etc. are no longer supported by the CUDA toolkit for CUDA >= 7.0.

So I’ve tried to use CMAKE to configure the build with older CUDA versions (e.g. CUDA 6.5) and was somehow successful to generate a 32-bit build of the libraries! Then I’ve created an application with dense linear algebra and it runs perfectly fine, gives the right results and it is really fast!!

The bad news is, that when trying to generate a sparse linear algebra application I get linker errors like magma_sparse.lib(magma_smconverter.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_cusparseCreateIdentityPermutation@12" in Funktion "_magma_smconvert".

So I’m now trying to generate a 64bit build but I’m failing how to properly configure the build …

Are there pre-built binaries available for download? Or, at least a more detailed guideline how to configure the build in a similar environment?

Thanks for help,


Re: trying to build magma-2.1.0 on Windows

Posted: Mon Nov 07, 2016 9:11 pm
by mgates3
Why are you building a 32-bit build of MAGMA? Not that it shouldn't work, but if the other libraries are 64-bit (CUDA, BLAS, LAPACK), there's no real reason to use 32-bit.

cusparseCreateIdentityPermutation was added in CUDA 7.0. However, that call should be disabled if compiled with CUDA < 7.0. (See sparse/control/magma_zmconverter.cpp, has #if CUDA_VERSION >= 7000 around that section.)


Re: trying to build magma-2.1.0 on Windows

Posted: Sun Nov 13, 2016 5:25 pm
by Fractarno
Mark – many thanks for your reply!
The first reason going for 32 bit was that for I need to generate a 32bit dll at the end. Disabling the call you mentioned unfortunately still did not resolve the problem (there are still a lot of linker errors).

The second reason is that I’m still failing when trying to compile 64bit. I’ve tried to configure the build via cmake using the default settings (and adding the path to those 64-bit libraries which cmake didn’t find by itself):

Building without Fortran compiler
Using -DADD_ for Fortran calling convention
Found OpenMP
OpenMP_C_FLAGS /openmp
OpenMP_CXX_FLAGS /openmp
Found CUDA 7.5
CUDA_INCLUDE_DIRS: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include
CUDA_CUDART_LIBRARY: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64/cudart.lib
compile for CUDA arch 2.x (Fermi)
compile for CUDA arch 3.0 (Kepler)
compile for CUDA arch 3.5 (Kepler)
User set LAPACK_LIBRARIES. To change, edit LAPACK_LIBRARIES using ccmake (set to empty to enable search).
LAPACK_LIBRARIES: C:\Users\arno\Documents\Visual Studio 2012\Projects\magma-2.1.0\extra\cbia.lib.lapack.dyn.rel.x64.12.lib
MKLROOT not set. To change, set MKLROOT using ccmake.
NFLAGS -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_35,code=compute_35 -DADD_
FFLAGS /W1 /nologo /fpp /libs:dll /threads
LIBS tester;lapacktest;magma
LIBS_SPARSE tester;lapacktest;magma;magma_sparse
Configuring done
Generating done

Then, when opening magma.sln in Visual Studio, everything seems to be prepared for 32bit(?). I can change to 64bit and compiling works but still linking fails (it seems to me that NVCC is still compiling 32bit…?!):

CMakeFiles\magma.dir\magmablas\Release\ : fatal error LNK1112: Modul-Computertyp "X86" steht in Konflikt mit dem Zielcomputertyp "x64"

So I still would be grateful if I could get some support how to properly configure the 64-bit build in a similar environment or - even better - to get pre-built binaries available for download?

Regards Arno

Re: trying to build magma-2.1.0 on Windows

Posted: Tue Nov 15, 2016 6:28 pm
by mgates3
Are you re-running CMake with the same build directory? That might cause problems if it caches some information like the compiler to use. I would suggest creating a new build directory when making significant changes in CMake.

Otherwise, we simply follow the directions in README-Windows.

Sorry, we don't provide pre-built binaries for any OS. One reason is there are a lot of combinations of external libraries and features -- which CUDA version, CUDA architectures, C/C++/Fortran compiler, version of LAPACK / BLAS, version of Windows, 32 or 64-bit, with or without OpenMP. Any pre-built library would necessarily pick one set of those and thus be of limited use.


Re: trying to build magma-2.1.0 on Windows

Posted: Fri Nov 18, 2016 5:05 pm
by Fractarno
I’ve now created a new directory and tried the configuration “Visual Studio 11 Win64” which seems to fit to my installation (all other 64bit configurations fail). Cmake seems to find everything. However, in Visual Studio I always get the error:

nvcc fatal : Microsoft Visual Studio configuration file 'vcvars64.bat' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/../..'

What is vcvars64.bat (I couldn't find it on my system...)?

Re: trying to build magma-2.1.0 on Windows

Posted: Sat Nov 19, 2016 5:21 pm
by mgates3
Try Googling the error message; there seem to be some posts about it on programming and NVIDIA forums.

Re: trying to build magma-2.1.0 on Windows

Posted: Sun Nov 20, 2016 6:52 am
by Fractarno
In the meantime for 32bit everything works fine for me (the examples work well and I can generate my own application - but I had to go back to CUDA6.5). As I have to deliver a 32bit dll in the end, this does the job for the moment.
For 64bit I still have the same troubles, so if somebody knows how to compile with Visual Studio 11 and CUDA 7.5, any help is highly appreciated. Kind regards, Arno

Re: trying to build magma-2.1.0 on Windows

Posted: Sun Dec 11, 2016 5:24 am
by Fractarno
After some upgrades (Visual Studio Community 2015 / CMake 3.7.1 / magma-2.2.0 / cuda 8.0) I’ve now finally (!) been successful compiling the 64bit Version of magma on Windows. :)
Maybe it is of interest to note that:

CMake was always started from the VS2015 x64 Native Tools Command Prompt.
For clapack and magma I’ve used the configuration: Visual Studio 14 2015 64bit

Since I don’t use Fortran, I’ve downloaded the clapack version from ... -CMAKE.tgz and compiled it with Visual Studio 14 2015 64bit (all prebuilt libraries I’ve tried always resulted in linking errors – maybe due to the absence of fortran libraries on my system …?!).

Important was changing the C Flags from /MD to /MT (otherwise I got a linking error: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'…obviously because the cuda-objects were built differently than the CXX objects)
Lapack libraries: I’ve included blas.lib, lapack.lib and also tmglib.lib and libf2c.lib

Building my own application:
I’ve started with an empty project and then (after adding the include paths to magma and adding magma-libs and lapack-libs) I consequently changed Code Generation to Multi-threaded (/MT). Additionally I’ve added some Preprocessor definitions (copied from the examples): WIN32;_CRT_SECURE_NO_WARNINGS;_WINDOWS;ADD_;MAGMA_NOAFFINITY;HAVE_CUBLAS;MIN_CUDA_ARCH=200;

That was quite an effort!
However with these changes and updates everything worked very well (all libraries, tests, and also my own application … and for large matrices it is really a benefit going for 64bit).

Regards Arno

Re: trying to build magma-2.1.0 on Windows

Posted: Sat Feb 25, 2017 12:03 am
by Manuel__
I am also trying to build magma in windows, without success so far.

I wonder, would it be possible for me to obtain the magma.lib and magma-sparse.lib files that you have managed to create?

They are too big to pass as email attachments, but maybe through ftp ? I am sure other people would be interested as well.

Many thanks in advance

Re: trying to build magma-2.1.0 on Windows

Posted: Sun Feb 26, 2017 6:59 pm
by mgates3
Were there particular problems that you encountered in building MAGMA, using the directions in README-Windows?