Gurobi can be used in WSL2. You have two options outlined below to get set up with your Gurobi license.
The most accessible options are to connect to a floating token server or to use our Web License Service. Since Gurobi 10.0, you can also use WLS licenses running in WSL2.
To use a machine-bound individual license (e.g. free academic license), please follow these instructions:
The Windows Subsystem for Linux, specifically version 2, does not have a persistent network address. This means that a new MAC address will be assigned to the network adapter after every reboot of the Windows host machine. Gurobi uses these network adapters to identify the machine and validate the license, so a simple reboot of the machine may render the license invalid.
Until there is a proper solution to have a static and persistent MAC address in WSL2 natively, you may use the approach suggested in WSL issue #5352:
You need to add these lines to the .bashrc
of your WSL user:
# assign a persistent MAC address for adpater bond0 and rename it eth1
mac=1a:2b:3c:4d:5e:6f
if ! ip link show | grep -q $mac; then
sudo ip link add bond0 type bond # only if no bond0 adapter present already
sudo ip link set dev bond0 down
sudo ip link set dev bond0 address $mac
sudo ip link set dev bond0 name eth1
sudo ip link set dev eth1 up
fi
If you already have a bond0
adapter (check with grbprobe adapters
), you can use this MAC address to make this address persistent via the mac
variable in the above script. In that case, you can also remove the first line in the if-block that adds the bond0
adapter.
After a reboot, the eth1
address will stay the same and you can use it to bind the Gurobi license to your WSL by following these steps:
- get a new academic license
- run
grbprobe --adapter eth1 --output wsl2-hostinfo.txt
to store theeth1
info in the filewsl2-hostinfo.txt
- run
grbgetkey xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx --input wsl2-hostinfo.txt
using your personal license key and the hostinfo file.
Please note that you will need to enter your sudo password when starting the WSL for the first time to apply the network changes defined in your .bashrc
file.
Alternatively, you can also use WSL2 as a client and offload optimization jobs to Gurobi Instant Cloud or a Gurobi Compute Server. No machine-bound license is required in those cases.
Further information
- How do I obtain a free academic license for a cluster or a shared computer lab?
- What is an Academic WLS client license?
- How do I use the command line on Windows?
Comments
0 comments
Article is closed for comments.