Please help me: gurobipy._exception.GurobiError: Out of memory
AnsweredHi everyone.
I am currently modelling an energy system covering EU using pypsa (pypsa-eur). It is a quite large file. It has around 50 mio. rows, 25 mio. columns and 126 mio. nonzeros. My machine on the other hand only has 16 gb of RAM and CPU model: AMD Ryzen 5 5500U with Radeon Graphics. Is it simply physically impossible to solve it with my current machine? If yes, do you have other suggestion? I dont know what to do. Here is the log copy:
[Fri Jan 30 17:17:11 2026]
localrule solve_sector_network:
input: resources/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc
output: results/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc, results/Thesis/Q1-B-demandandsupply/configs/config.base_s_96___2040.yaml
log: results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_solver.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_memory.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_python.log
jobid: 0
benchmark: results/Thesis/Q1-B-demandandsupply/benchmarks/solve_sector_network/base_s_96___2040
reason: Missing output files: results/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc; Input files updated by another job: resources/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc
wildcards: clusters=96, opts=, sector_opts=, planning_horizons=2040
threads: 6
resources: tmpdir=C:\Users\AppData\Local\Temp, mem_mb=30000, mem_mib=28611, runtime=360
INFO:pypsa.io:Imported network base_s_96___2040.nc has buses, carriers, generators, global_constraints, lines, links, loads, storage_units, stores
WARNING:pypsa.consistency:The following buses have no attached components, which can break the lopf: {'EU'}
INFO:__main__:Adding solar potential constraint.
INFO:linopy.model: Solve problem using Gurobi solver
INFO:linopy.model:Solver logs written to `results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_solver.log`.
INFO:linopy.model:Solver options:
- threads: 6
- method: 1
- crossover: 0
- BarConvTol: 1e-05
- Seed: 123
- AggFill: 0
- PreDual: 0
- GURO_PAR_BARDENSETHRESH: 200
INFO:linopy.io:Writing objective.
Writing constraints.: 100%|███████████████████████████████████████████████████████████████████████| 254/254 [08:43<00:00, 2.06s/it]
Writing continuous variables.: 100%|████████████████████████████████████████████████████████████████| 50/50 [01:25<00:00, 1.70s/it]
INFO:linopy.io: Writing time: 675.52s
Set parameter Username
Set parameter LicenseID to value 2712504
Academic license - for non-commercial use only - expires 2026-09-23
Read LP format model from file C:\Users\pypsa-eur\linopy-problem-coengmfx.lp
Reading time = 169.46 seconds
obj: 53948546 rows, 25122580 columns, 126333669 nonzeros
Set parameter Threads to value 6
Set parameter Method to value 1
Set parameter Crossover to value 0
Set parameter BarConvTol to value 1e-05
Set parameter Seed to value 123
Set parameter AggFill to value 0
Set parameter PreDual to value 0
Set parameter GURO_PAR_BARDENSETHRESH to value 200
Set parameter LogFile to value "C:\Users\pypsa-eur\results\Thesis\Q1-B-demandandsupply\logs\base_s_96___2040_solver.log"
Gurobi Optimizer version 12.0.2 build v12.0.2rc0 (win64 - Windows 11.0 (26100.2))
CPU model: AMD Ryzen 5 5500U with Radeon Graphics, instruction set [SSE2|AVX|AVX2]
Thread count: 6 physical cores, 12 logical processors, using up to 6 threads
Non-default parameters:
Method 1
BarConvTol 1e-05
Crossover 0
AggFill 0
PreDual 0
Seed 123
Threads 6
GURO_PAR_BARDENSETHRESH 200
Optimize a model with 53948546 rows, 25122580 columns and 126333669 nonzeros
Model fingerprint: 0xd7c4a5bc
Coefficient statistics:
Matrix range [2e-07, 3e+02]
Objective range [4e-02, 2e+06]
Bounds range [3e-01, 1e+10]
RHS range [1e-03, 1e+09]
Warning: Model contains large bounds
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Presolve time: 175.02s
Solved in 0 iterations and 175.05 seconds (86.06 work units)
Infeasible or unbounded model
INFO:linopy.solvers:Unable to save solution file. Raised error: Unable to retrieve attribute 'X'
WARNING:linopy.constants:Optimization potentially failed:
Status: warning
Termination condition: infeasible_or_unbounded
Solution: 0 primals, 0 duals
Objective: nan
Solver model: available
Solver message: 4
WARNING:__main__:Solving status 'warning' with termination condition 'infeasible_or_unbounded'
Gurobi Optimizer version 12.0.2 build v12.0.2rc0 (win64 - Windows 11.0 (26100.2))
CPU model: AMD Ryzen 5 5500U with Radeon Graphics, instruction set [SSE2|AVX|AVX2]
Thread count: 6 physical cores, 12 logical processors, using up to 6 threads
Non-default parameters:
Method 1
BarConvTol 1e-05
Crossover 0
AggFill 0
PreDual 0
Seed 123
Threads 6
GURO_PAR_BARDENSETHRESH 200
Warning: insufficient memory, speed may be affected.
IIS runtime: 18.92 seconds (1.78 work units)
ERROR:root:Uncaught exception
Traceback (most recent call last):
File "C:\Users\pypsa-eur\.snakemake\scripts\tmpglmwdv67.solve_network.py", line 1646, in <module>
solve_network(
File "C:\Users\pypsa-eur\.snakemake\scripts\tmpglmwdv67.solve_network.py", line 1602, in solve_network
labels = n.model.compute_infeasibilities()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\anaconda3\envs\pypsa-eur\Lib\site-packages\linopy\model.py", line 1281, in compute_infeasibilities
solver_model.computeIIS()
File "src\\gurobipy\\_model.pyx", line 1208, in gurobipy._model.Model.computeIIS
gurobipy._exception.GurobiError: Out of memory
RuleException:
CalledProcessError in file "C:\Users\pypsa-eur\rules/solve_overnight.smk", line 44:
Command 'C:/Users/anaconda3/envs/pypsa-eur/python.exe "C:\Users\pypsa-eur\.snakemake\scripts\tmpglmwdv67.solve_network.py"' returned non-zero exit status 1.
[Fri Jan 30 17:37:36 2026]
Error in rule solve_sector_network:
message: None
jobid: 0
input: resources/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc
output: results/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc, results/Thesis/Q1-B-demandandsupply/configs/config.base_s_96___2040.yaml
log: results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_solver.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_memory.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_python.log (check log file(s) for error details)
Shutting down, this might take some time.
Exiting because a job execution failed. Look below for error messages
[Fri Jan 30 17:37:36 2026]
Error in rule solve_sector_network:
message: None
jobid: 0
input: resources/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc
output: results/Thesis/Q1-B-demandandsupply/networks/base_s_96___2040.nc, results/Thesis/Q1-B-demandandsupply/configs/config.base_s_96___2040.yaml
log: results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_solver.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_memory.log, results/Thesis/Q1-B-demandandsupply/logs/base_s_96___2040_python.log (check log file(s) for error details)
Complete log(s): C:\Users\pypsa-eur\.snakemake\log\2026-01-30T163238.398216.snakemake.log
WorkflowError:
At least one job did not complete successfully.
-
Hi Cornelius,
Setting Method=1 as you are doing, to use dual simplex, will help. You will find other ideas in this article:
How do I avoid an out-of-memory condition? In particular I would try with Threads=1. If you have closed other programs that may be consuming memory, and are still getting an error then you will need to use another machine.On a side note, while you are using dual simplex, parameters related to barrier such as crossover, BarConvTol and GURO_PAR_BARDENSETHRESH will be redundant.
- Riley
0
Please sign in to leave a comment.
Comments
1 comment