教你从头到尾利用DQN自动玩flappy bird(全程命令提示、纯小白教程)

前言

(安装 ubuntu14.04 省略,当读者刚刚安装好 ubuntu14.04 后,直接看一下步骤安装就行。)

一、 安装必要 NVIDIA 驱动、 CUDA 、 cudnn

apt-get update (更新源)

apt-get install vim (安装 VIM )

vi /etc/default/grub (进入 grub 文件)

添加 text (具体方法看 July 发布的学梵高作画)

update-grub2 (更新一下)

reboot (重启)

1、Install NVIDIA Driver 安装 NVIDIA 驱动

cd /**/**/** (cd 到 cuda 所在文件目录下 )

./NVIDIA-linux-x86_64-367.44.run (安装 NVIDIA 驱动)

reboot (重启)

2、Install CUDA 安装 CUDA

cd /**/**/** (cd 到 cuda 所在文件目录下 )

./cuda_8.0.27_linux.run (安装 CUDA )

! accept 之后第一个选项填写“ n ”(该选项让你选择是否安装 NVIDIA 的 Driver ,之前已经安装过了, 所以不需要),之后一路“绿灯”。

vi /etc/default/grub (打开 grub )

修改 text (具体方法看 July 发布的学梵高作画)

update-grub2 (更新一下)

reboot (重启)

3、Install cuDNN 安装 cuDNN

tar xvzf cudnn-7.5-linux-x64-v5.1-ga.tgz (解压)

sudo cp cuda/include/cudnn.h /usr/local/cuda/include (复制)

sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 (复制)

sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* (加权限)

CUDA Environment Path 添加 CUDA 的环境变量

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"

二、 安装 Tensorflow
[原]教你从头到尾利用DQN自动玩flappy bird(全程命令提示,纯小白教程)

apt-get install git

Clone the TensorFlow repository 克隆 Tensorflow

git clone https://github.com/tensorflow/tensorflow

1、Install Bazel 安装 Bazel

Install JDK 8 安装 JDK8

sudo add-apt-repository ppa:webupd8team/java (添加源)

sudo apt-get update (更新)

sudo apt-get install oracle-java8-installer (安装)

Add Bazel distribution URI as a package source (one time setup) (将 Bazel 的 URL 添加为源)

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 更新并下载 Bazel

sudo apt-get update && sudo apt-get install bazel

sudo apt-get upgrade bazel

2、Install other dependencies 安装其他依赖

sudo apt-get install python-numpy swig python-dev python-wheel python-pip

Configure the installation 配置 (这里注意 configure 后面的提示,提示已经给出)

./configure

Please specify the location of python. [Default is /usr/bin/python]: Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N

No Google Cloud Platform support will be enabled for TensorFlow

Do you wish to build TensorFlow with GPU support? [y/N] y

GPU support will be enabled for TensorFlow

Please specify which gcc nvcc should use as the host compiler. [Default is /usr/bin/gcc]: Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 7.5 Please 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 you want to use. [Leave empty to use system default]: 5 Please 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 you want to build with.

You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.

Please note that each additional compute capability significantly increases your build time and binary size.

[Default is: "3.5,5.2"]: 3.0

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 install 创建 pip 包并且安装

bazel build -c opt //tensorflow/tools/pip_package:build_pip_package (笔者用公司网提示 error ,翻墙后问题解决)

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 (笔者安装过程中出现 ImportError : No module named setuptools ,解决办法: apt-get install

python-pip ,安装 python-pip 就行了。)

sudo pip install /tmp/tensorflow_pkg/tensorflow-0.11.0rc0-py2-none-any.whl

4、Setting up TensorFlow for Development 编译设置 Tensorflow

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 model 测试 Tensorflow

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 (这里重新添加环境变量是因为笔者安装过程中提示未能找到 CUDA )

python convolutional.py (笔者这里出现 AttributeError : type object 'NewBase' has no attribute 'is_abstract' 问题,解决办法: sudo pip install six --upgrade --

target="/usr/lib/python2.7/dist-packages" )

三、 安装 OpenCV

Download OpenCV 下载 OpenCV

浏览器打开 http://opencv.org/

右侧下载 Linux 版本的 OpenCV

cd 到下载目录

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

四、 下载 FlappyBird

Download DeepLearningFlappyBird 下载 FlappyBird

git clone --recursive https://github.com/yenchenlin/DeepLearningFlappyBird

五、 安装 pygame

Install pygame 安装 pygame

wget http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz 下载 pygame

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: OpenCVCULinux浏览器TIRYADM变量
分页:12
转载请注明
本文标题:[原]教你从头到尾利用DQN自动玩flappy bird(全程命令提示,纯小白教程)
本站链接:http://www.codesec.net/view/482427.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(75)