Cholmod is a powerful package for sparse matrix calculation and Scikit-Sparse is a python interface. It is convenient to set up the Cholmod and Scikit-Sparse (CSC) environment in Linux and Mac OS, but it may be troublesome in Windows. Thanks to jlblancoc's package suitesparse-metis-for-windows, I make a modification for the python interface. Here are the instructions.
It takes two steps to set up the CSC environment.
- Compile the
*.h
,*.lib
and*.dll
files of Cholmod. It can be included and linked for C/C++. - Compile the python package Scikit-Sparse.
This repository has been tested on
- Windows 10 64bit
- Anaconda 3
- Microsoft Visual C++ 17
This repository is not applicable to Python 2 (Anaconda 2) on Windows 10. Because in the Step II, compiling C codes for Python 2 requires VC 9.0 (VS 2008), which can not be installed on Windows 10. The compiler used in the Step I is supposed to be the same as the one used in the Step II.
Because metis package has many errors when compiling, I removed the metis package and modified the CSC_ROOT/CMakeLists.txt
.
- Microsoft Visual Studio 2017 including VC 14 (VS 2015 may be Ok). C++ compiler tools are required. You can add them by the Stack Overflow post.
- Anaconda 3.6 64bit including numpy and scipy.
- Download CMake.
- Clone or Download this repository, say
CSC_ROOT
. If you require the latest version, just download them and merge them with the target folders.- suitesparse-metis-for-windows version: 1.3.1
- scikit-sparse version: 0.4.4. If you replace it by a new package, don't forget to modify the
setup.py
to link the headers and libraries. - SuiteSparse version: 5.3.0. It is under the
suitesparse-metis-for-windows-1.3.1/
- Run CMake, then:
- Set the "Source code" folder to
CSC_ROOT/suitesparse-metis-for-windows-1.3.1
. - Set the "Build the binaries" folder to
CSC_ROOT/suitesparse-metis-for-windows-1.3.1/build
. - Click "Configure" and select "Visual Studio 15 2017 Win64" (for 64bit OS). Tips: Make sure to build in x64 mode. "HAVE_COMPLEX" is not recommended.
- Click "Generate".
- Click "Open Project" to open the "SuiteSparseProject" solution.
- Set the "Source code" folder to
- In Visual Studio, build the "INSTALL" project in "Release" mode. It may show hundreds of warnings, but it's OK. (Note: according to this issue#2 report, select "Release" mode is necessary in case of missing
cholmod.lib
.) CSC_ROOT/suitesparse-metis-for-windows-1.3.1/build/install
contains the generated libraries.*.h
header files are inCSC_ROOT/suitesparse-metis-for-windows-1.3.1/build/install/include/suitesparse
*.lib
libraries are inCSC_ROOT/suitesparse-metis-for-windows-1.3.1/build/install/lib64
andCSC_ROOT/suitesparse-metis-for-windows-1.3.1/build/install/lib64/lapack_blas_windows
*.dll
dynamic libraries are inCSC_ROOT/suitesparse-metis-for-windows-1.3.1/build/install/lib64/lapack_blas_windows
.
- Now, the Cholmod package has been set up for C/C++.
- Open "PowerShell" and type
cd scikit-sparse-0.4.4
. - Type
python setup.py build
to compile the package. Thesetup.py
has been modified to link the headers and libraries. - Type
python setup.py install
to copy the executable code into the Anaconda folders.
Congratulations! Everything is done! In python command. Type
from sksparse.cholmod import cholesky
If nothing happens, the installation is done! For detailed usage and test, please refer to scikit-sparse-0.4.4/sksparse/test_cholmod.py
.
Give me a star if you like this repository. Feel free to open an issue or start an pull request.