设为首页 收藏本站
查看: 923|回复: 0

[经验分享] Install GPU TensorFlow From Sources w/ Ubuntu 16.04 and Cuda 8.0-IT技术学习与交流

[复制链接]

尚未签到

发表于 2018-4-30 08:23:37 | 显示全部楼层 |阅读模式
  In this tutorial I will be going through the process of building the latest TensorFlow from sources for Ubuntu 16.04.  TensorFlow now supports using Cuda 8.0 & CuDNN 5.1 so you can use the pip’s from their website for a much easier install.  If you would like to install into a Anaconda environment the easiest method is to ‘conda install pip’ and just use the pip packages. If you prefer to build from sources using Ubuntu 14.04 please see my other tutorial.
  In order to use TensorFlow with GPU support you must have a Nvidia graphic card with a minimum compute capability of 3.0.
  Getting started I am going to assume you know some of the basics of using a terminal in Linux.
  Install Required Packages


  Open a terminal by pressing Ctrl +>  Paste each line one at a time (without the $) using Shift + Ctrl + V
$ sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev  Update & Install Nvidia Drivers

  You must also have the 367 (or later) NVidia drivers installed, this can easily be done from Ubuntu’s built in additional drivers after you update your driver packages.
$ sudo add-apt-repository ppa:graphics-drivers/ppa  
$ sudo apt update
  Once installed using additional drivers restart your computer.  If you experience any troubles booting linux or logging in: try disabling fast & safe boot in your bios and modifying your grub boot options to enable nomodeset.
Install Nvidia Toolkit 8.0 & CudNN
  Skip if not installing with GPU support
  To install the Nvidia Toolkit  download base installation .run file from Nvidiawebsite.  MAKE SURE YOU SAY NO TO INSTALLING NVIDIA DRIVERS! Also make sure you select yes to creating a symbolic link to your cuda directory.
$ cd ~/Downloads # or directory to where you downloaded file  
$ sudo sh cuda_8.0.44_linux.run --override # hold s to skip
  This will install cuda into: /usr/local/cuda
  To install CudNN download cudNN v5.1 for Cuda 8.0 from Nvidia website and extract into /usr/local/cuda via:
$ sudo tar -xzvf cudnn-8.0-linux-x64-v5.1.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*
  Then update your bash file:
$ gedit ~/.bashrc  This will open your bash file in a text editor which you will scroll to the bottom and add these lines:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"  
export CUDA_HOME=/usr/local/cuda

  Once you save and close the text file you can return to your original terminal and type this command to>$ source ~/.bashrc
Install Bazel
  Instructions also on Bazel website
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list$ curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -  
$ sudo apt-get update
  
$ sudo apt-get install bazel
  
$ sudo apt-get upgrade bazel
  Clone TensorFlow
$ cd ~  
$ git clone https://github.com/tensorflow/tensorflow
  Configure TensorFlow Installation

$ cd ~/tensorflow  
$ ./configure
  Use defaults by pressing enter for all except:
  Please specify the location of python. [Default is /usr/bin/python]:
  For Python 2 use default or If you wish to build for Python 3 enter:
$ /usr/bin/python3.5  Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]:
  For Python 2 use default or If you wish to build for Python 3 enter:
$ /usr/local/lib/python3.5/dist-packages  Unless you have a Radeon graphic card you can say no to OpenCL support. (has anyone tested this? ping me if so!)
  Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]:
$ 8.0  Please specify the Cudnn version you want to use. [Leave empty to use system default]:
$ 5  You can find the compute capability of your device at:https://developer.nvidia.com/cuda-gpus
  If all was done correctly you should see:
  INFO: All external dependencies fetched successfully.
  Configuration finished
  Build TensorFlow

  Warning Resource Intensive I recommend having at least 8GB of computer memory.
  If you want to build TensorFlow with GPU support enter:
$ bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package  For CPU only enter:
$ bazel build -c opt //tensorflow/tools/pip_package:build_pip_package  Build & Install Pip Package

  This will build the pip package required for installing TensorFlow in your /tmp/ folder
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg  To Install Using Python 3 (remove sudo if using a virtualenv)
$ sudo pip3 install /tmp/tensorflow_pkg/tensorflow  

  
# with no spaces after tensorflow hit tab before hitting enter to fill in blanks
  For Python 2 (remove sudo if using a virtualenv)
$ sudo pip install /tmp/tensorflow_pkg/tensorflow  

  
# with no spaces after tensorflow hit tab before hitting enter to fill in blanks
  Test Your Installation

  Close all your terminals and open a new terminal to test.
$ python # or python3  
$ import tensorflow as tf
  
$ sess = tf.InteractiveSession()
  
$ sess.close()
  TensorFlow also has instructions on how to do a basic test and a list of common installation problems.
  There you have it, you should now have TensorFlow installed on your computer. This tutorial was tested on a fresh install of Ubuntu 16.04 with a GeForce GTX 780 and a GTX 970m.

  If you want to give your GPU a workout maybe try building a massive image>  https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-453836-1-1.html 上篇帖子: Ubuntu系统主题及插件工具等官方地址 下篇帖子: ubuntu16.xxx安装mysql5.0项目迁移环境搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表