Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/official-stockfish/nnue-pytorch
Stockfish NNUE (Chess evaluation) trainer in Pytorch
https://github.com/official-stockfish/nnue-pytorch
chess deep-learning pytorch stockfish
Last synced: about 2 hours ago
JSON representation
Stockfish NNUE (Chess evaluation) trainer in Pytorch
- Host: GitHub
- URL: https://github.com/official-stockfish/nnue-pytorch
- Owner: official-stockfish
- License: gpl-3.0
- Created: 2020-10-28T03:07:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T12:37:41.000Z (5 months ago)
- Last Synced: 2024-06-03T14:39:15.518Z (5 months ago)
- Topics: chess, deep-learning, pytorch, stockfish
- Language: C++
- Homepage:
- Size: 2.05 MB
- Stars: 293
- Watchers: 15
- Forks: 94
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setup
### Software prerequisites
#### Python
If using easy_train.py then at least 3.7 is required.
Otherwise versions around 3.6 should also work, but updating is recommended.
Python 3.11 was also tested and works well.
#### A C++ compiler
If you're using easy_train.py then at least GCC 9.2 is required for compiling the data loader, Stockfish, and c-chess-cli. This a defensive version requirement as older versions were known to cause problems with Stockfish.
If you're not using easy_train.py then no automatic compilation will take place; use what you wish.
If you're on Windows the best way is to probably use [MSYS2](https://www.msys2.org/). It would also make it easy to install Make (next step).
#### Make
For compiling Stockfish and c-chess-cli. Not strictly necessary if you're not using easy_train.py, but recommended.
#### CMake
Necessary for compiling the data loader.
https://cmake.org/install/
### Package dependencies
```
python -m venv trainer
pip install -r requirements.txt
```PyTorch with CUDA 11.8 will be automatically installed, along with the matching CuPy version.
### The data loader (if not using easy_train.py)
This requires a C++17 compiler and cmake.
Windows:
```
compile_data_loader.bat
```Linux/Mac:
```
sh compile_data_loader.bat
```# Network training and management
Hard way: [wiki](https://github.com/official-stockfish/nnue-pytorch/wiki/Basic-training-procedure-(train.py))
Easier way: [wiki](https://github.com/official-stockfish/nnue-pytorch/wiki/Basic-training-procedure-(easy_train.py))
# Logging
TODO: Move to wiki. Add setup for easy_train.py
```
tensorboard --logdir=logs
```
Then, go to http://localhost:6006/# Automatically run matches to determine the best net generated by a (running) training
TODO: Move to wiki
```
python run_games.py --concurrency 16 --stockfish_exe ./stockfish.master --c_chess_exe ./c-chess-cli --ordo_exe ./ordo --book_file_name ./noob_3moves.epd run96
```Automatically converts all `.ckpt` found under `run96` to `.nnue` and runs games to find the best net. Games are played using `c-chess-cli` and nets are ranked using `ordo`.
This script runs in a loop, and will monitor the directory for new checkpoints. Can be run in parallel with the training, if idle cores are available.# Thanks
* Sopel - for the amazing fast sparse data loader
* connormcmonigle - https://github.com/connormcmonigle/seer-nnue, and loss function advice.
* syzygy - http://www.talkchess.com/forum3/viewtopic.php?f=7&t=75506
* https://github.com/DanielUranga/TensorFlowNNUE
* https://hxim.github.io/Stockfish-Evaluation-Guide/
* dkappe - Suggesting ranger (https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer)