PyLops / pylops

PyLops – A Linear-Operator Library for Python
https://pylops.readthedocs.io
GNU Lesser General Public License v3.0
430 stars 102 forks source link

build: added separate requirement file for torch #599

Closed mrava87 closed 2 months ago

mrava87 commented 3 months ago

Closes https://github.com/PyLops/pylops/issues/597 by adding a requirements-torch.txt file that installs PyTorch from a specific index.

We have also simplified the GA installation process removing unneeded if [ -f requirements.txt ]; then pip install -r requirements-dev.txt; fi, simply installing all dependencies as follows:

pip install -r requirements-dev.txt
pip install -r requirements-torch.txt
mrava87 commented 3 months ago

@cako can you check that this is doing what you suggested 😄

mrava87 commented 3 months ago

Alright!

Let me give it a try. I assume you mean that if I run the pip install command with requirements-torch.txt after that with requirements.txt, the only extra package that should be installed is torch (otherwise any of the other will come from this index instead of the official PyPI?)

mrava87 commented 2 months ago

@cako I finally got some time to go back to this.. I tried the following:

conda create -n pylops_torchafter python=3.11
pip install -r requirements-dev.txt
pip install install -r requirements-torch.txt 

and from the latter command I get:

(pylops_torchafter) KL-23637:pylops ravasim$ pip install -r requirements-torch.txt 
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu
Collecting torch>=1.2.0 (from -r requirements-torch.txt (line 2))
  Using cached https://download.pytorch.org/whl/cpu/torch-2.4.0-cp311-none-macosx_11_0_arm64.whl (62.1 MB)
Requirement already satisfied: filelock in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from torch>=1.2.0->-r requirements-torch.txt (line 2)) (3.15.4)
Requirement already satisfied: typing-extensions>=4.8.0 in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from torch>=1.2.0->-r requirements-torch.txt (line 2)) (4.12.2)
Requirement already satisfied: sympy in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from torch>=1.2.0->-r requirements-torch.txt (line 2)) (1.13.2)
Collecting networkx (from torch>=1.2.0->-r requirements-torch.txt (line 2))
  Using cached networkx-3.3-py3-none-any.whl.metadata (5.1 kB)
Requirement already satisfied: jinja2 in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from torch>=1.2.0->-r requirements-torch.txt (line 2)) (3.1.4)
Collecting fsspec (from torch>=1.2.0->-r requirements-torch.txt (line 2))
  Using cached fsspec-2024.6.1-py3-none-any.whl.metadata (11 kB)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from jinja2->torch>=1.2.0->-r requirements-torch.txt (line 2)) (2.1.5)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /opt/anaconda3/envs/pylops_torchafter/lib/python3.11/site-packages (from sympy->torch>=1.2.0->-r requirements-torch.txt (line 2)) (1.3.0)
Using cached fsspec-2024.6.1-py3-none-any.whl (177 kB)
Using cached networkx-3.3-py3-none-any.whl (1.7 MB)
Installing collected packages: networkx, fsspec, torch

I think this looks good to go, do you agree?

mrava87 commented 2 months ago

@cako checking that you saw this.. if you agree, I would like to merge this PR?