simonzhang00 / ripser-plusplus

Ripser++: GPU-accelerated computation of Vietoris–Rips persistence barcodes
MIT License
98 stars 14 forks source link

Can we run this library in google colab #1

Open sohailiqbal opened 3 years ago

sohailiqbal commented 3 years ago

Is it possible to run this library in google colab.

simonzhang00 commented 3 years ago

Yes, as long as Google colab will allow you to run the commands git, cmake, apt, make, nvcc, python3, pip3 etc you can build as you would on a local machine.

Building from source is very consistent. This is how you would install the python bindings of ripser++ in Google colab:

  1. To use GPU on Google Colab, create a new notebook. Then runtime-> change runtime type-> GPU

  2. In this fresh notebook, run the command !pwd. It should say /content. If not, then run:

import os
os.chdir('/content')
  1. clone the repository:
    !git clone https://github.com/simonzhang00/ripser-plusplus.git'
  2. install cmake:
    !apt update
    !apt install -y cmake
  3. build the .so file (this is what gets executed when you run python code on top of ripser++)
    import os
    os.chdir('/content/ripser-plusplus/python/bin')
    !pwd
    !cmake /content/ripser-plusplus/python && make
  4. install ripser++ for python
    !pip3 install /content/ripser-plusplus/python/
  5. To run the examples.py file run:
    import os
    os.chdir('/content/ripser-plusplus/python/working_directory')
    !pwd`
    !python3 "examples.py"

    Don't forget, if you want to remove verbosity, uncomment the two lines:

    #define PROFILING
    #define COUNTING

    from ripser++.cu and don't forget that uncommenting

    #define ASSEMBLE_REDUCTION_SUBMATRIX 

    may give better performance.

Here is gist of the above instructions: Google colab gist

Good luck and have fun!

IbtihalFerwana commented 3 years ago

Hello, thanks for the guide.

at step 5, I face the issue that folder /python is not created in ripser-plusplus. Any hints in that? FileNotFoundError: [Errno 2] No such file or directory: '/ripser-plusplus/python/bin'

simonzhang00 commented 3 years ago

These instructions are old, ripser++ has been updated. To install ripser++ just use: pip3 install ripserplusplus or pip3 install git+https://github.com/simonzhang00/ripser-plusplus or clone the repository and follow the instructions in the main README.md.

sava-1729 commented 2 years ago

pip3 install ripserplusplus

Hello, This still doesn't seem to work. Please check the notebook below for details: https://github.com/sava-1729/practice/blob/master/ripser.ipynb

Edit: One needs to enable GPU in the notebook menu: Runtime -> Change Runtime Type -> Hardware Accelerator -> GPU And after that it gets installed perfectly. Check the notebook below for details: https://github.com/sava-1729/practice/blob/master/ripser_with_gpu.ipynb