Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mihsamusev opened this issue Dec 6, 2023 · 7 comments · Fixed by #3183
Closed

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

mihsamusev opened this issue Dec 6, 2023 · 7 comments · Fixed by #3183

Comments

@mihsamusev
Copy link

mihsamusev commented Dec 6, 2023

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:

def _get_version(self, solver_exec=None):
"""
Returns a tuple describing the solver executable version.
"""
if solver_exec is None:
solver_exec = self.executable()
if solver_exec is None:
return _extract_version('')
results = subprocess.run(
[solver_exec, "--version"],
timeout=1,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
return _extract_version(results.stdout)

@mihsamusev mihsamusev added the bug label Dec 6, 2023
@mrmundt
Copy link
Contributor

mrmundt commented Dec 6, 2023

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.

@kchen158
Copy link

I am suffering this issue every time to call scip.

@ramondalmau
Copy link

Same issue here. Were you able to resolve it?

@mppolo
Copy link

mppolo commented Mar 3, 2024

Same issue here...

@nqh-tq-32052503
Copy link

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 :>

@mrmundt
Copy link
Contributor

mrmundt commented Mar 25, 2024

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

@hygro-aabedi
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants