tensorflow installation guide


ABSTRACT

descripe :
date     : 2018.06.06
platform : NVIDIA GeForce 1080Ti
version  : ubuntu        - 16.04 LTS(自带的是python3.5,所以在安装tensorflow时,需要注意版本)
           NVIDIA-driver - 384.13
           CUDA          - 9.0
           cuDNN         - 7.1.2
           tensorflow    - 1.8
      

 ==========================

首先在search your computer中输入upd,进入software&updates,更改下载源(推荐清华或阿里作为下载源。)

 首先sudo apt update,然后sudo apt upgrade


==========================

STEP I : install nvidia driver

reference : https://blog.csdn.net/u012759136/article/details/53355781

 

修改驱动文件权限

sudo chmod 777 NVIDIA-Linux-x86_64-410.78.run


    1.  sudo apt-get remove –purge nvidia*
    2.  sudo vim /etc/modprobe.d/blacklist.conf (sudo apt-get install vim-gtk)
    3.  add "blacklist nouveau" at the end of file
    4.  sudo update-initramfs -u
    5.  sudo reboot
    6.  Ctrl+Alt+F1
    7.  lsmod | grep nouveau
    8.  sudo /etc/init.d/lightdm stop
    9.  cd ${nvidia_driver_path}
    10. sudo sh NVIDIA-Linux-x86_64-384.130.run –no-x-check –no-nouveau-check –no-opengl-files

安装(注意 参数)


  sudo ./NVIDIA-Linux-x86_64-384.13.run –no-opengl-files

–no-opengl-files 只安装驱动文件,不安装OpenGL文件。这个参数最重要
–no-x-check 安装驱动时不检查X服务
–no-nouveau-check 安装驱动时不检查nouveau 
后面两个参数可不加。

在安装驱动的时候,有一步问你”Would you like to run the nvidia-xconfig utility to automatically update your X configuration file…”什么的,选择 No

    11. sudo reboot

    
    Please run the commands, if the desktop can not login after reboot.
    1. cd /usr/share/X11/xorg.conf.d/
    2. sudo mv nvidia-drm-outputclass.conf nvidia-drm-outputclass.conf.bak
    3. sudo reboot
    
==========================

STEP II : install CUDA

    1. Download CUDA 9.0 at https://developer.nvidia.com/cuda-90-download-archive
       select Linux, x86_64, Ubuntu, 16.04, runfile(local) and download base installer,(the download file name is "cuda_9.0.176_384.81_linux.run")
    2. cd ${cuda_9.0_path}
    3. sudo sh cuda_9.0.176_384.81_linux.run
    4. enter n, y, '\n', y, y, '\n' step by step, like this. ('\n' means enter)

有一个关键是会让你选择是否安装Graphics Driver for Linux-x86_64:XXXX版本,这个地方必须选择no!否则会覆盖之前的驱动。
    
        Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
        (y)es/(n)o/(q)uit: n

        Install the CUDA 9.0 Toolkit?
        (y)es/(n)o/(q)uit: y

        Enter Toolkit Location
         [ default is /usr/local/cuda-9.0 ]:

        Do you want to install a symbolic link at /usr/local/cuda?
        (y)es/(n)o/(q)uit: y

        Install the CUDA 9.0 Samples?
        (y)es/(n)o/(q)uit: y

        Enter CUDA Samples Location
         [ default is /home/ai_group ]:

        Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...
        Missing recommended library: libGLU.so
        Missing recommended library: libX11.so
        Missing recommended library: libXi.so
        Missing recommended library: libXmu.so
        Missing recommended library: libGL.so

        Installing the CUDA Samples in /home/ai_group ...
        Copying samples to /home/ai_group/NVIDIA_CUDA-9.0_Samples now...
        Finished copying samples.

        ===========
        = Summary =
        ===========

        Driver:   Not Selected
        Toolkit:  Installed in /usr/local/cuda-9.0
        Samples:  Installed in /home/ai_group, but missing recommended libraries

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver

Logfile is /tmp/cuda_install_3795.log

liuliu@liuliu:~/Downloads/install required package$ sudo sh cuda_9.0.176_384.81_linux.run -silent -driver

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``

 

 


    5.1 gedit ./.bashrc

 install CUDA 的 5. gedit ./.bashrc,请注意bashrc文件在home路径下,所以需要进入home路径,打开bashrc文件进行编辑。

    5.2 source ~/.bashrc

    5.3 关闭终端,然后再重启一个新的终端,这一步很重要

    6. add environment path at the end
       export PATH=/usr/local/cuda/bin:$PATH
       export LD_LIBRARY_PATH=/usr/local/cuda/lib64$:LD_LIBRARY_PATH
       
==========================

STEP III : install cuDNN

    1. Download cuDNN for CUDA 9.0 at https://developer.nvidia.com/rdp/cudnn-archive

下载解压文件那一项 :cuDNN v7.1.4 Library for Linux
    2. Extract the cuDNN
    3. cd ${cuDNN_extract_folder_path}
    4. sudo cp ./include/cudnn.h /usr/local/cuda/include
    5. sudo cp ./lib64/libcudnn* /usr/local/cuda/lib64
    6. sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
    
==========================

STEP IV : install tensorflow

    1. choose the ailiyun as the default source
    2. sudo apt-get update
    3. sudo apt-get install python3-pip
    4. sudo pip3 install --upgrade pip
    5. pip3 install tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

"downloading https://pypi.tuna.tsinghua.edu.cn/packages/84/d8/00a450ad627c7c5e28ada8a179e6a43854089ea5b30485f896efa5ed5814/tensorflow_gpu-1.11.0-cp35-cp35m-manylinux1_x86_64.whl"

 

5. another method:

download tensorflow-gpu from :  https://pypi.org/project/tensorflow-gpu/

cd ${tensorflow_gpu-1.12.0-cp35-cp35m-manylinux1_x86_64.whl_folder_path}

pip  install tensorflow_gpu-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
    
==========================

STEP V : test

    1. creat an empty document at desktop named "test.py" and enter the code showed below.

        #!/usr/bin/env python3
        import tensorflow as tf
        hello  = tf.constant('Hello,world!')
        sess   = tf.Session()       # creat a conversation
        result = sess.run(hello)    # run
        sess.close()                # close
        print(result)               # show result
        
    2. cd ~/Desktop
    3. python3 test.py
    
Congratulations, if "Hello,world!" is printed at the end. Enjoy!



    
    
    
    

 

    ~~~~~~~~~~~~~~~~~~

nvidia-smi

    ~~~~~~~~~~~~~~~~~~

cudnn版本:

nvcc -V

~~~~~~~~~~~~~~~~~~

 

首先禁掉Secure boot

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~。

一、安装eclipse

1、ubuntu software 搜索eclipse,然后install

2、安装好eclipse后,会提示缺jrc,解决办法:

2.1、sudo apt install synaptic

2.2、在search your computer中,打开synaptic

2.3、在synaptic中选择搜jdk,安装

2.4、打开eclipse,选择Launch the Eclipse Marketplace

2.5、选择Python IDE for Eclipse。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

https://blog.csdn.net/wei_fu/article/details/80913073

python3

import tensorflow

报错:ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

解决方案:sudo ldconfig /usr/local/cuda-9.0/lib64 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

由于tensorflow版本不同,可能一些函数的调用也有变换,这时候可能需要查看tensorflow版本,可以在终端输入查询命令如下:

python

import tensorflow as tf

tf.__version__

查询tensorflow安装路径为:

tf.__path__
 

ubuntu查看 python安装路径

s@s-pc:~/mypython$ which python
/usr/bin/python

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

删除某文件夹:

sudo rm -rf 文件夹名

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

http://www.cnblogs.com/shenba/p/6931331.html

在ubuntu下使用visual studio code编写python

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值