Skip to content

Instantly share code, notes, and snippets.

@aeantipov
Last active May 18, 2019 17:31
Show Gist options
  • Save aeantipov/3839d09529cb5dd2cedc00b76ccd2eb8 to your computer and use it in GitHub Desktop.
Save aeantipov/3839d09529cb5dd2cedc00b76ccd2eb8 to your computer and use it in GitHub Desktop.
Kwant WSL installation

Kwant WSL (Linux subsytem for Windows) installation

Prerequisites for installation: Windows 10 (updates after September 2016) and Linux subsystem for windows. Linux subsystem is in fact Ubuntu 14.04 Trusty, so the instructions are similar. One could in fact use ubuntu instructions (via sudo apt-get install python3-numpy or pip3 install numpy), but the performance would be suboptimal. In order to get optimal perfomance, one needs to compile LAPACK libraries and numpy/scipy. Two ways are possible: manual installation and package manager (spack).

Spack installation

This way of installation has not been tested, but should be easier to do. Since we don't need binaries and ubuntu trusty is old, one needs a source package manager. One possible choice is spack - it gives a user installed packages complimentary to the system package manager. The steps are

  1. Get spack (https://github.com/LLNL/spack)
export SPACK_ROOT=${HOME}/spack
. $SPACK_ROOT/share/spack/setup-env.sh
  • reload shell
spack install openblas
spack install [email protected] py-numpy py-scipy
  1. (Optional : get mumps and scotch)

    spack install scotch ~mpi
    spack install mumps +scotch ~mpi ~ptscotch 
    
  2. Get kwant:

[lapack]
libraries = openblas gfortran
library_dirs = OPENBLAS_DIR/lib
extra_link_args = -Wl,-rpath=OPENBLAS_DIR/lib

[mumps]
libraries = zmumps mumps_common mpiseq pord scotchmetis esmumps scotch scotcherr scotcherrexit metis gfortran
library_dirs = MUMPS_DIR/lib SCOTCH_DIR/lib/ METIS_DIR/lib
include_dirs = MUMPS_DIR/include SCOTCH_DIR/include
extra_link_args = -Wl,-rpath=SCOTCH_DIR/lib
  • the paths for openblas, mumps and scotch need to be looked up with spack find -p mumps (same for scotch, openblas and metis & scalapack if installed)
  • spack load [email protected]
  • python3.5 setup.py build
  • python3.5 setup.py install

Manual installation (tested)

Steps:

  1. Install python3.5 : (https://www.reddit.com/r/IPython/comments/3lf81w/using_python35_in_ubuntu_trusty/):
  • sudo add-apt-repository ppa:fkrull/deadsnakes
  • sudo apt-get update
  • sudo apt-get install python3.5 python3.5-dev libpython3.5-dev
  1. Install pip (https://pip.pypa.io/en/stable/installing/):
  1. Install openblas:
  1. Install numpy/scipy:
  • sudo apt-get install libfftw3-dev libumfpack5.7.1 libamd2.3.1 (the versions might be different)
  • Download .tar.gz archives from http://www.scipy.org/scipylib/download.html
  • untar them (in my case these are numpy-1.11.2 and scipy-0.18.1 dirs)
  • numpy:
    • cd numpy-1.11.2
    • edit site.cfg (openblas might be OpenBLAS):
      # numpy site.cfg
      [amd]
      amd_libs = amd
      
      [umfpack]
      umfpack_libs = umfpack
      
      [fftw]
      libraries = fftw3
      
      [default]
      include_dirs = /opt/openblas/include
      library_dirs = /opt/openblas/lib
      
      [openblas]
      openblas_libs = openblas
      library_dirs = /opt/openblas/lib
      
      [lapack]
      lapack_libs = openblas
      library_dirs = /opt/openblas/lib
      
    • python3.5 setup.py build
    • sudo python3.5 setup.py install
  • scipy: very similar
    • cd scipy-0.18.1
    • copy site.cfg from numpy
    • python3.5 setup.py build
    • sudo python3.5 setup.pu install
  1. At this moment one can install kwant without mumps:
[lapack]
libraries = openblas gfortran
library_dirs = /opt/openblas/lib
extra_link_args = -Wl,-rpath=/opt/openblas/lib
  • python3.5 setup.py build
  • sudo python3.5 setup.py install
  1. For kwant installation with mumps - look the last step of spack installation.
@citibeth
Copy link

@aeantipov I know this page is a little old... do you have direct experience using Spack with WSL? Do you know if it makes a difference on WSL-1 vs. WSL-2? Thanks!

@aeantipov
Copy link
Author

Indeed this is rather old. I used spack at the days, when conda was in youth. Unfortunately I can't say anything about wsl-1 vs wsl-2 and spack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment