Installing Gurobi on a Docker container (Ubuntu)Answered
Hi I am trying to use a tool for genomic data reconstruction called COBRAToolbox which relies on GUROBI as an LP solver. I'm currently working on a remote system helped set up by the university, hence a DOCKER container on a virtual system; OS is Linux64. so I followed the steps outlined here https://opencobra.github.io/cobratoolbox/stable/installation.html#gurobi and when I test run by launching gurobi.sh I have the following error:
Python 3.7.4 (default, Oct 29 2019, 10:15:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
License is not valid in a Docker container, contact Gurobi support for more options
I tried for a solution online but it seems slightly too involved and incomprehensible. Could anyone help me with this issue, would be very much appreciated. Thanks in advance
Thanks for your post. The standard academic licenses for Gurobi do not work in docker containers. For this reason we have launched the Web License Service (WLS), which is a new licensing mechanism specifically tailored to Docker containers. You can think of it as a floating license that is managed by Gurobi. There are further details to be found in the Web License Service documentation.
If you are able to access your university network, you can create your own WLS license from our Web License Manager by clicking on "Create academic license". This will provide you with a 90-day license allowing up to two concurrent uses of Gurobi. You can renew this license as needed from the Web License Manager website. If you do not have access to your university network, please let us know.
Once you have created a WLS license you will be able to download the license file from WLS, mount it in your docker container in place of your current academic license, then run Gurobi within the container. For examples of how to use the WLS license, we provide an image for using the full Gurobi Optimizer as well as an image specifically for Python use.
If you run into any issues with this process, please open a ticket in our support portal (rather than on the community forum) so that we can help you directly.0
Many many thanks for your comment. The documentations is rather easy to follow through. However, I have one question: I have retrieved the license file and it contains the 3 ID's. I am wondering how do you feed this in the once I open gurobi environment via command line (I opened it with the command gurobi.sh and following is what it states:
Using license file /opt/gurobi/gurobi.lic
Set parameter LogFile to value gurobi.log
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID
Gurobi Interactive Shell (linux64), Version 9.1.2
Copyright (c) 2021, Gurobi Optimization, LLC
Type "help()" for help
I used the parameters WLSACCESSID, WLSSECRET, LICENSEID but it returns, as Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'WLSACCESSID' is not defined
Any suggestions what I am doing incorrectly here?
Thanks in advance,
You don't need to set the parameters manually - it suffices to just use the downloaded gurobi.lic file from within your container when running Gurobi.
You may want to use one of our pre-built container images: gurobi/optimizer - Docker Image | Docker Hub
Thank you for the email. I may have a very tricky very constraint requirement for gurobi which is not being sufficed by the conventional alternatives for Docker container, it seems like. More so I am using it for a MATLAB package called as RAVEN to create metabolic reconstruction models, which in turn also depends on another package called cobraToolbox. Now to solve LP problems on cobraToolbox the installation has been outlined here: https://opencobra.github.io/cobratoolbox/stable/installation.html#gurobi
Step 6 mentions how to run the grbgetkey command followed by the license file (which has a certain format). Now the only thing here which is confusing is that the License key which is generated for the WLS token is not accepted in this command grbgetkey and hence I cant proceed with the installation of gurobi. All these are kind of interdependent and thus I think it has a specific installation walkthrough which has to be followed. This is where I am stuck at now with gurobi, please give it a short read on the cobraToolbox installation and maybe if you find a solution for gurobi for me please let me know.
Sorry for the complexity of this issue. I thank you very much for your time and help.
The issue might not be as complicated as you think. grbgetkey is only creating a license file on your machine and Gurobi requires this license file. If yo already have such a license file, e.g. via WLS, then you can safely skip the grbgetkey command.
I recommend testing your installation by just calling
You may also want to check out our Quick Start Guides (gurobi.com).
I hope that helps.
An update: I got in touch with my IT team hand had at least few tools moved out of Docker as I had many issues on there. So now I am running it on Ubuntu 18.04. I have now used the steps to install which I have pasted in the installation link in previous comment. I have could do the grbgetkey, get the license file. Up wntil that point everything ran perfectly. But when I test run the installation of my tool (CobtaToolbox and RAVEN) in MATLAB, this is the following output I can see:
> changeCobraSolver: Solver gurobi is installed but not working properly.
*** THE RAVEN TOOLBOX v.2.5.1 ***
Checking if RAVEN is on the MATLAB path... OK
Checking if it is possible to parse a model in Microsoft Excel format... OK
Checking if it is possible to import an SBML model using libSBML... The model contains 0 errors and 1 warnings.
Solver found in preferences... gurobi
Checking if it is possible to solve an LP problem using gurobi... Not OK
Checking if it is possible to solve an LP problem using cobra... OK
Preferred solver... NEW
Solver saved as preference... cobra
Checking essential binary executables:
NOTE: Broken binary executables must be fixed before running RAVEN
Checking non-essential/development binary executables:
NOTE: Only fix these binaries if planning to use KEGG FTP dump files in getKEGGModelForOrganism
cd-hit... Not OK! If necessary, download/compile the binary and run checkInstallation again
Checking whether RAVEN functions are non-redundant across MATLAB path... Not OK
WARNING: Duplicate functions in /home/joe/RAVEN/cobratoolbox/src/reconstruction/comparison:
It is strongly recommended to resolve conflicting functions as this may compromise RAVEN functionality
*** checkInstallation complete ***
To interpret this the MILP solver for this shows NOT OK flag when there is some problem with gurobi.
As a side, I have added the path to .bashrc as follows:
And lastly, when running the commands gurobi.sh and gurobi_cl got the following errors: gurobi_cl: error while loading shared libraries: libgurobi91.so: cannot open shared object file: No such file or directory
(base) joe@querx:/opt/gurobi912/linux64/matlab$ gurobi.sh
gurobi.sh: command not found
I asked this question to the owner of the softwares on github as well, but they said that its best to ask this on gurobi community as they cannot rectify the issue themselves. I am stuck on the same since days so I maybe need some help from you to get past this roadblock.
Thanks very much,
I am very sorry to hear that you are still having issues. There appears to be something wrong with your Gurobi installation. Could you please check whether you can run:
There is no gurobi.sh in /opt/gurobi912/linux64/matlab so this last command is expected to fail. How did you install Gurobi? Did you follow the installation instructions? It is very unusual to see the error about "loading shared libraries: libgurobi91.so" when you export the LD_LIBRARY_PATH like that. Before running or testing anything with COBRA or RAVEN, you should make sure that the stand-alone Gurobi installation is working as expected.
Could you please run:
Thanks for your comment. I tried to follow all the steps as was given in the installation link for gurobi solver. And in the last step it is expected to check whether gurobi is properly installed by running gurobi.sh (according to the link I shared). Although as advised by you I ran gurobi_cl and gurobi_cl --license as well.
I can however assure that gurobi.sh is indeed present in the expected path. Please find the below for reference:
(base) joe@querx:/opt/gurobi912/linux64/matlab$ ls
gurobi_feasrelax.m gurobi.mexa64 gurobi_relax.mexa64 html
gurobi_feasrelax.mexa64 gurobi_presolve.mexa64 gurobi_setup.m info.xml
gurobi_iis.m gurobi_read.m gurobi.sh README
gurobi_iis.mexa64 gurobi_read.mexa64 gurobi_write.m
gurobi.m gurobi_relax.m gurobi_write.mexa64
The below outputs after running the two echo commands:
(base) joe@querx:/opt/gurobi912/linux64/matlab$ echo $GUROBI_HOME
(base) joe@querx:/opt/gurobi912/linux64/matlab$ echo $LD_LIBRARY_PATH
Thanks for your continued help.
I am sorry, Joel, but in the Linux installation package of Gurobi 9.1.2 there is no gurobi.sh in the matlab subdirectory - this file should be in the bin directory.
Please remove the installation directory and repeat the installation again. There might be other things off that we don't see so easily.
Hi Joel - It still looks like there is something a little strnage in your installation. Can you share the contents of /opt/gurobi912/linux64/lib and /opt/gurobi912/linux64/bin? Thanks, Gwyneth0
MATHIAS and GWENYTH!
It finally worked for me! RAVEN and CobraToolbox are able to use gurobi! I'm so thankful to Mathias, Simon and Gwyneth for all helping out with this issue and ensure that it was resolved. It indeed was a problem with the license file. Reinstalling helped. Moving out of Docker helped too. I'm relieved and glad I can work on my project now. Again, I am extremely indebted for the amount of support I got from Gurobi team. Thanks very much! :)
Please sign in to leave a comment.