跳到主要內容

DDPG in Torcs within Docker Container











Dockerfile:
FROM tensorflow/tensorflow:0.10.0-gpu

WORKDIR /home/frank/old_gym_torcs
ADD . /home/old_gym_torcs 

RUN apt update
RUN apt install -y vim xautomation torcs
RUN apt-get install -y libjpeg-dev cmake swig python-pyglet python3-opengl libboost-all-dev \
        libsdl2-2.0.0 libsdl2-dev libglu1-mesa libglu1-mesa-dev libgles2-mesa-dev \
        freeglut3 xvfb libav-tools

RUN pip install gym
RUN pip install keras==1.1.0
ENV PATH="/usr/games:${PATH}"
CMD ["/bin/bash"]



viper1 $ docker run --runtime=nvidia -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/frank/old_gym_torcs:/home/old_gym_torcs -v /var/run/docker.sock:/var/run/docker.sock -v /home/frank/gym_torcs:/home/gym_torcs -v /home/frank/gym:/home/gym -p 3101:3101 --workdir /home/old_gym_torcs -p 8888:8888 ddpgfrk:tf0.10 /bin/bash

(grey part is not necessary)

After 
$ docker commit id ddpg:tf0.10.0-gpu

viper1 $ docker run --runtime=nvidia -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/frank/old_gym_torcs:/home/old_gym_torcs -v /var/run/docker.sock:/var/run/docker.sock -v /home/frank/gym_torcs:/home/gym_torcs -v /home/frank/gym:/home/gym -p 3101:3101 --workdir /home/old_gym_torcs -p 8888:8888 ddpg:tf0.10.0-gpu /bin/bash
..
Q:
autostart.sh: 12: autostart.sh: xte: not found
A:
sudo apt install xautomation

Q:
NameError: global name 'emsg' is not defined
A:
python2 and python 3 try except syntax conflict
snakeoil3_gym.py
-        except (socket.error, emsg):
+        except socket.error as emsg:


Reward Function:
Rt=Vxcos(θ)Vxsin(θ)VxtrackPos


Ref:
https://github.com/ugo-nama-kun/gym_torcs
https://github.com/yanpanlau/DDPG-Keras-Torcs
https://yanpanlau.github.io/2016/10/11/Torcs-Keras.html

留言

這個網誌中的熱門文章

增強式學習

   迴力球遊戲-ATARI     賽車遊戲DQN-ATARI 賽車遊戲-TORCS Ref:     李宏毅老師 YOUTUBE DRL 1-3 On-policy VS Off-policy On-policy     The agent learned and the agent interacting with the environment is the same     阿光自已下棋學習 Off-policy     The agent learned and the agent interacting with the environment is different     佐助下棋,阿光在旁邊看 Add a baseline:     It is possible that R is always positive     So R subtract a expectation value Policy in " Policy Gradient" means output action, like left/right/fire gamma-discounted rewards: 時間愈遠的貢獻,降低其權重 Reward Function & Action is defined in prior to training MC v.s. TD MC 蒙弟卡羅: critic after episode end : larger variance(cuz conditions differ a lot in every episode), unbiased (judge until episode end, more fair) TD: Temporal-difference approach: critic during episode :smaller variance, biased maybe atari : a3c  ...

tensorflow

TensorFlow Docker requirements Install Docker  on your local  host  machine. For GPU support on Linux,  install nvidia-docker . Docker is the easiest way to enable TensorFlow  GPU support  on Linux since only the  NVIDIA® GPU driver  is required on the  host  machine  (the  NVIDIA® CUDA® Toolkit  does not need to be installed). docker run [-it] [--rm] [-p hostPort:containerPort] tensorflow/tensorflow[:tag] [command] $ docker run -it --rm tensorflow/tensorflow    python -c "import tensorflow as tf; print(tf.__version__)" Note:   nvidia-docker  v1 uses the  nvidia-docker  alias, where v2 uses  docker --runtime=nvidia . CUDA 9.0 for TensorFlow < 1.13.0 nvidia-docker2 intsall prerequisites: NVIDIA driver  and Docker  . If you have a custom  /etc/docker/daemon.json , the  nvidia-docker2  package might override it....

{}大括弧在PYTHON的2種用法

Ref: https://stackoverflow.com/questions/9197324/what-is-the-meaning-of-curly-braces {}大括弧在PYTHON的2種用法: "Curly Braces" are used in Python to define a dictionary. A dictionary is a data structure that maps one value to another - kind of like how an English dictionary maps a word to its definition. Python: 1. dict = { "a" : "Apple" , "b" : "Banana" , } 2. They are also used to format strings, instead of the old C style using %, like: ds = [ 'a' , 'b' , 'c' , 'd' ] x = [ 'has_{} 1' . format ( d ) for d in ds ] print x [ 'has_a 1' , 'has_b 1' , 'has_c 1' , 'has_d 1' ]