安搭
软件安装搭建教程网是专门为软件开发、IT运维人员提供Apache、Centos、dotNET、Eclipse、Ftp、Git、java、mssqlserver、MySQL、Nginx、php、python、Redis、SVN、Vscode、VUE等服务器服务系统的安装教程、搭建教程、配置教程信息网。

ubuntu16.04安装python3.6.5并配置tensorflow1.7_在Ubuntu16.04的系统下安装TensorFlow1.7.0GPU版本...

本教程不会教你怎么安装Ubuntu16.04系统,如果你不会,那就去学习,网上教程很多。

安装须知:

1.请在你的电脑上安装Ubuntu16.04系统,而不是虚拟机,最好是新装系统并且没有安装Nvidia驱动。

2.请在你的电脑上安装一块大于3算力的Nvidia显卡,查看Nvidia显卡算力。

3.我已经为你准备好了安装所需软件包。请把其下载下来免去你下载失败的问题。如果链接失效,请在下面评论区留言。

开始安装:

1.检查你的显卡型号

sudo lshw -numeric -C display

你会看到如下信息:

*-display

description: VGA compatible controller

product: GM206 [GeForce GTX 960] [10DE:1401]

vendor: NVIDIA Corporation [10DE]

physical id: 0

bus info: pci@0000:01:00.0

version: a1

width: 64 bits

clock: 33MHz

capabilities: pm msi pciexpress vga_controller bus_master cap_list rom

configuration: driver=nvidia latency=0

resources: irq:125 memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:e000(size=128) memory:c0000-dffff

我的显卡为GTX960 在官网上可以查到我的算力是5.2

2.查找你的显卡适合的驱动版本

ubuntu-drivers devices

你会看到如下信息:

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==

modalias : pci:v000010DEd00001401sv00007377sd00000000bc03sc00i00

model : GM206 [GeForce GTX 960]

vendor : NVIDIA Corporation

driver : nvidia-384 - distro non-free recommended

driver : xserver-xorg-video-nouveau - distro free builtin

我的显卡所需驱动为nvidia-384

3.安装你的显卡驱动

sudo apt install nvidia-384

4.下载我所提供的软件包:

请把这些安装包放在同一目录下,然后进入该目录下。

5.安装cuda

sudo sh cuda_9.0.176_384.81_linux.run

首先会跳出一段文字,直接Ctrl+C,然后依照下面的输入就行(我偷懒从网上找来的,cuda8版本的和cuda9是一样)

简化就是accept(enter),n(enter),y(enter),enter,y(enter),y(enter),enter

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)es/(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)es/(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 with the name of this run file:

sudo .run -silent -driver

Logfile is /tmp/cuda_install_17494.log

cuda 就安装好了

6.添加环境变量

编辑.bashrc 文件:

vim ~/.bashrc

在文件最后添加:

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

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

export CUDA_HOME=/usr/local/cuda

说明:

前 2 个(PATH, LD_LIBRARY_PATH) 是 CUDA 官网安装文档中建议的变量。

第 3 个(CUDA_HOME)是 tensorflow-GPU 版本要求的变量。

最后激活:

source ~/.bashrc

汉语部分全为解释语句,请不要复制。这时一般重启一下系统。

7.检查显卡驱动安装结果

nvidia-smi

你会看到如下结果:

Thu Apr 19 15:34:45 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 960 Off | 00000000:01:00.0 On | N/A |

| 27% 35C P0 29W / 120W | 620MiB / 4035MiB | 0% Default |

+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+

| Processes: GPU Memory |

| GPU PID Type Process name Usage |

|=============================================================================|

| 0 1122 G /usr/lib/xorg/Xorg 304MiB |

| 0 2000 G compiz 167MiB |

| 0 2210 G fcitx-qimpanel 8MiB |

| 0 7675 G /proc/self/exe 135MiB |

+-----------------------------------------------------------------------------+

如果没有显示,则说明安装失败。

8.安装深度学习库cuDNN

sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb

sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb

sudo dpkg -i libcudnn7-doc_7.0.5.15-1+cuda9.0_amd64.deb

sudo apt -f install

请按照顺序来安装,要不然会出错

9.安装Anaconda

sh Anaconda3-5.1.0-Linux-x86_64.sh

这个不可以用Ctrl+C跳过条款(不要问我问什么,我试过!)

一直按空格,然后按说明来安装,最后会提示你让你安装VSCode,看你爱好了。(反正我用不惯)

一般重启一下系统。

10.创建虚拟环境tensorflow

conda create -n tensorflow python==3.6

source activate tensorflow

第二句为激活tensorflow环境

11.安装tensorflow-gpu

pip install tensorflow_gpu-1.7.0-cp36-cp36m-linux_x86_64.whl -i https://pypi.douban.com/simple

pip install pandas -i https://pypi.douban.com/simple

pip install pillow -i https://pypi.douban.com/simple

pip install jupyter -i https://pypi.douban.com/simple

这样就安装好tensorflow了,可以测试是否正确安装。

12.测试(参考车神的文章)

sudo apt install protobuf-compiler

下载代码:

git clone https://github.com/tensorflow/models

第一步测试

cd models/samples/core/get_started/

python premade_estimator.py

成功之后最后会出现以下三句话:

Prediction is "Setosa" (99.9%), expected "Setosa"

Prediction is "Versicolor" (99.1%), expected "Versicolor"

Prediction is "Virginica" (98.8%), expected "Virginica"

第二步测试

cd ~/models/research/

protoc object_detection/protos/*.proto --python_out=.

没有输出任何提示信息,说明成功。

jupyter notebook

然后进入object_detection 文件夹,然后打开 object_detection_tutorial.ipynb

按照下图所示运行

最后结果如下图所示:

打开App,阅读手记

文章来源:https://blog.csdn.net/weixin_39992788/article/details/111006269