Unable to load shared library 'gurobi81'

432 views
Skip to first unread message

schoem...@gmail.com

unread,
Nov 14, 2019, 2:14:30 PM11/14/19
to OPTANO Modeling

I'm trying to integrate gurobi in our .NET core application via nuget:
<PackageReference Include="OPTANO.Modeling.Gurobi" Version="8.1.1.19"/>
<PackageReference Include="OPTANO.Modeling" Version="3.0.1.451"/>


Now when I run the application locally I get this error message:
System.DllNotFoundException: Unable to load shared library 'gurobi81' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libgurobi81, 1): image not found


I'm running this on my local machine (macos). When I install gurobi on my local machine everything works fine. 

But there's the problem. We want to run the application in a Docker container on Azure. It doesn't make sense to install gurobi on that machine I would say. It seems that only adding the nuget packages is not enough. We already have it up and running with version 7.5 on an app service on Azure. In this case we also only have referenced the NuGet packages and that works. 


If we run the application in Docker on Azure with NuGet package 8.1.1.19 then we get kinda same exception as I got on my local machine without gurobi installed:

System.DllNotFoundException : Unable to load shared library 'gurobi81' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgurobi81: cannot open shared object file: No such file or directory


Can you please help me out so I can get this up and running without installing gurobi locally?

ORCONOMY Team

unread,
Nov 14, 2019, 3:17:48 PM11/14/19
to OPTANO Modeling
Hi

What version of dotnet core and MacOS do you use?

Id like to setup a test env for this issue.

Best,
jp

schoem...@gmail.com

unread,
Nov 15, 2019, 2:12:14 AM11/15/19
to OPTANO Modeling
Hi jp,

It's net core 2.2 and latest macos.
I can give you an sample project which shows the issue if you want?

Kind regards 
Martijn 

schoem...@gmail.com

unread,
Nov 15, 2019, 2:19:26 AM11/15/19
to OPTANO Modeling
You can download the sample project here. If you run this on macos (or apparently on linux as well) without Gurobi locally installed you'll get the exception I mentioned:

ORCONOMY Team

unread,
Nov 15, 2019, 2:29:54 AM11/15/19
to OPTANO Modeling
Thanks for the update. We're setting up a matching test environment.

Just to double check:
* Your Dev Environment is MacOS
* Your Prod Environment in Azure

In both cases, the package does not run?

Do you see any build issues, regarding missing files or .target-files that failed?

Best,
jp

schoem...@gmail.com

unread,
Nov 15, 2019, 2:35:23 AM11/15/19
to OPTANO Modeling
- Yes, my local machine is macos.
- Prod env is a docker container on Azure. But I think if you run the app locally in a docker container you'll see the same behaviour, but I didn't checked that.

In both cases it gives kinda the same error.

macOS (see mention of dylib its macos specific): 
System.DllNotFoundException: Unable to load shared library 'gurobi81' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libgurobi81, 1): image not found 

Docker/linux:
System.DllNotFoundException : Unable to load shared library 'gurobi81' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgurobi81: cannot open shared object file: No such file or directory

No I dont get any build issues. It's crashing on run time.

schoem...@gmail.com

unread,
Nov 15, 2019, 7:37:27 AM11/15/19
to OPTANO Modeling
Ok, I got the same issue when running my application locally in a docker container. 

So what I did was following this doc to install gurobi on the linux machine:

So therefore I modified my dockerfile to run this script:

tar xvfz gurobi8.1.1_linux64.tar.gz

export GUROBI_HOME="/root/gurobi811/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

exec dotnet *.dll

All the files are in the specified folders (when I check content of LD_LIBRARY_PATH the files are there). 
But when calling the dotnet application I still get the exception

ORCONOMY Team

unread,
Nov 15, 2019, 7:47:15 AM11/15/19
to OPTANO Modeling
Hallo

I have contacted the gurobi support to figure out what files are required and missing.

Best,
jp

schoem...@gmail.com

unread,
Nov 15, 2019, 8:09:09 AM11/15/19
to OPTANO Modeling
Ok thanks. Probably you can add this:

before running the dotnet application if I check the LD_LIBRARY_PATH everything seems fine. The folder '/root/gurobi811/linux64/lib' is there. And if I do 'ls' on that folder I see that the files that are in Linux zip that I downloaded here: https://www.gurobi.com/downloads/gurobi-software/

But I don't now if all neccesary files are there and if so, why it's still complaining about missing libraries. 

echo $LD_LIBRARY_PATH
:/root/gurobi811/linux64/lib

cd /root/gurobi811/linux64/lib
ls

gurobi-javadoc.jar
gurobi.jar
gurobi.py
gurobi81.netstandard20.dll
gurobi81.netstandard20.xml
libGurobiJni81.so
libgurobi.so.8.1.1
libgurobi81.so
libgurobi81_light.so
libgurobi_c++.a
libgurobi_g++4.2.a
libgurobi_g++5.2.a
python2.7
python2.7_utf16
python2.7_utf32
python3.5_utf32
python3.6_utf32
python3.7_utf32
rootcert.pem

schoem...@gmail.com

unread,
Nov 15, 2019, 9:41:43 AM11/15/19
to OPTANO Modeling
I found a solution/workaround. I ended up on this forum post with kinda the same situation but with another library.

I also used docker image alpine but switched it to stretch-slim and now its working...

ORCONOMY Team

unread,
Nov 15, 2019, 10:31:01 AM11/15/19
to OPTANO Modeling
Hi,

thanks for the update. What part of the thread has helped?
I'd like to evaluate this on our machines as well.

Best,
jp

schoem...@gmail.com

unread,
Nov 15, 2019, 10:33:18 AM11/15/19
to OPTANO Modeling
The fix is in the last message; using another Linux distro.
Debian (stretch slim) instead of alpine.

ORCONOMY Team

unread,
Nov 15, 2019, 10:38:23 AM11/15/19
to OPTANO Modeling
a got it. we usually use debian - not knowing it's such a difference.

i just release 8.1.1.20 - it should fix an issue in the .target file and copy the gurobi files correctly.

Best,
jp

s.vanho...@gmail.com

unread,
Jun 11, 2020, 9:06:43 AM6/11/20
to OPTANO Modeling
Hi jp,

I am experiencing the same issue. Steps I took:
1. Setup Docker desktop to use Linux containers
2. Create a new .NET Core (2.1) Console App;
3. Add Docker support for Linux;
4. Install OPTANO.Modeling (3.3.0.474) & OPTANO.Modeling.Gurobi (9.0.1.23) via NuGet;
5. Create a new instance of the GurobiSolver in main method
6. Build project with Docker
7. Get the following error: System.DllNotFoundException: 'Unable to load shared library 'gurobi90' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgurobi90: cannot open shared object file: No such file or directory'.

* My DockerFile uses the .NET Core 2.1 stretch-slim image
* When using Windows containers in Docker the GurobiSolver instance can be created without problems.

Am I missing out on something?

Kind regards,
Sander van Hooff


OPTANO Team

unread,
Jun 11, 2020, 10:52:45 AM6/11/20
to OPTANO Modeling
Hi!

I am going to create a compareable solution on one of our linux systems.

Is the docker Container somewhere available?

Please allow a few days, we are on bank holidays until Sunday.

Best,
jp

s.vanho...@gmail.com

unread,
Jun 11, 2020, 11:22:06 AM6/11/20
to OPTANO Modeling
Hi jp,

No the Docker container runs on my local machine (Windows).
Thanks in advance, I will wait for your response.

Best,
Sander

OPTANO Team

unread,
Jun 13, 2020, 4:39:06 AM6/13/20
to optano-...@googlegroups.com
Hi,

I think, there's a workaround. Please test, if this is sufficient to you:

  1. go to the deploy/build folder. might be something like
    cd ./bin/Debug/netcoreapp3.1

  2. Rename libgurobi901.so to libgurobi90.so by executing
    mv libgurobi901.so libgurobi90.so
  3. Re-run your application from the the folder



Does this work? Then we will fix the nuget package as well.
Best,
jp

OPTANO Team

unread,
Jun 13, 2020, 5:23:23 AM6/13/20
to OPTANO Modeling
We just release the Gurobi Package 9.0.2.24 which shall fix this issue.
It has been tested on ubuntu 20.04.

Best,
jp

s.vanho...@gmail.com

unread,
Jun 15, 2020, 4:00:55 AM6/15/20
to OPTANO Modeling
Hi jp,

Great, now it works :)
Thanks for the fast response again.

Have a nice week,
Sander
Reply all
Reply to author
Forward
0 new messages