Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on raspberrypi #35

Closed
hylkedonker opened this issue Jan 28, 2021 · 7 comments
Closed

Compile error on raspberrypi #35

hylkedonker opened this issue Jan 28, 2021 · 7 comments

Comments

@hylkedonker
Copy link

Hi,

I am trying to install a python package, which depends on osqp, which in turn depends on qdldl. However, I can not get it to compile in my Docker container on Raspberry Pi.
I get the following error:

      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ic -Ic/qdldl/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/include/python3.8 -c cpp/wrapper.cpp -o build/temp.linux-armv7l-3.8/cpp/wrapper.o -O3 -std=c++11
      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ic -Ic/qdldl/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/include/python3.8 -c cpp/qdldl.cpp -o build/temp.linux-armv7l-3.8/cpp/qdldl.o -O3 -std=c++11
      cpp/qdldl.cpp: In constructor ‘qdldl::Solver::Solver(QDLDL_int, QDLDL_int*, QDLDL_int*, QDLDL_float*)’:
      cpp/qdldl.cpp:34:41: error: cannot convert ‘QDLDL_int*’ {aka ‘int*’} to ‘const long long int*’
         34 |  QDLDL_int amd_status = amd_l_order(nx, Ap, Ai, P, NULL, NULL);
            |                                         ^~
            |                                         |
            |                                         QDLDL_int* {aka int*}
      In file included from cpp/qdldl.hpp:3,
                       from cpp/qdldl.cpp:1:
      c/amd/include/amd.h:63:28: note:   initializing argument 2 of ‘long long int amd_l_order(long long int, const long long int*, const long long int*, long long int*, c_float*, c_float*)’
         63 |     const SuiteSparse_long Ap [ ],
            |     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

I suspect this is related to Raspberry Pi's ARM architecutre, because on my local 64bit Ubuntu machine I experience no problem. To reproduce, my Dockerfile is as follows:

FROM ubuntu:20.10
ARG DEBIAN_FRONTEND=noninteractive

# Install binary packages so that not all pip packages have to be rebuilt.
RUN apt update -qq && \
        apt install -y -qq \
        python3-pip \
        python3-dev \
        python3-setuptools \
        python3-wheel \
        python3-numpy \
        python3-scipy \
	python3-cvxopt \
	python3-joblib

# Instal libraries for compiling from source.
RUN apt update -qq && \
        apt install -y -qq \
        libblas3 \
        liblapack3 \
        liblapack-dev \
        libblas-dev \
        gfortran \
        libatlas-base-dev \
        cmake \
        g++

RUN pip3 install osqp

Any thoughts how to resolve this?

Thanks,

Hylke

@goulart-paul
Copy link
Collaborator

I think the issue is that it is trying to compile OSQP and QDLDL with the -DDLONG = TRUE (the default), which is maybe not supported on the 32 bit platform you are using. You could try compiling OSQP with -DDLONG = FALSE (and maybe also -DFLOAT = TRUE). You might have to do this directly from the OSQP source using CMAKE.

@hylkedonker
Copy link
Author

Thanks for your prompt response. I added the line

cmake_args += ["-DDLONG=FALSE", "-DFLOAT=TRUE"]

to the setup.py file (I also tried only the -DDLONG=FALSE flag), but it did not resolve the compilation error. Neither was changing FALSE=>OFF and TRUE=>ON. Do you have any other suggestions in mind?
Thanks!
Hylke

@goulart-paul
Copy link
Collaborator

Could you post verbose output from CMAKE so we can see what options you are getting?

@hylkedonker
Copy link
Author

Yes, the complete output is:

$ python3 setup.py install
Disabling LONG
Remove long integers for numpy compatibility. See:
 - https://github.com/numpy/numpy/issues/5906
 - https://github.com/ContinuumIO/anaconda-issues/issues/3823
You can reenable long integers by passing: --osqp --long argument.

  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-orhqnmrb/qdldl/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-orhqnmrb/qdldl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-4o98ziee
       cwd: /tmp/pip-wheel-orhqnmrb/qdldl/
  Complete output (72 lines):
  running bdist_wheel
  running build
  running build_ext
  -- The C compiler identification is GNU 10.2.0
  -- The CXX compiler identification is GNU 10.2.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Floats are OFF
  -- Disabling long integers (64bit) on 32bit machine
  -- Long integers (64bit) are OFF
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-wheel-orhqnmrb/qdldl/c/build
  gmake[1]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  gmake[2]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  gmake[3]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  Scanning dependencies of target qdldlobject
  gmake[3]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  gmake[3]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  [  6%] Building C object qdldl/CMakeFiles/qdldlobject.dir/src/qdldl.c.o
  gmake[3]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  [  6%] Built target qdldlobject
  gmake[3]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  Scanning dependencies of target qdldlamd
  gmake[3]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  gmake[3]: Entering directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  [ 13%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_1.c.o
  [ 20%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_2.c.o
  [ 26%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_aat.c.o
  [ 33%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_control.c.o
  [ 40%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_defaults.c.o
  [ 46%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_info.c.o
  [ 53%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_order.c.o
  [ 60%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_post_tree.c.o
  [ 66%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_postorder.c.o
  [ 73%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_preprocess.c.o
  [ 80%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_valid.c.o
  [ 86%] Building C object CMakeFiles/qdldlamd.dir/amd/src/SuiteSparse_config.c.o
  [ 93%] Building C object CMakeFiles/qdldlamd.dir/amd/src/perm.c.o
  [100%] Linking C static library out/libqdldlamd.a
  gmake[3]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  [100%] Built target qdldlamd
  gmake[2]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  gmake[1]: Leaving directory '/tmp/pip-wheel-orhqnmrb/qdldl/c/build'
  building 'qdldl' extension
  creating build
  creating build/temp.linux-armv7l-3.8
  creating build/temp.linux-armv7l-3.8/cpp
  arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ic -Ic/qdldl/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/include/python3.8 -c cpp/wrapper.cpp -o build/temp.linux-armv7l-3.8/cpp/wrapper.o -O3 -std=c++11
  arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ic -Ic/qdldl/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/local/lib/python3.8/dist-packages/pybind11/include -I/usr/include/python3.8 -c cpp/qdldl.cpp -o build/temp.linux-armv7l-3.8/cpp/qdldl.o -O3 -std=c++11
  cpp/qdldl.cpp: In constructor ‘qdldl::Solver::Solver(QDLDL_int, QDLDL_int*, QDLDL_int*, QDLDL_float*)’:
  cpp/qdldl.cpp:34:41: error: cannot convert ‘QDLDL_int*’ {aka ‘int*’} to ‘const long long int*’
     34 |  QDLDL_int amd_status = amd_l_order(nx, Ap, Ai, P, NULL, NULL);
        |                                         ^~
        |                                         |
        |                                         QDLDL_int* {aka int*}
  In file included from cpp/qdldl.hpp:3,
                   from cpp/qdldl.cpp:1:
  c/amd/include/amd.h:63:28: note:   initializing argument 2 of ‘long long int amd_l_order(long long int, const long long int*, const long long int*, long long int*, c_float*, c_float*)’
     63 |     const SuiteSparse_long Ap [ ],
        |     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for qdldl
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/setuptools/installer.py", line 128, in fetch_build_egg
    subprocess.check_call(cmd)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpbl53r0dr', '--quiet', 'qdldl']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "setup.py", line 262, in <module>
    setup(name='osqp',
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 162, in setup
    _install_setup_requires(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 157, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 699, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 779, in resolve
    dist = best[req.key] = env.best_match(
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1064, in best_match
    return self.obtain(req, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1076, in obtain
    return installer(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 758, in fetch_build_egg
    return fetch_build_egg(self, req)
  File "/usr/lib/python3/dist-packages/setuptools/installer.py", line 130, in fetch_build_egg
    raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpbl53r0dr', '--quiet', 'qdldl']' returned non-zero exit status 1.

I hope this helps.

@goulart-paul
Copy link
Collaborator

It seems like you probably have the same problem as this one : osqp/qdldl-python#15.

Suggestion there is to try OSQP version < 0.6.2.

@hylkedonker
Copy link
Author

Thanks, that seems to do the trick!

@goulart-paul
Copy link
Collaborator

Thanks for confirming. In that case I will close this and we will just keep it live in the qdldl-python repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants