Gurobi can be used in WSL2. You have two options outlined below to get set up with your Gurobi license.
The easiest options is 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:
# get a persistent MAC address for bond0 and rename it eth1
if ! ip link show | grep -q $mac; then
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
You should run
grbprobe adapters first and use the MAC address of the
bond0 adapter to set the
mac variable in that script to match your current setup. 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
grbprobe --adapter eth1 --output wsl2-hostinfo.txtto store the
eth1info in the file
grbgetkey xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx --input wsl2-hostinfo.txtusing 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
Alternatively, you can also use WSL2 as a client and offload optimization jobs to Gurobi Instant Cloud or to a Gurobi Compute Server.
- 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?
Please sign in to leave a comment.