系统配置

系统版本: Centos7.6

语言: Python3.5(anaconda3 4.2)

框架: Tensorflow

安装依赖

  1. sudo yum 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 curl

安装 NVIDIA 驱动 和 CUDA

  1. curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
  2. sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
  3. sudo dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
  4. sudo apt-get update
  5. sudo apt-get install cuda-9-0
  6. # 这一步有可能报错,出现
  7. # trying to replace " /usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0 ",which
  8. # belong to the package libglx-mesa0:amd64 18.0.0~rc5-1ubuntu1
  9. # errors have been encountered during the execution of :
  10. # /var/cuda-repo-9-2-local/./nvidia-396_396.26-0ubuntu1_amd64.deb
  11. # 或者类似,请尝试
  12. # dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-xxx
  13. # 参见 https://askubuntu.com/questions/1037982/nividia-396-installation-blocked-by-libglx-on-18-04
  14. # 重启
  15. sudo reboot
  16. # 检查驱动安装
  17. nvidia-smi
  18. 如下图 (双 GPU)
  19. +-----------------------------------------------------------------------------+
  20. | NVIDIA-SMI 396.44 Driver Version: 396.44 |
  21. |-------------------------------+----------------------+----------------------+
  22. | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
  23. | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
  24. |===============================+======================+======================|
  25. | 0 Tesla P4 Off | 00000000:00:07.0 Off | 0 |
  26. | N/A 37C P0 22W / 75W | 0MiB / 7611MiB | 0% Default |
  27. +-------------------------------+----------------------+----------------------+
  28. | 1 Tesla P4 Off | 00000000:00:08.0 Off | 0 |
  29. | N/A 37C P0 23W / 75W | 6722MiB / 7611MiB | 0% Default |
  30. +-------------------------------+----------------------+----------------------+

Install cudnn

  1. tar -zxvf cudnn-9.0-linux-x64-v7.1.solitairetheme8
  2. sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
  3. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d
  4. sudo chmod a+r /usr/local/cuda/include/cudnn.h
  5. sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

配置环境变量 ~/.bashrc:

  1. export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
  2. export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
  3. export CUDA_HOME=/usr/local/cuda
  4. export PATH="$PATH:/usr/local/cuda/bin"
  5. # 刷新
  6. source ~/.bashrc

安装 Python 环境 (miniconda)

  1. wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  2. bash Miniconda3-latest-Linux-x86_64.sh
  3. # press s to skip terms
  4. # Do you approve the license terms? [yes|no]
  5. # yes
  6. # Miniconda3 will now be installed into this location:
  7. # accept the location
  8. # 如果错误信息:bunzip2: command not found
  9. yum install -y bzip2
  10. # Do you wish the installer to prepend the Miniconda3 install location
  11. # to PATH in your /home/ghost/.bashrc ? [yes|no]
  12. # yes
  13. source ~/.bashrc

Create conda env to install tf

  1. conda create -n tensorflow
  2. # press y a few times

Activate env

  1. source activate tensorflow

安装带 gpu 的 tensorflow 版本

  1. pip install tensorflow-gpu -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

测试安装结果

  1. # start python shell
  2. python
  3. # run test script
  4. import tensorflow as tf
  5. hello = tf.constant('Hello, TensorFlow!')
  6. sess = tf.Session()
  7. print(sess.run(hello))
  8. # 正常会在 nvidia-smi 看到(双 gpu)
  9. +-----------------------------------------------------------------------------+
  10. | NVIDIA-SMI 396.44 Driver Version: 396.44 |
  11. |-------------------------------+----------------------+----------------------+
  12. | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
  13. | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
  14. |===============================+======================+======================|
  15. | 0 Tesla P4 Off | 00000000:00:07.0 Off | 0 |
  16. | N/A 38C P0 23W / 75W | 7241MiB / 7611MiB | 0% Default |
  17. +-------------------------------+----------------------+----------------------+
  18. | 1 Tesla P4 Off | 00000000:00:08.0 Off | 0 |
  19. | N/A 37C P0 23W / 75W | 7387MiB / 7611MiB | 0% Default |
  20. +-------------------------------+----------------------+----------------------+
  21. +-----------------------------------------------------------------------------+
  22. | Processes: GPU Memory |
  23. | GPU PID Type Process name Usage |
  24. |=============================================================================|
  25. | 0 54501 C python 7231MiB |

如何在CentOS上安装Tensorflow的gpu版本?的更多相关文章

  1. 如何在CentOS上安装一个2048小游戏

    如何在centos上安装一个2048小游戏 最近在学习CentOS系统,就琢磨着玩点什么,然后我看到有人在玩2048小游戏,所有我就在想,为啥不装一个2048小游戏搞一下嘞,于是乎,我就开始工作啦 由 ...

  2. 如何在centos上安装epel源

    一.EPEL是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/Cent ...

  3. Ubuntu 14.04 64bit 安装tensorflow(GPU版本)

    本博客主要用于在Ubuntu14.04 64bit 操作系统上搭建google开源的深度学习框架tensorflow. 0.安装CUDA和cuDNN 如果要安装GPU版本的tensorflow,就必须 ...

  4. linux 安装tensorflow(gpu版本)

    一.安装cuda 具体安装过程见我的另一篇博客,ubuntu16.04下安装配置深度学习环境 二.安装tensorflow 1.具体安装过程官网其实写的比较详细,总结一下的话可以分为两种:安装rele ...

  5. windows10安装tensorflow的gpu版本(pip3安装方式)

    前言: TensorFlow 有cpu和 gpu两个版本:gpu版本需要英伟达CUDA 和 cuDNN 的支持,cpu版本不需要:本文主要安装gpu版本. 1.环境 gpu:确认你的显卡支持 CUDA ...

  6. 【图文】如何在centos上安装tomcat

    先到tomcat官网下载安装包(随便下载你想要的版本) 假设你现在使用的是windows系统 那么就把你下载来的压缩包解压,放到一个目录中 在你本地的windows系统中安装个xshell和xftp ...

  7. 如何在Centos上安装python3.4

    Centos上面默认的Python版本是2.6,本文介绍如何安装3.4版本. 0.下载前准备 需要安装以下库,不然会有问题. yum -y install zlib-devel bzip2-devel ...

  8. 如何在 CentOS 上安装 dos2unix 和 unix2dos 命令

    yum install -y dos2unix 注意:以上安装包既包含 dos2unix 命令,又包含 unix2dos 命令.

  9. Centos上安装python3.5以上版本

    一.准备工作: yum install zlib-devel yum install openssl-devel 二.安装python3.5 wget https://www.python.org/f ...

随机推荐

  1. 使用Qt自动注册Lav

    Qt播放视频使用QMediaPlayer要注册Lav解码器,如果手动去注册,每次去使用管理员运行命令或者生成.bat文件都比较麻烦. 解决方法步骤如下: 一:编写注册Lav解码器脚本,并取消控制台的显 ...

  2. Lighthouse

    北大程郁缀教授: 一,"日月之行,若出其中,星汉灿烂,若出其里."要找机会去感受大海,男人要有大海一样的胸怀,大气者方能成大器. 二,"亦余心之所善兮,虽九死其而未悔.& ...

  3. CInternetSession的简单使用

    1. CInternetSession的简单使用 CInternetSession session; CHttpFile *file = NULL; CString strURL = " h ...

  4. Python常用库 - logging日志库

    logging的简单介绍 用作记录日志,默认分为六种日志级别(括号为级别对应的数值) NOTSET(0) DEBUG(10) INFO(20) WARNING(30) ERROR(40) CRITIC ...

  5. 【题解】P1559 运动员最佳匹配问题

    [题目](https://www.luogu.com.cn/problem/P1559) 题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组 ...

  6. node - 简单的爬虫案例

    cherrio模块 安装 cnpm install cherrio 使用方法 const cheerio = require('cheerio') const $ = cheerio.load('&l ...

  7. 使用jQuery的插件jquery.corner.js来实现圆角效果-详解

    jquery.corner.js可以实现各种块级元素的角效果,以下为演示,详见jquery_corner.html中的注释部分,并附百度盘下载 jquery_corner.html代码如下: < ...

  8. VFP 用 SPT 来发布一条 SELECT 到一个新的 SQL Server 表

    为了发布一条 SQL SELECT 语句来创建一个新的 SQL Server 表,  SQL Server 数据库的 select into/bulkcopy 选项必须是可用的. 在默认情况下, 对于 ...

  9. OSPF RFC2740

    2.5. Use of link-local addresses IPv6 link-local addresses are for use on a single link, for purpose ...

  10. .gitignore配置规则

    1.gitignore文件 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 .gitignore 文件的方法.这个文件每一行保存了一个匹配的规则例如: # 此为注释 – 将被 ...