pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

["scip.exe", "--version"] timed out after 1 second

Open mihsamusev opened this issue 2 years ago • 4 comments

Summary

A proper and feasible linear model solves ok with scip but on a rare occasion a subprocess error of a kind subprocess.TimeoutExpired: Command [".../scip.exe", "--version"] timed out after 1 second error is thrown. If it is possible to reach the solver within given 1 second the rest of the interaction with solver and problem results are correct every single time.

Steps to reproduce the issue

Very hard to reproduce, but it seems to be affected by how many python processes are re-using scip and whether the os is busy running some other heavy task like Teams Video call.

Error Message

File "C:\Users\MyUser\miniconda3\envs\ramiro\Lib\site-packages\my_library\model_wrapper\pyomo_model_wrapper.py", line 123, in __solve_chunks
results: SolverResults = factory.solve(model, tee=True)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\site-packages\pyomo\opt\base\solvers.py", line 533, in solve
self.available(exception_flag=True)
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\site-packages\pyomo\opt\solver\shellcmd.py", line 135, in available
ans = self.executable()

^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\site-packages\pyomo\opt\solver\shellcmd.py", line 206, in executable
else self._default_executable()

^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\site-packages\pyomo\solvers\plugins\solvers\SCIPAMPL.py", line 77, in _default_executable
self._known_versions[executable_path] = self._get_version(

^^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\site-packages\pyomo\solvers\plugins\solvers\SCIPAMPL.py", line 104, in _get_version
results = subprocess.run(

^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\subprocess.py", line 550, in run
stdout, stderr = process.communicate(input, timeout=timeout)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\subprocess.py", line 1209, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\MyUser\miniconda3\envs\some_project\Lib\subprocess.py", line 1628, in _communicate
raise TimeoutExpired(self.args, orig_timeout)
subprocess.TimeoutExpired: Command '['C:\\Users\\MyUser\\miniconda3\\envs\\some_project\\Library\\bin\\scip.exe', '--version']' timed out after 1 seconds

Information on your system

Pyomo version: 6.6.0 Python version: 3.11 Operating system: Windows 11 How Pyomo was installed (PyPI, conda, source): pip install Pyomo==6.6 Solver (if applicable): SCIP 8.1.0 installed by conda install -c conda-forge scip

Additional

Tried the same problem on GLPK solver and it doesnt seem to call the above mentioned subprocess first before calling the solver executable. No matter how busy is the OS.

Here it is i believe, timeout set 1:

https://github.com/Pyomo/pyomo/blob/de96befb45386af212711fcd51db79e467b75780/pyomo/solvers/plugins/solvers/SCIPAMPL.py#L96-L111

mihsamusev avatar Dec 06 '23 14:12 mihsamusev

Thanks, @mihsamusev , for this. I am going to attach it to one of our ongoing efforts : #1030 . We are actively working on refactoring how the solver interfaces work, and we will look into this as part of that.

mrmundt avatar Dec 06 '23 22:12 mrmundt

I am suffering this issue every time to call scip.

kchen158 avatar Jan 13 '24 21:01 kchen158

Same issue here. Were you able to resolve it?

ramondalmau avatar Feb 28 '24 09:02 ramondalmau

Same issue here...

mppolo avatar Mar 03 '24 22:03 mppolo

I had the same issue. Then I tried running the command "scip --version" in the Terminal. After that, I ran the previous command again, and then it worked. I do not know the reason, but it worked :>

nqh-tq-32052503 avatar Mar 23 '24 09:03 nqh-tq-32052503

All who commented:

The cause of this issue is that there was a hardcoded timeout of 1 second when checking the version of scip (and other solvers). Sometimes it can take longer than that for a solver to reply, which is what was causing this failure. We changed this in #3183 in two ways:

  1. The default is now 2 seconds
  2. The timeout can be changed by doing:
import pyomo.environ as pyo
opt = pyo.SolverFactory('scip')
opt._version_timeout = 3 # however many seconds you choose

mrmundt avatar Mar 25 '24 14:03 mrmundt

I had the same issue. Then I tried running the command "scip --version" in the Terminal. After that, I ran the previous command again, and then it worked. I do not know the reason, but it worked :>

This worked for me as well!

hygro-aabedi avatar May 07 '24 13:05 hygro-aabedi