跳到主要內容

tensorflow

TensorFlow Docker requirements
  1. Install Docker on your local host machine.
  2. 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.

Ubuntu 14.04/16.04/18.04, 

Ubuntu will install docker.io by default which isn't the latest version of Docker Engine. This implies that you will need to pin the version of nvidia-docker. 
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
ref:
https://github.com/NVIDIA/nvidia-docker



CUDA toolkit versionDriver versionGPU architecture
6.5>= 340.29>= 2.0 (Fermi)
7.0>= 346.46>= 2.0 (Fermi)
7.5>= 352.39>= 2.0 (Fermi)
8.0== 361.93 or >= 375.51== 6.0 (P100)
8.0>= 367.48>= 2.0 (Fermi)
9.0>= 384.81>= 3.0 (Kepler)
9.1>= 387.26>= 3.0 (Kepler)
9.2>= 396.26>= 3.0 (Kepler)
10.0>= 384.130, < 385.00Tesla GPUs
10.0>= 410.48>= 3.0 (Kepler)


CUDA images come in three flavors and are available through the NVIDIA public hub repository.

  • base: starting from CUDA 9.0, contains the bare minimum (libcudart) to deploy a pre-built CUDA application.
    Use this image if you want to manually select which CUDA packages you want to install.
  • runtime: extends the base image by adding all the shared libraries from the CUDA toolkit.
    Use this image if you have a pre-built application using multiple CUDA libraries.
  • devel: extends the runtime image by adding the compiler toolchain, the debugging tools, the headers and the static libraries.
    Use this image to compile a CUDA application from sources.


留言

這個網誌中的熱門文章

A3C in ATARI Pong-V0

ATARI PONG 對戰模式,左邊為遊戲程式,右邊為訓練中的A3C模型。一局以21分決勝負,對手MISS 一球得一分。從LOG可以看出,A3C模型從最初全敗的輸21分,經過2小時左右的TRAINING,已經逆轉至幾乎每局都勝利,偶爾甚至勝出高達13分。 底下為TRAINING A3C MODEL過程的LOG, (base) frank@viper1:~/a3c$ python main.py --env-name "Pong-v0" --num-processes 8 Time 00h 00m 10s, episode reward -21.0, episode length 1026 Time 00h 01m 18s, episode reward -21.0, episode length 1020 Time 00h 02m 26s, episode reward -21.0, episode length 1029 Time 00h 03m 35s, episode reward -21.0, episode length 1023 Time 00h 04m 42s, episode reward -21.0, episode length 1014 Time 00h 05m 50s, episode reward -21.0, episode length 1087 Time 00h 07m 00s, episode reward -21.0, episode length 1359 Time 00h 08m 14s, episode reward -16.0, episode length 1922 Time 00h 09m 30s, episode reward -14.0, episode length 2220 Time 00h 10m 48s, episode reward -15.0, episode length 2431 Time 00h 12m 04s, episode reward -15.0, episode length 2211 Time 00h 13m 23s, episode reward -8.0, episode length 2600 Time 00h 14m 38s, episod...

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 r...

Loss function

why cross entroy is more suitable for categorical classcification? ref: https://www.youtube.com/watch?v=Li5sVEXTIJw