Ubuntu16 installs GPU version TensorFlow (personal laptop)

Thinking about starting to learn tf, how can I not use GPU, I checked it online and found itGeForce GTX确实支持GPU运算,所以就尝试部署了一下,在这里记录一下,避免大家少走弯路。

Use a personal laptop thinkpadE570, memory 4G, graphics cardGeForce GTX 950M

In the early stage, the computer has been installed with win0+Ubuntu16 dual system, and thinkpad installs win0+Ubuntu16 configuration by referring to here (I am for convenience)

The installation sequence is:

(1) Install NVIDIA Driver

  安装电脑对应的显卡驱动,安装完成能够在程序中找到NVIDIA。和windows驱动类似,不再赘述。

  File ( GTX950 ): NVIDIA-Linux-x86_64-390.48.run

(2) Install CUDA. CUDA (Compute Unified Device Architecture) is a general computing architecture based on a new parallel programming model and instruction set architecture launched by NVIDIA. It can utilize the parallel computing engine of NVIDIA GPU and is more efficient than CPU. to solve many complex computing tasks.

  Not recommendedsudo apt-get install nvidia-375安装,国内速度太慢,建议下载安装包,官网地址,选择选择runfile下载,

  文件GTX950cuda_8.0.61_375.26_linux-run

(3) Install cuDNN, NVIDIA cuDNN is a GPU-accelerated library for deep neural networks.

  The direct download is also very slow and requires registration. Here, the address on the Baidu network disk is used .

  File (GTX950) : cudnn-8.0-linux-x64-v6.0.tgz

(4) Installationgpu版本TensorFlow,下载地址,github地址:https://github.com/tensorflow/tensorflow

  文件GTX950tf_nightly_gpu-1.head-cp27-none-linux_x86_64.whl

start installation:

Check the graphics card information first

$sudo lshw -numeric -C display
       description: 3D controller
       product: GM107M [GeForce GTX 950M] [10DE:139A]
       vendor: NVIDIA Corporation [10DE]
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a2
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=nvidia latency=0
       resources: irq:136 memory:f1000000-f1ffffff memory:c0000000-cfffffff memory:d0000000-d1ffffff ioport:d000(size=128)
$ ubuntu-drivers devices
  == /sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0 ==
  modalias : pci:v000010DEd0000139Asv000017AAsd0000505Cbc03sc02i00
  vendor   : NVIDIA Corporation
  model    : GM107M [GeForce GTX 950M]
  driver   : nvidia-361 - distro non-free
  driver   : nvidia-384 - third-party non-free recommended
  driver   : xserver-xorg-video-nouveau - distro free builtin


(1)安装驱动
sudo apt-get install nvidia-384
如果速度慢,官网下载,地址
选择合适的版本,然后用安装包安装。E570版本

(2)安装CUDA
$ sudo sh cuda_8.0.61_375.26_linux-run --override
然后安装引导界面,交互界面,开始的Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?选择n,因为你已经安装驱动了。
Using more to view the EULA.
End User License Agreement
--------------------------


Preface
-------

The following contains specific license terms and conditions
for four separate NVIDIA products. By accepting this
agreement, you agree to comply with all the terms and
conditions applicable to the specific product(s) included
herein.


NVIDIA CUDA Toolkit


Description

The NVIDIA CUDA Toolkit provides command-line and graphical
tools for building, debugging and optimizing the performance
of applications accelerated by NVIDIA GPUs, runtime and math
libraries, and documentation including programming guides,
user manuals, and API references. The NVIDIA CUDA Toolkit
License Agreement is available in Chapter 1.


Default Install Location of CUDA Toolkit

Windows platform:

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit? 
(y)is /(n)o/ (q)uit: y

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

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

Install the CUDA 8.0 Samples? 
(y)is /(n)o/ (q)uit: y

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

Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Missing recommended library: libXmu.so

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

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

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

Please make sure that
 -   PATH includes /usr/local/cuda-8.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.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_17494.log
加入环境变量:
export PATH="$PATH:/usr/local/cuda-8.0/bin" export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64"

$ nvidia-smi
Tue May  1 15:09:50 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111                Driver Version: 384.111                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 950M    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P5    N/A /  N/A |    342MiB /  2002MiB |      8%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1071      G   /usr/lib/xorg/Xorg                            49MiB |
|    0      3202      G   /usr/lib/xorg/Xorg                           129MiB |
|    0      3700      G   compiz                                       114MiB |
|    0       4084       G fcitx-qimpanel 8MiB |
|    0      4754      G   /usr/lib/firefox/firefox                       1MiB |
+-----------------------------------------------------------------------------+

     Successful installation!

(3)安装cuDNN
$ tar xvzf cudnn-8.0-linux-x64-v6.0.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*
(4)安装TensorFlow
pip install wheel
sudo pip install tf_nightly_gpu-1.head-cp27-none-linux_x86_64.whl
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

  搞定!




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325082317&siteId=291194637