Search code examples
installationgoogle-colaboratorymetis

METIS Installation on google colab


Following this source I would like to install METIS and the Python wrapper in colab: https://github.com/james77777778/metis_python

The installation steps are listed as the following:

  1. Download and extract metis-5.1.0.tar.gz from METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering
  2. cd metis-5.1.0
  3. make config shared=1 prefix=~/.local/
  4. make install
  5. export METIS_DLL=~/.local/lib/libmetis.so
  6. pip3 install metis-python

However, I'm not sure how to do steps 2-4 in colab specifically and so I get the following error: RuntimeError: Could not locate METIS dll. Please set the METIS_DLL environment variable to its full path.

Thanks!


Solution

  • The issue seems to be the location of the libmetis.so file. Copying the file to /usr/lib and updating the path for the environmental variable successfully completes the process:

    import requests
    import tarfile
    
    # Download and extract the file
    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
    response = requests.get(url, stream=True)
    file = tarfile.open(fileobj=response.raw, mode="r|gz")
    file.extractall(path=".")
    
    # Change working directory
    %cd metis-5.1.0
    
    # The remaining steps as you have shown in the question, with updated path
    !make config shared=1 prefix=~/.local/
    !make install
    !cp ~/.local/lib/libmetis.so /usr/lib/libmetis.so
    !export METIS_DLL=/usr/lib/libmetis.so
    !pip3 install metis-python
    
    import metispy as metis