如何在CentOS上安装Tensorflow的gpu版本?
系统配置
系统版本: Centos7.6
语言: Python3.5(anaconda3 4.2)
框架: Tensorflow
安装依赖
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
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-9-0
# 这一步有可能报错,出现
# trying to replace " /usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0 ",which
# belong to the package libglx-mesa0:amd64 18.0.0~rc5-1ubuntu1
# errors have been encountered during the execution of :
# /var/cuda-repo-9-2-local/./nvidia-396_396.26-0ubuntu1_amd64.deb
# 或者类似,请尝试
# dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-xxx
# 参见 https://askubuntu.com/questions/1037982/nividia-396-installation-blocked-by-libglx-on-18-04
# 重启
sudo reboot
# 检查驱动安装
nvidia-smi
如下图 (双 GPU)
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.44 Driver Version: 396.44 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla P4 Off | 00000000:00:07.0 Off | 0 |
| N/A 37C P0 22W / 75W | 0MiB / 7611MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla P4 Off | 00000000:00:08.0 Off | 0 |
| N/A 37C P0 23W / 75W | 6722MiB / 7611MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
Install cudnn
tar -zxvf cudnn-9.0-linux-x64-v7.1.solitairetheme8
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
配置环境变量 ~/.bashrc:
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda
export PATH="$PATH:/usr/local/cuda/bin"
# 刷新
source ~/.bashrc
安装 Python 环境 (miniconda)
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# press s to skip terms
# Do you approve the license terms? [yes|no]
# yes
# Miniconda3 will now be installed into this location:
# accept the location
# 如果错误信息:bunzip2: command not found
yum install -y bzip2
# Do you wish the installer to prepend the Miniconda3 install location
# to PATH in your /home/ghost/.bashrc ? [yes|no]
# yes
source ~/.bashrc
Create conda env to install tf
conda create -n tensorflow
# press y a few times
Activate env
source activate tensorflow
安装带 gpu 的 tensorflow 版本
pip install tensorflow-gpu -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
测试安装结果
# start python shell
python
# run test script
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
# 正常会在 nvidia-smi 看到(双 gpu)
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.44 Driver Version: 396.44 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla P4 Off | 00000000:00:07.0 Off | 0 |
| N/A 38C P0 23W / 75W | 7241MiB / 7611MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla P4 Off | 00000000:00:08.0 Off | 0 |
| N/A 37C P0 23W / 75W | 7387MiB / 7611MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 54501 C python 7231MiB |
如何在CentOS上安装Tensorflow的gpu版本?的更多相关文章
- 如何在CentOS上安装一个2048小游戏
如何在centos上安装一个2048小游戏 最近在学习CentOS系统,就琢磨着玩点什么,然后我看到有人在玩2048小游戏,所有我就在想,为啥不装一个2048小游戏搞一下嘞,于是乎,我就开始工作啦 由 ...
- 如何在centos上安装epel源
一.EPEL是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/Cent ...
- Ubuntu 14.04 64bit 安装tensorflow(GPU版本)
本博客主要用于在Ubuntu14.04 64bit 操作系统上搭建google开源的深度学习框架tensorflow. 0.安装CUDA和cuDNN 如果要安装GPU版本的tensorflow,就必须 ...
- linux 安装tensorflow(gpu版本)
一.安装cuda 具体安装过程见我的另一篇博客,ubuntu16.04下安装配置深度学习环境 二.安装tensorflow 1.具体安装过程官网其实写的比较详细,总结一下的话可以分为两种:安装rele ...
- windows10安装tensorflow的gpu版本(pip3安装方式)
前言: TensorFlow 有cpu和 gpu两个版本:gpu版本需要英伟达CUDA 和 cuDNN 的支持,cpu版本不需要:本文主要安装gpu版本. 1.环境 gpu:确认你的显卡支持 CUDA ...
- 【图文】如何在centos上安装tomcat
先到tomcat官网下载安装包(随便下载你想要的版本) 假设你现在使用的是windows系统 那么就把你下载来的压缩包解压,放到一个目录中 在你本地的windows系统中安装个xshell和xftp ...
- 如何在Centos上安装python3.4
Centos上面默认的Python版本是2.6,本文介绍如何安装3.4版本. 0.下载前准备 需要安装以下库,不然会有问题. yum -y install zlib-devel bzip2-devel ...
- 如何在 CentOS 上安装 dos2unix 和 unix2dos 命令
yum install -y dos2unix 注意:以上安装包既包含 dos2unix 命令,又包含 unix2dos 命令.
- Centos上安装python3.5以上版本
一.准备工作: yum install zlib-devel yum install openssl-devel 二.安装python3.5 wget https://www.python.org/f ...
随机推荐
- 使用Qt自动注册Lav
Qt播放视频使用QMediaPlayer要注册Lav解码器,如果手动去注册,每次去使用管理员运行命令或者生成.bat文件都比较麻烦. 解决方法步骤如下: 一:编写注册Lav解码器脚本,并取消控制台的显 ...
- Lighthouse
北大程郁缀教授: 一,"日月之行,若出其中,星汉灿烂,若出其里."要找机会去感受大海,男人要有大海一样的胸怀,大气者方能成大器. 二,"亦余心之所善兮,虽九死其而未悔.& ...
- CInternetSession的简单使用
1. CInternetSession的简单使用 CInternetSession session; CHttpFile *file = NULL; CString strURL = " h ...
- Python常用库 - logging日志库
logging的简单介绍 用作记录日志,默认分为六种日志级别(括号为级别对应的数值) NOTSET(0) DEBUG(10) INFO(20) WARNING(30) ERROR(40) CRITIC ...
- 【题解】P1559 运动员最佳匹配问题
[题目](https://www.luogu.com.cn/problem/P1559) 题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组 ...
- node - 简单的爬虫案例
cherrio模块 安装 cnpm install cherrio 使用方法 const cheerio = require('cheerio') const $ = cheerio.load('&l ...
- 使用jQuery的插件jquery.corner.js来实现圆角效果-详解
jquery.corner.js可以实现各种块级元素的角效果,以下为演示,详见jquery_corner.html中的注释部分,并附百度盘下载 jquery_corner.html代码如下: < ...
- VFP 用 SPT 来发布一条 SELECT 到一个新的 SQL Server 表
为了发布一条 SQL SELECT 语句来创建一个新的 SQL Server 表, SQL Server 数据库的 select into/bulkcopy 选项必须是可用的. 在默认情况下, 对于 ...
- OSPF RFC2740
2.5. Use of link-local addresses IPv6 link-local addresses are for use on a single link, for purpose ...
- .gitignore配置规则
1.gitignore文件 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 .gitignore 文件的方法.这个文件每一行保存了一个匹配的规则例如: # 此为注释 – 将被 ...