Windows Installation Guide - nanpuhaha/SerpentAI GitHub Wiki
Installing Serpent.AI on Windows might sound a little daunting at first but it really turns out to be easier than expected. Have a pro tip? Contributions to this page are encouraged.
Prefer a video? A thorough install guide is available on YouTube.
Initial Requirements
- Windows 7 and up
Python Environment
Python 3.6+ (with Anaconda)
Serpent.AI was developed taking full advantage of Python 3.6 so it is only natural that the Python requirement be for versions 3.6 and up.
Installing regular Python 3.6+ isn't exactly difficult but Serpent.AI relies on a good amount of scientific computing libraries that are extremely difficult / impossible to compile on your own on Windows. Thankfully, the Anaconda Distribution exists and takes this huge weight off our collective shoulders.
Installing Anaconda 5.2.0 (Python 3.6)
Download the Python 3.6 version of Anaconda 5.2.0 and run the graphical installer.
The following commands are to be performed in an Anaconda Prompt with elevated privileges (Right click and Run as Administrator). It is recommended to create a shortcut to this prompt because every Python and Serpent command will have to be performed from there starting now.
Creating a Conda Env for Serpent.AI
conda create --name serpent python=3.6
('serpent' can be replaced with another name)
Creating a directory for your Serpent.AI projects
mkdir SerpentAI && cd SerpentAI
Activating the Conda Env
conda activate serpent
3rd-Party Dependencies
Redis
Redis is used in the framework as the in-memory store for the captured frame buffers as well as the temporary storage of analytics events. It is not meant to be compatible with Windows! Microsoft used to maintain a port but it's been abandoned since. This being said, that Redis version is sufficient and it outperforms stuff like running it in WSL on Windows 10. It will install as a Windows Service. Make sure you set it to start automatically.
Alternatively, you can run it in a Docker container.
Build Tools for Visual Studio 2017
Some of the packages that will be installed alongside Serpent.AI are not pre-compiled binaries and will be need to be built from source. This is a little more problematic for Windows but with the correct C++ Build Tools for Visual Studio it all goes down smoothly.
You can get the proper installer by visiting https://www.visualstudio.com/downloads/ and scrolling down to the Build Tools for Visual Studio 2017 download. Download, run, select the Visual C++ build tools section and make sure the following components are checked:
- Visual C++ Build Tools core features
- VC++ 2017 version 15.7 v14.14 latest v141 tools
- Visual C++ 2017 Redistributable Update
- VC++ 2015.3 v14.00 (v140) toolset for desktop
- Universal CRT
Installing Serpent.AI
Once all of the above had been installed and set up, you are ready to install the framework. Remember that PATH changes in Windows are not reflected in your command prompts that were opened while you made the changes. Open a fresh Anaconda prompt before continuing to avoid installation issues.
Go back to the directory you created earlier for your Serpent.AI projects. Make sure you are scoped in your Conda Env.
Run pip install SerpentAI
Then run serpent setup
to install the remaining dependencies automatically.
You are now done with the installation on Windows!
Installing Optional Modules
In the spirit of keeping the initial installation on the light side, some specialized / niche components with extra dependencies have been isolated from the core. It is recommended to only focus on installing them once you reach a point where you actually need them. The framework will provide a warning when a feature you are trying to use requires one of those modules.
OCR
A module to provide OCR functionality in your game agents.
Tesseract
Serpent.AI leverages Tesseract for its OCR functionality. You can install Tesseract for Windows by following these steps:
- Visit https://github.com/UB-Mannheim/tesseract/wiki
- Download the .exe for version 3
- Run the graphical installer (Remember the install path!)
- Add the path to tesseract.exe to your %PATH% environment variable
You can test your Tesseract installation by opening an Anaconda Prompt and executing tesseract --list-langs
.
Installation
Once you've validated that Tesseract has been properly set up, you can install the module with serpent setup ocr
GUI
A module to allow Serpent.AI desktop app to run.
Kivy
Kivy is the GUI framework used in the framework.
Once you are ready to test your Kivy, you can install the module with serpent setup gui
and try to run serpent visual_debugger
ML
A module to leverage various machine learning solutions that are packaged with the framework.
Tensorflow GPU Dependencies (Optional)
You only need to install the following dependencies if:
- Your game agents will leverage deep neural networks like CNNs and RNNs and you want to get top performance from Tensorflow
AND
- You have an NVIDIA GPU that supports compute capability 3.0+ (Generally the GTX 600 series and up)
NVIDIA Drivers
You are on Windows, have a modern GPU and planning to use video games as an environment... Let's face it, your NVIDIA drivers are probably current and up to date.
In case you are totally new to this:
- Visit http://www.nvidia.com/Download/index.aspx
- Find your GPU in the list and download the drivers
- Run the downloaded graphical installer
CUDA
- Make an account on https://developer.nvidia.com/ or log in
- Visit https://developer.nvidia.com/cuda-toolkit-archive
- Select CUDA Toolkit 9.0
- Select Windows, x86_64, 10, exe (local) and download the installer
- Run the graphical installer. Select Custom Install and untick everything except CUDA.
You can test your CUDA installation by opening an Anaconda Prompt and executing nvcc --version
.
cuDNN
- Make an account on https://developer.nvidia.com/ or log in
- Visit https://developer.nvidia.com/rdp/cudnn-archive
- Click Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0
- Download cuDNN v7.0.5 Library for Windows 10
- Extract bin, include and lib inside the ZIP archive to the CUDA installation path equivalent (like C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0)
- Make sure .DLL is included in your %PATHEXT% environment variable
Installation
Once you've taken care of the dependencies, you can install the module with serpent setup ml
. The stable release of the framework installs TensorFlow 1.4.0 which is only compatible with CUDA 8. We installed 9.0 to be compatible with newer releases of TensorFlow which means you will have to uninstall 1.4.0 pip uninstall tensorflow-gpu
. If you want a good balance of library support and recent enough TensorFlow version, it is currently recommended to install 1.5.1 pip install tensorflow-gpu==1.5.1
. Installing versions that are too recent breaks compatibility with libraries that build on top of TensorFlow.
You can test your GPU Tensorflow installation by going to ipython
and entering import tensorflow
. If it loads without any exceptions, you are good to go!
PyTorch
Some SerpentAI's algorithms rely purely on pytorch rather than tensorflow or keras to work. That is the case of RainbowDQN and PPO. In order to use those models, you'll have to go to https://pytorch.org/ and install pytorch according to your compute platform.
Pytorch's installation can be quite heavy and it's recommended to close your browser while the installation is in progress.
Extra
There's also some changes that have been made in folders that are located within site-packages folder. Such changes, though minors, would still be unconvenient to be explained here, so it's better if you just download/clone this repository, get the site-packages folder, copy the files inside this folder, and then go to your conda virtual environment site-package folder and paste it there.
- Download this repository
- Copy the site-packages folder's content files
- Go to [Your pathfile]/[Your Anaconda file]/envs/serpent(your environment name)/Lib/site-packages
- Paste the files you copied there.