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

Using OSQP-Eigen with OSQP CUDA #148

Open
JTylerBoylan opened this issue Oct 9, 2023 · 2 comments
Open

Using OSQP-Eigen with OSQP CUDA #148

JTylerBoylan opened this issue Oct 9, 2023 · 2 comments

Comments

@JTylerBoylan
Copy link

I got OSQP-Eigen to build and solve when I build OSQP with its normal linear algebra library, but when I build OSQP with it's CUDA library instead, I get a compilation error for OSQP-Eigen.

Compilation Error:

/usr/bin/ld: CMakeFiles/main.dir/src/main.cpp.o: in function `bool OsqpEigen::SparseMatrixHelper::createOsqpSparseMatrix<Eigen::SparseMatrix<float, 0, int> >(Eigen::SparseCompressedBase<Eigen::SparseMatrix<float, 0, int> > const&, OSQPCscMatrix*&)':
/usr/local/include/OsqpEigen/SparseMatrixHelper.tpp:42: undefined reference to `csc_spalloc'
/usr/bin/ld: /usr/local/lib/libOsqpEigen.so.0.8.1: undefined reference to `csc_spfree'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:99: main] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Dockerfile:

FROM nvidia/cuda:12.2.0-devel-ubuntu22.04

RUN apt-get update -y

RUN apt-get install -y cmake git

RUN apt-get install -y libeigen3-dev

RUN git clone https://github.com/osqp/osqp
RUN cd osqp && mkdir build
RUN cd osqp/build && cmake -G "Unix Makefiles" .. -DOSQP_ALGEBRA_BACKEND=cuda
# RUN cd osqp/build && cmake -G "Unix Makefiles" ..
# Does not fail when using above ^
RUN cd osqp/build && cmake --build . --target install

RUN git clone https://github.com/robotology/osqp-eigen
RUN cd osqp-eigen && mkdir build
RUN cd osqp-eigen/build && cmake ..
RUN cd osqp-eigen/build && make && make install

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)
project(my_project)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(OsqpEigen REQUIRED)
find_package(Eigen3)

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})

include_directories(include)

# Add the executable
add_executable(main src/main.cpp)
target_include_directories(main PUBLIC include)
target_link_libraries(main PUBLIC stdc++ stdc++fs m OsqpEigen::OsqpEigen)
@traversaro
Copy link
Member

traversaro commented Oct 9, 2023

Thanks a lot for the issue. Just to understand, with the exact version of osqp (not some other version), just changing OSQP_ALGEBRA_BACKEND to builtin (or mkl, if you know how to install that) everything works?

@JTylerBoylan
Copy link
Author

Correct, using OSQP_ALGEBRA_BACKEND=builtin works (as well as using double types for my matrices), but cuda does not. The CUDA backend requires the use of floats instead of doubles.
I have not tried mkl.

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