如何在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 ...
随机推荐
- 21种JavaScript设计模式最新记录(含图和示例)
最近观看了<Javascript设计模式系统讲解与应用>教程,对设计模式有了新的认识,特在此做些记录. 一.UML 文中会涉及众多的UML类图,在开篇需要做点基础概念的认识.以下面的图为例 ...
- kubernetes从私有仓库下载遇到的坑
1.必须要在所有的k8s节点上配置私有仓库的地址.(master和node) 2.创建secret kubectl create secret docker-registry secret名字 --d ...
- non-local static 变量初始化顺序不确定,带来的问题
所谓static对象,其寿命从被构造出来直到程序结束为止,因此stack和heap-based对象都被排除.这种对象包括global对象.定义于namespace作用域内的对象,classes内.在函 ...
- SpringMVC基础(二)_文件上传、异常处理、拦截器
实现文件上传 实现文件上传,需要借助以下两个第三方 jar 包对上传的二进制文件进行解析: commons-fileupload commons-io form表单的 enctype 取值必须为:mu ...
- GitHub注册与Git安装
注册GitHub GitHub官网 ☞☞☞☞[戳我] 一.打开,如下图所示, 按照要求进行注册. 安装Git Git官网下载☞☞☞☞ [戳我] 一.打开,根据自己的电脑系统选择不同的版本,这里主要是以 ...
- Java查找数组重复元素,并打印重复元素、重复次数、重复元素位置
面试题查找重复元素并打印重复次数和重复位置,一顿懵逼,回来死磕写下来,打印指定重复次数和最大次数,其他在此基础上可以再更新 package sort; import org.testng.annota ...
- [win]更改win终端编码
更改cmd的编码格式 chcp: 显示当前的编码格式 chcp 65001: 更改当前编码格式为UTF-8 字体选择`Lucida Console` 更改PowerShell编码格式(from zhi ...
- Codeforces_801
A.直接暴力就行了,先把能组合的按线性组合掉,再枚举剩下相邻没用过的. #include<bits/stdc++.h> using namespace std; string s; ] = ...
- Python原来这么好学-1.1节: 在windows中安装Python
这是一本教同学们彻底学通Python的高质量学习教程,认真地学习每一章节的内容,每天只需学好一节,帮助你成为一名卓越的Python程序员: 本教程面向的是零编程基础的同学,非科班人士,以及有一定编程水 ...
- error C2338: No Q_OBJECT in the class with the signal (NodeCreator.cpp)
在Qt中,当派生类需要用到信号与槽机制时,有两个要求. 1.该类派生自QObject类. 2.类中有Q_OBJECT宏. 本次报错的原因就是因为没有在类中添加Q_OBJECT宏. 而我的出错原因更傻逼 ...