Teach you to use DQN automatically play Flappy Bird (full command prompt, pure small white tutorial)
Li Zhe, Li Wei, July
Description: This tutorial was written primarily Yu Shinjie, and finally ran the Yenchenlin GitHub open source demo. In case of problems welcome plus Q Group Exchange: 472899334.
Date: October 13, 2016.
Objective
We in the previous tutorial "based on torch learning Wang Feng write lyrics, chat robot, image coloring/generation, look at the picture talk, subtitle generation," said: "Let everyone can play a, unlimited to reduce the threshold of the novice friend experiment," that can reduce the difficulty again, such as some students are not familiar with the Linux command to the whole, Is that not familiar with the Linux command can not be a toss? And since it's so that everyone can play, it's best to take care of the most.
This tutorial provides a full command prompt so that the Linux command can be set up for students who are not familiar with it . Therefore, auto-play Flappy Bird three steps:
- No matter 3,721, build up the game first.
- After the build up, the Linux command follow slowly familiar, familiar, follow, build other experiment environment also will be immediately smooth many
- Get a sense of accomplishment and peace of mind, then carefully delve into the principles behind the experiment (another, October machine learning algorithm class will also delve into the principle behind the experiment)
another tutorial omitted the ubuntu14.04 installation , if you have not previously installed Ubuntu, you can see the "teach you from start to finish using DL study van Gogh painting" in part 4.1.
Or this matter, welcome more friends to do experiments with us, play together. Including the Flappy Bird 8 experiments: Van Gogh painting, text generation, automatic chat robot, image coloring, image generation, look at the speech, subtitle generation, Flappy bird,10 month to make one of these 8 experiments and on Weibo [email protected] The researcher July, then sends 100 class voucher, the experiment experience sends the community ask.julyed.com, then sends 100 class voucher.
First, NVIDIADrive,CUDA,CUDNN Installation
Apt-get Update (updated source)
Apt-get Install vim (installing vim)
Vi/etc/default/grub (Enter grub file)
Add text( See How to teach you how to use DL to paint from topto bottom)
UPDATE-GRUB2 (update)
Reboot (restart)
1. Install NVIDIA DriverinstallationNvidiaDrive
CD/**/**/** (CD to cuda file directory )
./nvidia-linux-x86_64-367.44.run (Install NVIDIA driver)
Reboot (restart)
2. Install CUDAinstallationCUDA
CD/**/**/** (CD to cuda file directory )
./cuda_8.0.27_linux.run (Installation cuda)
! the first option after accept fills in "n" (this option allows you to choose whether to install NVIDIA 's Driver, It has been installed before, so it is not required), then all the way "green".
Vi/etc/default/grub (open grub)
Modify text(see "Teach you how to use DL to paint from beginningto end")
UPDATE-GRUB2 (update)
Reboot (restart)
3. Install CuDNNinstallationCuDNN
Tar xvzf cudnn-7.5-linux-x64-v5.1-ga.tgz (unzip)
sudo cp cuda/include/cudnn.h/usr/local/cuda/include (copy)
sudo cp cuda/lib64/libcudnn*/usr/local/cuda/lib64 (copy)
sudo chmod a+r/usr/local/cuda/include/cudnn.h/usr/local/cuda/lib64/libcudnn* (plus permissions)
Cuda environment Path to add cuda Environment Variables
Export ld_library_path= "$LD _library_path:/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64"
Export Cuda_home=/usr/local/cuda
Export path= "$CUDA _home/bin: $PATH"
TwoinstallationTensorFlow
Apt-get Install git
Clone the TensorFlow repository cloning TensorFlow
git clone https://github.com/tensorflow/tensorflow
1. Install BazelinstallationBazel
Install JDK 8 installation JDK8
sudo add-apt-repository ppa:webupd8team/java (add source)
sudo apt-get update (update)
sudo apt-get install Oracle-java8-installer (installation)
Add Bazel distribution URI as a package source (one time Setup) ( add Bazel URL Add as Source)
echo "Deb [Arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee/etc/apt/sources.list.d/bazel.list
Curl HTTPS://BAZEL.IO/BAZEL-RELEASE.PUB.GPG | sudo apt-key add-
Update and install Bazel updates and downloads Bazel
sudo apt-get update && sudo apt-get install Bazel
sudo apt-get upgrade Bazel
2. Install Other dependenciesInstall other dependencies
sudo apt-get install python-numpy swig Python-dev python-wheel Python-pip
Configure the installation configuration (note here Configure The hints that are given below)
./configure
Specify the location of Python. [Default Is/usr/bin/python]:
Does wish to build TensorFlow with Google Cloud Platform support? [y/n] N
No Google Cloud Platform support is enabled for TensorFlow
Do you wish to build TensorFlow with GPU support? [y/n] Y
GPU support would be-enabled for TensorFlow
Specify which GCC NVCC should use as the host compiler. [Default IS/USR/BIN/GCC]:
Please specify the Cuda SDK version of want to use, e.g. 7.0. [Leave empty to use system default]: 8.0
Specify the location where CUDA 7.5 Toolkit is installed. Refer to readme.md for more details. [Default Is/usr/local/cuda]:
Please specify the CuDNN version of your want to use. [Leave empty to use system default]: 5
Specify the location where CuDNN 5 library is installed. Refer to readme.md for more details. [Default Is/usr/local/cuda]:
Please specify a list of comma-separated Cuda compute capabilities your want to build with.
You can find the compute capability of your device At:https://developer.nvidia.com/cuda-gpus.
Please note this each additional compute capability significantly increases your build time and binary size.
[Default is: "3.5,5.2"]:
Setting up Cuda include
Setting up Cuda Lib
Setting up Cuda Bin
Setting up Cuda NVVM
Setting up Cupti include
Setting up Cupti lib64
Configuration finished
3. Create the PIP package and installCreatePipPackage and install
Bazel build-c opt//tensorflow/tools/pip_package:build_pip_package (the author uses the company network tips error, after the wall to solve the problem)
Bazel build-c opt--config=cuda//tensorflow/tools/pip_package:build_pip_package
Bazel-bin/tensorflow/tools/pip_package/build_pip_package/tmp/tensorflow_pkg(the author appears during the installation process ImportError :No module named Setuptools, Workaround:apt-get install PYTHON-PIP, installation Python-pip on the line)
sudo pip INSTALL/TMP/TENSORFLOW_PKG/TENSORFLOW-0.11.0RC0-PY2-NONE-ANY.WHL
4, Setting up TensorFlow for developmentCompilation SettingsTensorFlow
Bazel build-c opt//tensorflow/tools/pip_package:build_pip_package
Bazel build-c opt--config=cuda//tensorflow/tools/pip_package:build_pip_package
mkdir _python_build
CD _python_build
Ln-s. /bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/*.
Ln-s. /tensorflow/tools/pip_package/*.
Python setup.py Develop
5. Train your first tensorflow neural net modelTestTensorFlow
CD Tensorflow/models/image/mnist
Export ld_library_path= "$LD _library_path:/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64"
Export Cuda_home=/usr/local/cuda (re-add the environment variable here because I was prompted to not find CUDA during the installation process )
Python convolutional.py(the author appears here attributeerror:type object ' Newbase ' has no attribute ' Is_abstract ' problem, Workaround:sudo pip install six--upgrade-- target= "/usr/lib/python2.7/ Dist-packages ")
ThreeinstallationOpenCV
Download OpenCV Download OpenCV
Browser opens http://opencv.org/
Right Download Linux version of OpenCV
CD to download directory
Unzip Opencv-2.4.13.zip
CD opencv-2.4.13
mkdir Release
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy Libavcodec-dev Libavformat-dev Libswscale-dev
CD release
Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.
sudo make install
FourDownloadFlappybird
Download deeplearningflappybird Download flappybird
git clone--recursive Https://github.com/yenchenlin/DeepLearningFlappyBird
FiveinstallationPygame
Install Pygame installation Pygame
wget http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz Download pygame
sudo apt-get install Libsdl1.2-dev (SDL installation)
sudo apt-get install Libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev Libsdl-gfx1.2-dev Libsdl-net1.2-dev Libsdl-sge-dev Libsdl-sound1.2-dev Libportmidi-dev Libsmpeg-dev (Install other dependent packages)
CD Pygame-1.9.1release
Python config.py
Run deep_q_network.py
Python deep_q_network.py run deep_q_network.py (author here error:attributeerror: ' Module ' objec T has no attribute ' stack ', solution:
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook Python-pandas
Python-sympy Python-nose
git clone git://github.com/numpy/numpy.git numpy (I ran a cd numpyhere;python setup.py Install, Discovery report
The wrong missing Cython then executes the subsequent command)
Apt-get Install Cython
CD NumPy
Python setup.py install)
VI. implementation Procedures
when all is installed, execute again
Python deep_q_network.py
picture stuck waiting for a moment, GPU,CUDA takes time to run.
Wait a moment, the miracle appears, the bird starts to fly automatically, jumps up and down automatically, automatically passes through the obstacle, must know the pure manual play hard to insist 9s!
Still picture may not see what effect, video see this: Http://weibo.com/1580904460/EcxQh6em0.
At this time, this has abused the world countless people of the game, so in our hands, using deep learning automatic play! All embody the magic and charm of deep learning.
Reference Documents
- Teach you from start to finish using DL Van Gogh painting: GTX 1070 Cuda 8.0 tensorflow GPU Version
- May in-depth workshop students Xiao Cai students to write a simple tutorial: With Mac DQN play Flappy Bird
- Https://github.com/yenchenlin/DeepLearningFlappyBird
PostScript
July Online Development/marketing team, October 13, 2016.
Teach you to use DQN automatically play Flappy Bird (full command prompt, pure small white tutorial)