美文网首页
ubuntu16.0+cuda8.0+tensorflow1.4

ubuntu16.0+cuda8.0+tensorflow1.4

作者: 从今以后_19d7 | 来源:发表于2019-10-22 10:41 被阅读0次

一、前言

学习Deeplearning21个实例

先看效果

GPU加速的情况下,CPU资源得到节省。但其实也很消耗CPU的。完全用CPU跑的话,CPU使用率接近100%的。
所以在使用GPU加速的情况下CPU也不能太低的

屏幕快照 2019-10-22 上午11.13.26.png

GPU使用情况

屏幕快照 2019-10-22 上午11.18.46.png

1.卸载cuda9.0

/usr/local/cuda-9.0/bin/uninstall_cuda_9.0.pl
/usr/bin/nvidia-uninstall # 卸载显卡驱动

二、环境

这里的版本都是经过多次调试后确定的,不能有误。前提是tensorflow1.4的要求

  • ubuntu16.04
  • cuda8.0
  • python2.7 书上的代码需要这个版本
  • tensorflow1.4
  • cudnn6.0 书上的代码是需要6.0 这个版本
  • tensorboard==1.6.0
  • numpy==1.14.0

查看ubuntu的版本

root@z600:~/cuda8.0# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial

1. 安装cuda8.0

a. 下载

下载地址

按照下图选择要下载的版本


选择下载版本

然后下载所有的附件,这里的下载速度会比较快


下载所有的附件
root@z600:~/cuda8.0# ll -h

总用量 1.5G
drwxr-xr-x 2 root root 4.0K 10月 22 09:46 ./
drwx------ 9 root root 4.0K 10月 22 09:56 ../
-rw-r--r-- 1 root root 94M 6月 28 2017 cuda_8.0.61.2_linux.run
-rw-r--r-- 1 root root 1.4G 2月 2 2017 cuda_8.0.61_375.26_linux.run

b.安装cuda

sh cuda_8.0.61_375.26_linux.run

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n
即这一项不安装。

c.添加环境变量

# /etc/profile
export PATH=$PATH:/usr/local/cuda-8.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64

3. 安装cudnn

下载cudnn-8.0-linux-x64-v6.0.tgz
解压安装包

root@z600:~/cuda8.0# tar -xzvf cudnn-8.0-linux-x64-v6.0.tgz

cuda/include/cudnn.h
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.6
cuda/lib64/libcudnn.so.6.0.21
cuda/lib64/libcudnn_static.a

复制安装

root@z600:~/cuda8.0# cp cuda/include/cudnn.h /usr/local/cuda/include/
root@z600:~/cuda8.0# cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

增加权限

root@z600:~/cuda8.0# chmod a+r /usr/local/cuda/include/cudnn.h   /usr/local/cuda/lib64/libcudnn*

tensorflow安装

清华镜像下载安装 Anaconda2-5.3.1-Linux-x86_64.sh。这个版本是python2.7的。

设置pip镜像

pys@z600:~$ cat .pip/pip.conf 

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

安装tensorflow

 pip install tensorflow-gpu==1.4.0

测试安装成果

pys@z600:~$ cat text.py 

Python

-- coding: UTF-8 --

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
with tf.device('gpu:0'):
sess = tf.Session()
print(sess.run(hello))

pys@z600:~$ python text.py 

2019-10-22 10:54:24.540655: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
2019-10-22 10:54:25.428398: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-10-22 10:54:25.428893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.7085
pciBusID: 0000:0f:00.0
totalMemory: 7.93GiB freeMemory: 7.84GiB
2019-10-22 10:54:25.428927: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:0f:00.0, compute capability: 6.1)
Hello, TensorFlow!

出现问题

ImportError: libcuda.so.1: cannot open shared object file: No such file or directory

这是因为上面把显卡驱动给删掉了
重新安装显卡驱动

root@z600:~/ivida# ./NVIDIA-Linux-x86_64-430.50.run 

Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 430.50..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

好多次安装显卡驱动之后,界面都无法显示了。找到一篇帖子,还没有研究,反正我是远程登录,用不到界面。
https://www.cnblogs.com/Qwells/p/6086773.html

numpy 版本问题

AttributeError: 'numpy.ufunc' object has no attribute 'module'

pys@z600:~$ pip freeze|grep numpy

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
numpy==1.16.5
numpydoc==0.8.0

多执行几次卸载,一直到没有东西可下载位置

pys@z600:~$ pip uninstall numpy

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Uninstalling numpy-1.16.5:
Would remove:
/home/pys/anaconda2/bin/f2py
/home/pys/anaconda2/bin/f2py2
/home/pys/anaconda2/bin/f2py2.7
/home/pys/anaconda2/lib/python2.7/site-packages/numpy-1.16.5.dist-info/*
/home/pys/anaconda2/lib/python2.7/site-packages/numpy/*
Proceed (y/n)? y
Successfully uninstalled numpy-1.16.5

安装1.12.1

pys@z600:~$ pip install numpy==1.12.1

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy==1.12.1
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f9/d5/f24f86b51298f171826a398efdd64b5214b687a28a2f05ff736b1505b1b2/numpy-1.12.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.12.1

相关文章

  • ubuntu16.0+cuda8.0+tensorflow1.4

    一、前言 学习Deeplearning21个实例 先看效果 GPU加速的情况下,CPU资源得到节省。但其实也很消耗...

网友评论

      本文标题:ubuntu16.0+cuda8.0+tensorflow1.4

      本文链接:https://www.haomeiwen.com/subject/panfvctx.html