Gurobi cannot compile with CUDA
AnsweredI can use standalone c++ codes with Gurobi on my linux machine.
I am trying to use Gurobi in a project which uses CUDA and has some .cu files
However all the Gurobi code is in .cpp file and I am compiling using the flags I use for my standalone codes.
The command is:
g++ -I/opt/gurobi912/linux64/include/ -I/usr/local/cuda/include -L/opt/gurobi912/linux64/lib -lgurobi_c++ -lgurobi91 -c helper.cpp -o ../o/helper.o
(helper.cpp) is the file with a function that uses Gurobi.
I get an error during compilation with undefined reference to every Gurobi class object.
helper.cpp:(.text+0x1ec): undefined reference to `GRBEnv::GRBEnv(bool)'
helper.cpp:(.text+0x20c): undefined reference to `GRBModel::GRBModel(GRBEnv const&)'
helper.cpp:(.text+0x258): undefined reference to `GRBVar::GRBVar()'
helper.cpp:(.text+0x2b5): undefined reference to `GRBVar::GRBVar()'
and so on..
Please help, the error seems to occur only when I have cuda APIs somewhere in my code.
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Samiran,
Did you follow the suggestions in this guide already:
How do I resolve "undefined reference" errors while linking Gurobi in C++? – Gurobi Support PortalBest regards,
Matthias0 -
Hi, thanks for commenting.
Yes, I did. But it didn't help, it was probably setup just fine.
I managed to fix the compilation error though.
Turns out I had an error in the makefile, I did not link the library in all: target and thought it would take it from the individual compilation commands.0
Post is closed for comments.
Comments
3 comments