ripser-plusplus icon indicating copy to clipboard operation
ripser-plusplus copied to clipboard

Can we run this library in google colab

Open sohailiqbal opened this issue 4 years ago • 4 comments

Is it possible to run this library in google colab.

sohailiqbal avatar Dec 08 '20 18:12 sohailiqbal

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'
  1. install cmake:
!apt update
!apt install -y cmake
  1. 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
  1. install ripser++ for python
!pip3 install /content/ripser-plusplus/python/
  1. 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!

simonzhang00 avatar Dec 08 '20 23:12 simonzhang00

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'

IbtihalFerwana avatar Jun 01 '21 21:06 IbtihalFerwana

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.

simonzhang00 avatar Jun 01 '21 21:06 simonzhang00

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

sava-1729 avatar Dec 24 '21 08:12 sava-1729