For Windows instances
A Gurobi license depends on the primary volume. So, for Windows, use an Elastic Block Store (EBS) volume for your primary volume (C:), and the license should remain valid.
For Linux instances
On Linux, by default, a Gurobi license depends on the primary network interface, which may change when starting a new EC2 instance. To prevent this, assign an Elastic Network Interface (ENI) to the EC2 instance and bind the license to this new network adapter. With an ENI, the Gurobi license will continue to work, since the network interface persists for the machine running Gurobi.
To assign a license to a secondary network adapter, perform the following steps:
- Create a new ENI
- Attach the ENI to your AWS EC2 instance
- Start your AWS EC2 instance
- Determine the hostname and host ID of the ENI
- Hostname: Run
hostnamewhen logged in to the machine or assign a custom hostname
- Host ID: These are the last eight hexadecimal digits of the MAC address. In the image below, the host ID is
- Hostname: Run
- Log in to your account on the Gurobi website and navigate to Downloads & Licenses->Your Gurobi Licenses. Click the appropriate license ID, then install the license using the manual process at the bottom of the webpage:
- Download and copy the license file to the EC2 machine
Alternatively, you may use the automatic license installation process using
grbgetkey. This will only register the license to the detachable ENI if you assign the ENI as the primary network adapter when configuring the EC2 instance before it is started for the first time.
In both cases, you are able to use the Gurobi license on a new EC2 instance as long as you assign the same hostname and attach the ENI (either as the primary or secondary network adapter) that was used to initially install the license.
Regardless of the operating system, it's easiest to start and stop the EC2 instance, rather than creating a new instance each time.