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

Feature proposal: Linux support #11

Closed
Claes1981 opened this issue Mar 10, 2021 · 5 comments
Closed

Feature proposal: Linux support #11

Claes1981 opened this issue Mar 10, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@Claes1981
Copy link

I noticed it was not as simple as changing line 320 from
tour_manager = Path(Path.cwd(), './tourney_manager/cutechess/cutechess-cli.exe')
to
tour_manager = '/usr/bin/cutechess-cli'

result:

python lakas.py --engine /partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra --base-time-sec 1 --inc-time-sec 0.5 --optimizer bayesopt --output-data-file test1.dat --optimizer-log-file test1.txt --input-param "{'Threads': {'init': 8, 'lower': 1, 'upper': 8}}" --common-param "{'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}" --opening-file /home/claes/Lakas/start_pos.pgn --opening-file-format pgn
2021-03-10 11:56:41,687 | INFO  | Lakas v0.33.0
2021-03-10 11:56:41,687 | INFO  | input param: OrderedDict([('Threads', {'init': 8, 'lower': 1, 'upper': 8})])

2021-03-10 11:56:41,687 | INFO  | total budget: 1000
2021-03-10 11:56:41,687 | INFO  | games/budget: 100
2021-03-10 11:56:41,687 | INFO  | move control: base_time_sec: 1, inc_time_sec: 0.5, depth=None, nodes=None
2021-03-10 11:56:41,688 | INFO  | parameter dimension: 1
2021-03-10 11:56:41,688 | INFO  | deterministic function: False
2021-03-10 11:56:41,688 | INFO  | use best param: False
2021-03-10 11:56:41,688 | INFO  | optimizer: bayesopt, initialization: Hammersley, init_budget: None, middle_point: False, utility_kind: ucb, utility_kappa: 2.576, utility_xi: 0.0, gp_parameters: {'alpha': 0.001, 'normalize_y': True, 'n_restarts_optimizer': 5, 'random_state': None}

2021-03-10 11:56:41,696 | INFO  | budget: 1
2021-03-10 11:56:41,696 | INFO  | recommended param: {'Threads': 8}
2021-03-10 11:56:41,696 | INFO  | best param: {'Threads': 8}
2021-03-10 11:56:41,697 | INFO  | best loss: 0.5
2021-03-10 11:56:41,697 | INFO  | init param: {'Threads': 8}
2021-03-10 11:56:41,697 | INFO  | common param: {'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}
2021-03-10 11:56:41,697 | INFO  | recommended vs init
Traceback (most recent call last):
  File "lakas.py", line 931, in <module>
    main()
  File "lakas.py", line 893, in main
    loss = objective.run(**x.kwargs)
  File "lakas.py", line 244, in run
    result = engine_match(self.engine_file, test_options, base_options,
  File "lakas.py", line 398, in engine_match
    process = Popen(str(tour_manager) + command, stdout=PIPE, text=True)
  File "/usr/lib64/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.8/subprocess.py", line 1706, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/cutechess-cli -concurrency 1 -tournament round-robin -pgnout nevergrad_games.pgn fi -each tc=0/0:1+0.5 -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=test option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=base option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -rounds 50 -games 2 -repeat 2 -recover -wait 5000 -openings file=/home/claes/Lakas/start_pos.pgn order=random format=pgn -resign movecount=6 score=700 twosided=true -draw movenumber=30 movecount=6 score=1'

Entering /usr/bin/cutechess-cli -concurrency 1 -tournament round-robin -pgnout nevergrad_games.pgn fi -each tc=0/0:1+0.5 -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=test option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=base option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -rounds 50 -games 2 -repeat 2 -recover -wait 5000 -openings file=/home/claes/Lakas/start_pos.pgn order=random format=pgn -resign movecount=6 score=700 twosided=true -draw movenumber=30 movecount=6 score=1 on the command line starts a cutechess-cli match as expected, so the command seems to work there.

@fsmosca
Copy link
Owner

fsmosca commented Mar 11, 2021

I will try to implement it this weekend. Thanks for testing it in Linux.

@fsmosca fsmosca added the enhancement New feature or request label Mar 11, 2021
fsmosca added a commit that referenced this issue Mar 11, 2021
This is for #11
Tested to work in windows 10.

Example:

python -u lakas.py --match-manager-path F:/CuteChess-CLI/cutechess-cli.exe ...
@fsmosca
Copy link
Owner

fsmosca commented Mar 11, 2021

@Claes1981 can you try again if it will work in Linux.

I tried it in windows 10 and it worked.

help

  --match-manager-path MATCH_MANAGER_PATH
                        Match manager path and/or filename. Example:
                        cutechess:
                        --match-manager-path c:/chess/tourney_manager/cutechess/cutechess-cli.exe
                        duel.py for xboard engines:
                        --match-manager-path python c:/chess/tourney_manager/duel/duel.py
                        or
                        --match-manager-path c:/python3/python c:/chess/tourney_manager/duel/duel.py

@Claes1981
Copy link
Author

Sorry, same error as before:

python lakas.py --engine /partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra --base-time-sec 1 --inc-time-sec 0.5 --optimizer bayesopt --output-data-file test1.dat --optimizer-log-file test1.txt --input-param "{'Threads': {'init': 8, 'lower': 1, 'upper': 8}}" --common-param "{'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}" --opening-file /home/claes/Lakas/start_pos.pgn --opening-file-format pgn --match-manager-path /usr/bin/cutechess-cli
2021-03-11 20:26:18,712 | INFO  | Lakas v0.35.0
2021-03-11 20:26:18,712 | INFO  | input param: OrderedDict([('Threads', {'init': 8, 'lower': 1, 'upper': 8})])

2021-03-11 20:26:18,712 | INFO  | total budget: 1000
2021-03-11 20:26:18,712 | INFO  | games/budget: 100
2021-03-11 20:26:18,712 | INFO  | move control: base_time_sec: 1, inc_time_sec: 0.5, depth=None, nodes=None
2021-03-11 20:26:18,713 | INFO  | parameter dimension: 1
2021-03-11 20:26:18,713 | INFO  | deterministic function: False
2021-03-11 20:26:18,713 | INFO  | use best param: False
2021-03-11 20:26:18,713 | INFO  | optimizer: bayesopt, initialization: Hammersley, init_budget: None, middle_point: False, utility_kind: ucb, utility_kappa: 2.576, utility_xi: 0.0, gp_parameters: {'alpha': 0.001, 'normalize_y': True, 'n_restarts_optimizer': 5, 'random_state': None}

2021-03-11 20:26:18,721 | INFO  | budget: 1
2021-03-11 20:26:18,721 | INFO  | recommended param: {'Threads': 8}
2021-03-11 20:26:18,721 | INFO  | best param: {'Threads': 8}
2021-03-11 20:26:18,721 | INFO  | option.Threads=8 
2021-03-11 20:26:18,721 | INFO  | best loss: 0.5
2021-03-11 20:26:18,721 | INFO  | init param: {'Threads': 8}
2021-03-11 20:26:18,721 | INFO  | common param: {'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}
2021-03-11 20:26:18,721 | INFO  | recommended vs init
Traceback (most recent call last):
  File "lakas.py", line 951, in <module>
    main()
  File "lakas.py", line 913, in main
    loss = objective.run(**x.kwargs)
  File "lakas.py", line 252, in run
    result = engine_match(self.engine_file, test_options, base_options,
  File "lakas.py", line 409, in engine_match
    process = Popen(str(tour_manager) + command, stdout=PIPE, text=True)
  File "/usr/lib64/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.8/subprocess.py", line 1706, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/cutechess-cli -concurrency 1 -tournament round-robin -pgnout nevergrad_games.pgn fi -each tc=0/0:1+0.5 -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=test option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -engine cmd=/partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra name=base option.Threads=8 option.EvalFile=/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue option.Contempt=11 proto=uci -rounds 50 -games 2 -repeat 2 -recover -wait 5000 -openings file=/home/claes/Lakas/start_pos.pgn order=random format=pgn -resign movecount=6 score=700 twosided=true -draw movenumber=30 movecount=6 score=1'

(Entering the Cutechess-cli command from the last line direct in the terminal still starts a match)

I don't know how Python and Linux handles commands, but does it maybe somehow threat all command options as part of the file name, and therefore respond with "No such file or directory"?

fsmosca added a commit that referenced this issue Mar 12, 2021
Example command line in linux:

python3.7 lakas.py --match-manager-path ../cutechess-cli/cutechess-cli --concurrency 6 --optimizer bayesopt --bo-utility-kind ucb --output-data-file bayesopt_ucb.dat --input-data-file bayesopt_ucb.dat --optimizer-log-file opt_log_plot_ucb.txt --base-time-sec 1 --inc-time-sec 0.05 --budget 12 --games-per-budget 6 --engine stockfish_13_linux_x64_modern/stockfish_13_linux_x64_modern --input-param "{'Hash': {'init':16, 'lower':1, 'upper':128}}" --opening-file ./start_opening/ogpt_chess_startpos.epd --opening-file-format epd
2021-03-12 14:52:12,952 | INFO  | Lakas v0.36.0
2021-03-12 14:52:12,952 | INFO  | input param: OrderedDict([('Hash', {'init': 16, 'lower': 1, 'upper': 128})])

2021-03-12 14:52:12,953 | INFO  | total budget: 12
2021-03-12 14:52:12,953 | INFO  | games/budget: 6
2021-03-12 14:52:12,953 | INFO  | move control: base_time_sec: 1, inc_time_sec: 0.05, depth=None, nodes=None
2021-03-12 14:52:12,956 | INFO  | parameter dimension: 1
2021-03-12 14:52:12,957 | INFO  | deterministic function: False
2021-03-12 14:52:12,957 | INFO  | use best param: False
2021-03-12 14:52:12,977 | INFO  | optimizer: bayesopt, previous budget: 0

2021-03-12 14:52:12,991 | INFO  | budget: 1
2021-03-12 14:52:12,991 | INFO  | recommended param: {'Hash': 23}
2021-03-12 14:52:12,992 | INFO  | best param: {'Hash': 16}
2021-03-12 14:52:12,992 | INFO  | option.Hash=16
2021-03-12 14:52:12,992 | INFO  | best loss: 0.5
2021-03-12 14:52:12,992 | INFO  | init param: {'Hash': 16}
2021-03-12 14:52:12,992 | INFO  | recommended vs init
2021-03-12 14:52:21,605 | INFO  | actual result: 0.66667 @6 games, minimized result or loss: 0.33333, point of view: recommended

2021-03-12 14:52:21,623 | INFO  | budget: 2
2021-03-12 14:52:21,624 | INFO  | recommended param: {'Hash': 16}
2021-03-12 14:52:21,624 | INFO  | best param: {'Hash': 23}
2021-03-12 14:52:21,624 | INFO  | option.Hash=23
2021-03-12 14:52:21,625 | INFO  | best loss: 0.5
2021-03-12 14:52:21,625 | INFO  | init param: {'Hash': 16}
2021-03-12 14:52:21,625 | INFO  | recommended vs init
2021-03-12 14:52:37,560 | INFO  | actual result: 0.50000 @6 games, minimized result or loss: 0.50000, point of view: recommended

For #11
@fsmosca
Copy link
Owner

fsmosca commented Mar 12, 2021

Version 0.36.0 is uploaded, I tested it in WSL and it worked.

python3.7 lakas.py --match-manager-path ../cutechess-cli/cutechess-cli --concurrency 6 --optimizer bayesopt --bo-utility-kind ucb --output-data-file bayesopt_ucb.dat --input-data-file bayesopt_ucb.dat --optimizer-log-file opt_log_plot_ucb.txt --base-time-sec 1 --inc-time-sec 0.05 --budget 12 --games-per-budget 6 --engine stockfish_13_linux_x64_modern/stockfish_13_linux_x64_modern --input-param "{'Hash': {'init':16, 'lower':1, 'upper':128}}" --opening-file ./start_opening/ogpt_chess_startpos.epd --opening-file-format epd
2021-03-12 14:52:12,952 | INFO  | Lakas v0.35.0
2021-03-12 14:52:12,952 | INFO  | input param: OrderedDict([('Hash', {'init': 16, 'lower': 1, 'upper': 128})])

2021-03-12 14:52:12,953 | INFO  | total budget: 12
2021-03-12 14:52:12,953 | INFO  | games/budget: 6
2021-03-12 14:52:12,953 | INFO  | move control: base_time_sec: 1, inc_time_sec: 0.05, depth=None, nodes=None
2021-03-12 14:52:12,956 | INFO  | parameter dimension: 1
2021-03-12 14:52:12,957 | INFO  | deterministic function: False
2021-03-12 14:52:12,957 | INFO  | use best param: False
2021-03-12 14:52:12,977 | INFO  | optimizer: bayesopt, previous budget: 0

2021-03-12 14:52:12,991 | INFO  | budget: 1
2021-03-12 14:52:12,991 | INFO  | recommended param: {'Hash': 23}
2021-03-12 14:52:12,992 | INFO  | best param: {'Hash': 16}
2021-03-12 14:52:12,992 | INFO  | option.Hash=16
2021-03-12 14:52:12,992 | INFO  | best loss: 0.5
2021-03-12 14:52:12,992 | INFO  | init param: {'Hash': 16}
2021-03-12 14:52:12,992 | INFO  | recommended vs init
2021-03-12 14:52:21,605 | INFO  | actual result: 0.66667 @6 games, minimized result or loss: 0.33333, point of view: recommended

Try it if it will work this time.

@Claes1981
Copy link
Author

Yes, now it seems to work, thank you! :) The engines started to run before I manually aborted:

python lakas.py --engine /partitions/Sandisk/xfs/media/data/chess/engines/Cfish/Cfish-20100303_pgo_extra --base-time-sec 1 --inc-time-sec 0.5 --optimizer bayesopt --output-data-file test1.dat --optimizer-log-file test1.txt --input-param "{'Threads': {'init': 8, 'lower': 1, 'upper': 8}}" --common-param "{'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}" --opening-file /home/claes/Lakas/start_pos.pgn --opening-file-format pgn --match-manager-path /usr/bin/cutechess-cli
2021-03-12 18:48:59,738 | INFO  | Lakas v0.36.0
2021-03-12 18:48:59,738 | INFO  | input param: OrderedDict([('Threads', {'init': 8, 'lower': 1, 'upper': 8})])

2021-03-12 18:48:59,738 | INFO  | total budget: 1000
2021-03-12 18:48:59,738 | INFO  | games/budget: 100
2021-03-12 18:48:59,738 | INFO  | move control: base_time_sec: 1, inc_time_sec: 0.5, depth=None, nodes=None
2021-03-12 18:48:59,739 | INFO  | parameter dimension: 1
2021-03-12 18:48:59,739 | INFO  | deterministic function: False
2021-03-12 18:48:59,739 | INFO  | use best param: False
2021-03-12 18:48:59,739 | INFO  | optimizer: bayesopt, initialization: Hammersley, init_budget: None, middle_point: False, utility_kind: ucb, utility_kappa: 2.576, utility_xi: 0.0, gp_parameters: {'alpha': 0.001, 'normalize_y': True, 'n_restarts_optimizer': 5, 'random_state': None}

2021-03-12 18:48:59,747 | INFO  | budget: 1
2021-03-12 18:48:59,747 | INFO  | recommended param: {'Threads': 8}
2021-03-12 18:48:59,748 | INFO  | best param: {'Threads': 8}
2021-03-12 18:48:59,748 | INFO  | option.Threads=8 
2021-03-12 18:48:59,748 | INFO  | best loss: 0.5
2021-03-12 18:48:59,748 | INFO  | init param: {'Threads': 8}
2021-03-12 18:48:59,748 | INFO  | common param: {'EvalFile': '/partitions/Sandisk/xfs/media/data/chess/engines/Stockfish_development_versions/nets/nn-baeb9ef2d183.nnue', 'Contempt': 11}
2021-03-12 18:48:59,748 | INFO  | recommended vs init
^CTraceback (most recent call last):
  File "lakas.py", line 957, in <module>
    main()
  File "lakas.py", line 919, in main
    loss = objective.run(**x.kwargs)
  File "lakas.py", line 255, in run
    result = engine_match(self.engine_file, test_options, base_options,
  File "lakas.py", line 416, in engine_match
    for eline in iter(process.stdout.readline, ''):
KeyboardInterrupt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants