["scip.exe", "--version"] timed out after 1 second
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
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.
I am suffering this issue every time to call scip.
Same issue here. Were you able to resolve it?
Same issue here...
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 :>
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:
- The default is now 2 seconds
- 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
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!