Deep-MI / FastSurfer

PyTorch implementation of FastSurferCNN
Apache License 2.0
455 stars 119 forks source link

could not install on ubuntu 18.04 due to LaPy error #123

Closed pieper closed 2 years ago

pieper commented 2 years ago

Description

The pip install step failed with this error:

Collecting lapy@ git+https://github.com/Deep-MI/LaPy.git (from -r requirements.txt (line 19))
  Could not find a version that satisfies the requirement lapy@ git+https://github.com/Deep-MI/LaPy.git (from -r requirements.txt (line 19)) (from versions: )
No matching distribution found for lapy@ git+https://github.com/Deep-MI/LaPy.git (from -r requirements.txt (line 19))

Steps to Reproduce

Starting with a fresh 18.04 instance running on a google cloud VM.

sudo apt-get install python3-pip
git clone https://github.com/Deep-MI/FastSurfer.git
cd FastSurfer/
pip3 install -r requirements.txt 

Results in the error above.

Expected Behavior

I'd like to be able to run on this or a similar OS on a VM.

Environment

This is the most recent commit of FastSurfer.

commit 6724ae0039621282dd72523d167db2fb6e12d708 (HEAD -> master, origin/master, origin/HEAD)
Merge: 98bda9c cb85b6f
Author: LeHenschel <31760921+LeHenschel@users.noreply.github.com>
Date:   Fri Mar 18 11:00:50 2022 +0100

    Merge pull request #122 from Deep-MI/fix-sphere_reg

    Fix for missing label directory in sphere reg fix
m-reuter commented 2 years ago

Hmm, we'll take a look. In the meantime you could try conda instead (similar to how we do it in the docker): https://github.com/Deep-MI/FastSurfer/blob/6724ae0039621282dd72523d167db2fb6e12d708/Docker/Dockerfile

pieper commented 2 years ago

Thank you for the quick response 👍

I tried:

pip3 install numpy
pip3 install cython
python3 -m pip install -U git+https://github.com/Deep-MI/LaPy.git#egg=lapy

but ended up with this error:

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Isksparse -I/home/pieper/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include -I/usr/include/suitesparse -I/usr/include/python3.6m -c sksparse/cholmod.c -o build/temp.linux-x86_64-3.6/sksparse/cholmod.o
    In file included from /home/pieper/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
                     from /home/pieper/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /home/pieper/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from sksparse/cholmod.c:713:
    /home/pieper/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it with " \
      ^~~~~~~
    In file included from sksparse/cholmod.c:718:0:
    sksparse/cholmod_backward_compatible.h:1:10: fatal error: cholmod.h: No such file or directory
     #include "cholmod.h"
              ^~~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ltmn0c_6/scikit-sparse/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-m_o2fi56-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-ltmn0c_6/scikit-sparse/

I'll try using the docker version for now as a workaround.

LeHenschel commented 2 years ago

Hey,

the error occurs because scikit-sparse needs numpy and scipy pre-installed. Scikit-sparse is a dependency in lapy. If you install it with pip like this, it should work:

python3 -m pip install setuptools # (if not pre-installed inside the virtualenv)
python3 -m pip install numpy scipy cython
python3 -m pip install -U git+https://github.com/Deep-MI/LaPy.git#egg=lapy
python3 -m pip install -r requirements.txt # other FastSurfer requirements

or alternatively for FastSurfer as a whole:

  1. Change the lapy line in the requirements.txt to git+https://github.com/Deep-MI/LaPy.git#egg=lapy
  2. Install setuptools, numpy, scipy and cython
    python3 -m pip install setuptools # (if not pre-installed inside the virtualenv)
    python3 -m pip install numpy scipy cython
  3. Install FastSurfer dependencies via requirements.txt
    python3 -m pip install -r requirements.txt
pieper commented 2 years ago

Thanks for your help with this.

If I run this the lapy build works:

python3 -m pip install setuptools
python3 -m pip install numpy scipy
python3 -m pip install -U git+https://github.com/Deep-MI/LaPy.git#egg=lapy

But this in requirements.txt

lapy @ git+https://github.com/Deep-MI/LaPy.git#egg=lapy

still leads to this error

Collecting lapy@ git+https://github.com/Deep-MI/LaPy.git#egg=lapy (from -r requirements.txt (line 19))
  Could not find a version that satisfies the requirement lapy@ git+https://github.com/Deep-MI/LaPy.git#egg=lapy (from -r requirements.txt (line 19)) (from versions: )
No matching distribution found for lapy@ git+https://github.com/Deep-MI/LaPy.git#egg=lapy (from -r requirements.txt (line 19))

If I install lapy outside of requirements.txt and then comment it out of requirements.txt the rest installs fine.

Once I do that it seems to be running fine. I was able to use the docker version, so the native install isn't critical for me, but I'll leave this open in case someone knows how to fix the requirements.txt.

m-reuter commented 2 years ago

We have updated LaPy (see https://github.com/Deep-MI/LaPy/pull/7 ) and removed the scikit-sparse requirement there to avoid setting off pip. Installing with conda should have worked. If users want to use the faster Cholmod method, they need to install scikit-sparse in a separate step after numpy and scipy. Otherwise the code will fall back to LU decomposition which is a little slower. FastSurfer currently always request LU decomposition for consistency and to remove the indirect scikit-sparse dependency (see #124 ).

af-a commented 2 years ago

The requirements.txt issue might be resolved by upgrading your pip version (for e.g. using pip install --upgrade pip).

I could only reproduce the error with a fairly old pip version (9.0.1). It seems like the older versions somehow do not support the syntax used in the line:

lapy @ git+https://github.com/Deep-MI/LaPy.git#egg=lapy
pieper commented 2 years ago

Yes, I used the default python3-pip for ubuntu 18.04.

$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
m-reuter commented 2 years ago

The problem is that the requirements file gets automatically created, so I think we do not have a way to change that line to be compatible to older pip versions? This means users have to upgrade their pip ? If that (and the merge above) fixes it, we can close this issue.

pieper commented 2 years ago

Yes, probably it's enough to specify in the readme a minimum version of pip that must be used. I don't know if it's possible, but it seems like you should be able to specify the pip version in requirements.txt.

m-reuter commented 2 years ago

I think that will not work, as the pip version in requirements is going to be installed together with all other requirements (so they are installed by the old version of pip). I added text to readme that one should first upgrade pip.