Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ringsaturn/1986d4485bb16a03f430b0337000e20c to your computer and use it in GitHub Desktop.
Save ringsaturn/1986d4485bb16a03f430b0337000e20c to your computer and use it in GitHub Desktop.

Revisions

  1. @ksopyla ksopyla revised this gist Feb 26, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu16_tensorflow_cuda8.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # This is shorthened version of blog post
    # http://ksopyla.com/tensorflow-gpu-virtualenv
    # http://ksopyla.com/2017/02/tensorflow-gpu-virtualenv-python3/

    # update packages
    sudo apt-get update
  2. @ksopyla ksopyla created this gist Feb 26, 2017.
    79 changes: 79 additions & 0 deletions ubuntu16_tensorflow_cuda8.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    # This is shorthened version of blog post
    # http://ksopyla.com/tensorflow-gpu-virtualenv

    # update packages
    sudo apt-get update
    sudo apt-get upgrade

    #Add the ppa repo for NVIDIA graphics driver
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update

    #Install the recommended driver (currently nvidia-378)
    sudo ubuntu-drivers autoinstall
    sudo reboot

    #check if drivers were installed
    nvidia-smi



    #############################################
    # Instal CUDA Toolkit 8.0 for x64 Ubuntu 16.04
    wget -O cuda_8_linux.run https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
    sudo chmod +x cuda_8_linux.run
    ./cuda_8.0.61_375.26_linux.run

    #Do you accept the previously read EULA?
    #accept
    #Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
    #n (we installed drivers previously)
    #Install the CUDA 8.0 Toolkit?
    #y
    #Enter Toolkit Location:
    #/usr/local/cuda-8.0 (enter)
    #Do you wish to run the installation with ‚sudo’?
    #y
    #Do you want to install a symbolic link at /usr/local/cuda?
    #y
    #Install the CUDA 8.0 Samples?
    #y
    #Enter CUDA Samples Location:
    #enter

    # Install cuDNN
    # go to website and download cudnn-8 https://developer.nvidia.com/cudnn
    tar -zxvf cudnn-8.0-linux-x64-v5.1.tgz

    # copy libs to /usr/local/cuda folder
    sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
    sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
    sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

    # isntall python 3 and virtual env
    sudo apt install python3-pip
    sudo apt install python3-venv

    # create virtual environment for tensorflow
    python3 -m venv tfenv
    source tfenv/bin/activate

    # Instal tensorflow package with gpu support
    (tfenv)$ pip install tensorflow-gpu
    #or CPU version
    (tfenv)$ pip install tensorflow


    # check installation, run simple python scipt from console
    $ python

    import tensorflow as tf
    I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
    I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
    I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
    I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally
    I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
    tf_session = tf.Session()
    x = tf.constant(1)
    y = tf.constant(1)
    print(tf_session.run(x + y))