跳到主要內容

Install tensorflow-gpu in Ubuntu 18.04

Ubuntu version:
18.04 LTS
NVidia graphic card:
NVidia 1080
NVidia graphic driver:
410.93
CUDA:
9.0
Cudnn:
7.0.
Tensorflow-gpu:



how to check nvidia driver version:
1.  $ nvidia-smi


check cuda version:
    cat /usr/local/cuda/version.txt
    nvcc --version



Installing Tensorflow GPU on Ubuntu 18.04 LTS for deepfakehttps://medium.com/@taylordenouden/installing-tensorflow-gpu-on-ubuntu-18-04-89a142325138  *****
step1:nvidia driver
    https://www.geforce.com.tw/drivers
    sudo ./NVIDIA-Linux-x86_64-410.93.run

    出現 Would you like to run the nvidia-xconfig utility to automatically update your X configuration file
       so that the NVIDIA X driver will be used when you restart X? 
       Any pre-existing X configuration file will be backed up
       回答:Yes  (注意預設值是No)


OR:
(~) viper1 $ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001BE0sv00001025sd00001146bc03sc00i00
vendor   : NVIDIA Corporation
model    : GP104M [GeForce GTX 1080 Mobile]
manual_install: True
driver   : nvidia-driver-410 - third-party free
driver   : nvidia-driver-390 - third-party free
driver   : nvidia-driver-396 - third-party free
driver   : nvidia-driver-415 - third-party free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

$ sudo ubuntu-drivers autoinstall 
or
$ sudo apt install nvidia-415 

step2:cuda V9.0
    sudo chmod +x cuda_9.0.176_384.81_linux.run
    ./cuda_9.0.176_384.81_linux.run --override
    choose no to “Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?”


step3:cudnn V7.1.4
    cudnn
    cuDNN v7.1.4 Library for Linux    <=====pls download this one, not ubuntu XXXX
    cudnn-9.0-linux-x64-v7.tgz
    # Unpack the archive
    tar -zxvf cudnn-9.0-linux-x64-v7.tgz

    # Move the unpacked contents to your CUDA directory
    sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
    sudo cp  cuda/include/cudnn.h /usr/local/cuda-9.0/include/

    # Give read access to all users
    sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

step4:Install libcupti
    sudo apt-get install libcupti-dev

step5:Do the CUDA post-install actions
    So Tensorflow can find your CUDA installation and use it properly, you need to add these lines to the end of you ~/.bashrc or ~/.zshrc.

    export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

step6:Install Tensorflow GPU
    pip install --upgrade tensorflow-gpu


check if tensorflow-gpu works:
    python3
    >>>import tensorflow as tf
    >>>sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

留言

這個網誌中的熱門文章

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