Trouble debugging GRBEnv error on web server
回答済みHi, I have some code that uses Gurobi and runs correctly on my local machine.
However, when I try using it from my web server it doesn't work. The code is in java, and the web server is Ubuntu where the java code is called from a php file.
I have isolated the issue in the following code. My log file prints out "GS1" but does not print "GS2" or anything from either of the catch statements. So there is some issue with the creation of the GRBEnv, but somehow this is not getting picked up as a GRBException it seems. I am assuming the issue is related to a permission or license issue, but it is difficult to debug when it won't print out any information about the errors.
A little warning that my web development experience is minimal though I have used Gurobi successfully without the web server many times.
Thank you for any suggestions on how I can debug and fix this issue.
public class Grady_subproblem implements Grady_config {
private double objective;
private double[] thresholds;
private double[] probs;
private GRBEnv env;
public Grady_subproblem() {
try {
System.out.println("GS1");
env = new GRBEnv(true);
System.out.println("GS2");
env.set(GRB.IntParam.OutputFlag, GUROBI_VERBOSE);
System.out.println("GS3");
env.start();
System.out.println("GS4");
}
catch (GRBException ex) {
System.out.println("GS5");
System.out.println(ex.getMessage());
System.out.println(ex.getErrorCode());
System.out.println("GS6");
}
catch (Exception e) {
System.out.println("GS7");
System.out.println(e.getMessage());
}
}
-
Hi Sam,
What sort of license are you using?
- Riley
0 -
Named user license.
0 -
Ok, this simplifies the situation since networking shouldn't be an issue. Here are some things to try.
Can you try writing some code to see if your webapp can read the contents of your license file? If it can't this may point to a permissions issue.
Can you make sure you are setting the GRB_LICENSE_FILE environment variable to the location of your license file?
Can you also try printing all environment variables from within your webapp to make sure the GRB_LICENSE_FILE variable is available to the app?
0 -
Hi, I can confirm that GRB_LICENSE_FILE is set to the correct location.
I can also confirm that the php server code is not able to access it.
In the terminal when I type "printenv GRB_LICENSE_FILE" it prints:
/home/sganzfri/opt/gurobi1200/gurobi.lic
When I put the following in the php code for the server:
$command = 'printenv GRB_LICENSE_FILE';
exec($command, $output, $error);
print_r($output);
print_r($error);It prints Array ( ) 1
As a test, when I try
$command = 'java --version';
exec($command, $output, $error);
print_r($output);
print_r($error);The output is:
Array ( [0] => openjdk 21.0.5 2024-10-15 [1] => OpenJDK Runtime Environment (build 21.0.5+11-Ubuntu-1ubuntu124.04) [2] => OpenJDK 64-Bit Server VM (build 21.0.5+11-Ubuntu-1ubuntu124.04, mixed mode, sharing) ) 0
So somehow the php/webapp code is not able to access the environmental variables even though they are set properly.
0 -
Hi Sam,
It may be enough to change the location of the license file to one of the default locations listed in this article: https://support.gurobi.com/hc/en-us/articles/360013417211-Where-do-I-place-the-Gurobi-license-file-gurobi-lic
- Riley
0 -
Hi thanks, I think I have figured out the issue and I don't think it is related to the web server or license file location. I'm unable to run the code at all on the Ubuntu server using Gurobi 12.0 (though it runs properly on my local windows machine).
I have the GRB_LICENSE_FILE and all other environmental variables set correctly.
I get the following error. The issue is that it should be checking for GurobiJni120 in java.library.path, not GurobiJni110. I am compiling with the gurobi.jar file from the Gurobi 12.0 linux64 installer (I downloaded it again to double check). Perhaps there is a bug in this gurobi.jar file where it is looking for GurobiJni110 instead of GurobiJni120?
I guess I could probably get it work with Gurobi 11.0, but I'd like to be able to use the latest version if possible. I believe this is the issue causing all of my problems.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no GurobiJni110 in java.library.path: :/home/sganzfri/opt/gurobi1200/linux64/lib:/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
at java.base/java.lang.System.loadLibrary(System.java:2063)
at com.gurobi.gurobi.GurobiJni.<clinit>(GurobiJni.java:315)
at com.gurobi.gurobi.GRBEnv.<init>(GRBEnv.java:106)
at grady_new2.Grady_subproblem.<init>(Grady_subproblem.java:25)
at grady_new2.Grady_master.solve(Grady_master.java:115)
at grady_new2.Grady_main.main(Grady_main.java:129)0 -
Hi Sam,
Perhaps there is a bug in this gurobi.jar file where it is looking for GurobiJni110 instead of GurobiJni120?
I don't think so, our testing pipelines (beta users) would have picked such a bug up long ago.
I would double check the PATH, GUROBI_HOME and LD_LIBRARY_PATH variables, making sure there is nothing from v11 sneaking in. Or alternatively, switch to using Maven: https://support.gurobi.com/hc/en-us/articles/19474118568977-How-do-I-install-Gurobi-for-Java
- Riley
0 -
Hi Riley, thanks for the help. All of the variables seem to be correctly pointing to v12 though.
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$ printenv PATH
/home/sganzfri/bin:/home/sganzfri/.local/bin:/home/sganzfri/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/sganzfri/opt/gurobi1200/linux64/bin
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$ printenv GUROBI_HOME
/home/sganzfri/opt/gurobi1200/linux64
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$ printenv LD_LIBRARY_PATH
:/home/sganzfri/opt/gurobi1200/linux64/lib
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$ printenv GRB_LICENSE_FILE
/home/sganzfri/opt/gurobi1200/gurobi.lic
sganzfri@serversam:/var/www/grady.ddns.net/public_html/pages$0 -
hmm, how are you compiling your program? Are you using an IDE?
0 -
Can you try with the full path to the jar file and see if you still get the error? I.e.
javac -cp .:/home/sganzfri/opt/gurobi1200/linux64/lib/gurobi.jar *.java
0 -
Hi I fixed the issue. (Tried to delete my prior post but you responded already).
java -cp java_code/:./gurobi.jar grady_new2.Grady_main
was pointing to an old version of gurobi.jar that was in the directory I was running it from.
Thanks for your help, hopefully all is resolved now.
0 -
Yes everything works now, thanks so much for the help.
0 -
No problem, best of luck!
0
サインインしてコメントを残してください。
コメント
13件のコメント