#Ubuntu 18.04 安装tensorflow-gpu 1.9
参考
- https://tensorflow.google.cn/install/install_linux
- http://nvidia.com/cuda
- http://developer.nvidia.com/cudnn
说明
- 前提是机器上必须有Nvidia显卡,不太老就好(古董也没必要玩这个了吧,费电),在Nvidia官网可以查到显卡支持情况 https://developer.nvidia.com/cuda-gpus
- 安装过程中的命令都需要root身份,请使用su root切换或者每次加 sudo,编译运行测试代码使用普通用户就好
踩坑后的提示,怪我眼瞎坑自己,[手动抽脸表情]
- 必须按tensorflow 官网提示的版本安装 1.9 对应 CUDA 9.0,CUDA 9.0 要下载相应版本的cuDNN
- 如果喜欢折腾,建议使用没有重要数据的硬盘
- 安装包最好下载到其他电脑上,使用scp拷贝到安装机上,重装了几遍ubuntu,下一次包就2个G,作为联通40G所谓无线流量卡用户,想着还是蛋疼
下载主要安装文件
- CUDA® 工具包
#http://nvidia.com/cuda
#我选的是16.04的run文件,其他的坑不敢踩了
cuda_9.0.176_384.81_linux.run
- cuDNN 深度神经网络(DNN)开发环境,需要网站注册
#http://developer.nvidia.com/cudnn
libcudnn7-dev_7.1.4.18-1+cuda9.0_amd64.deb
libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb
libcudnn7-doc_7.1.4.18-1+cuda9.0_amd64.deb
准备环境
看CUDA自带的驱动版本,这里是384.81,低于这个版本就要先卸载,>= 跳过
#建议run文件卸载,即你之前下载的Nvidia驱动run文件
chmod +x *.run
./NVIDIA-Linux-x86_64-384.59.run --uninstall
# 不建议采取这种,不知道为什么没尝试过
apt-get remove --purge nvidia*
禁用自带的nouveau驱动,如果你连Nvidia驱动都装过了,这一步也免了
vi /etc/modprobe.d/blacklist.conf
#加两行
blacklist nouveau
options nouveau modeset=0
#生效配置
update-initramfs -u
#重启,后分辨率变低了,毕竟没有显卡驱动了
reboot
#检查是否生效
lsmod | grep nouveau
#如果屏幕没有输出则禁用nouveau成功
安装必要的编译环境否者自带网卡驱动安装不上
apt install gcc g++ make make-guile
针对CUDA 9.0,必须将GCC降级为gcc5,也是安装CUDA时发现的
apt install gcc-5 g++-5
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
安装 CUDA® 工具包
一定要根据tensorflow版本安装对应版本的CUDA 1.9对应9.0,被自己眼瞎害的
chmod +x cuda_9.0.176_384.81_linux.run
sh ./cuda_9.0.176_384.81_linux.run
#会有说明,需要看的自己看,看了几页不想看/条款看不懂的 按q键
- 如果安装过程中提示失败,根据提示查看log排错
- 安装成功后的log
Do you accept the previously read EULA?
accept/decline/quit: accept You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y #这里384.81表示显卡驱动版本,如果本机安装的显卡驱动版本比它高就不需要安装
#选no主要是前面踩坑的时候安了CUDA9.2,呵呵
#正常应该是yes
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: n Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]: Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: y Enter CUDA Samples Location
[ default is /root ]: Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so Installing the CUDA Samples in /root ...
Copying samples to /root/NVIDIA_CUDA-9.0_Samples now...
Finished copying samples. ===========
= Summary =
=========== Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-9.0
Samples: Installed in /root, but missing recommended libraries Please make sure that
- PATH includes /usr/local/cuda-9.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.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-9.0/bin Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.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 384.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run -silent -driver Logfile is /tmp/cuda_install_7657.log /root/NVIDIA_CUDA-9.0_Samples
设置环境变量
vi /etc/ld.so.conf.d/cuda.conf
#写入两行
/usr/local/cuda/lib64
/usr/local/cuda/extras/CUPTI/lib64
vi /etc/profile
#加入两行
export CUDA_HOME=/usr/local/cuda/bin
export PATH=$PATH:$CUDA_HOME
重启 reboot
测试安装情况
- 没有报错就表示安装成功
cd /root/NVIDIA_CUDA-9.0_Samples/samples/1_Utilities/deviceQuery
make
./deviceQuery
# Result = PASS 成功
cd ../bandwidthTest
make
./bandwidthTest
#Result = PASS 成功
cuDNN 安装
NVIDIA cuDNN is a GPU-accelerated library of primitives for deep neural networks.
#cuDNN v7.1.4 Runtime Library for Ubuntu16.04 (Deb)
dpkg -i libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb
#cuDNN v7.1.4 Developer Library for Ubuntu16.04 (Deb)
dpkg -i libcudnn7-dev_7.1.4.18-1+cuda9.0_amd64.deb
#cuDNN v7.1.4 Code Samples and User Guide for Ubuntu16.04 (Deb)
libcudnn7-doc_7.1.4.18-1+cuda9.0_amd64.deb
# 锁定版本,免得自动更新破坏环境
apt-mark hold libcudnn7 libcudnn7-dev
测试
#Copy the cuDNN sample to a writable path.
$cp -r /usr/src/cudnn_samples_v7/ $HOME
#Go to the writable path.
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
#Compile the mnistCUDNN sample.
$make clean && make
#Run the mnistCUDNN sample.
$ ./mnistCUDNN
#If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:
#Test passed!
安装 tensorflow-gpu 以python3为例
sudo apt-get install python3-pip python3-dev
pip3 install tensorflow-gpu
测试安装
#测试代码,保存到比如test.py
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
#执行 python3 test.py
#第一次有点慢
#没报错,有显卡信息,b'Hello, TensorFlow!',表示成功
结束了,老年人继续学习Tensorflow了
#Ubuntu 18.04 安装tensorflow-gpu 1.9的更多相关文章
- 深度学习应用系列(一)| 在Ubuntu 18.04安装tensorflow 1.10 GPU版本
tensorflow目前已经升级至r1.10版本.在之前的深度学习中,我是在MAC的虚拟机上跑CPU版本的tensorflow程序,当数据量变大后,tensorflow跑的非常慢,在内存不足情况下,又 ...
- 真实机下 ubuntu 18.04 安装GPU +CUDA+cuDNN 以及其版本选择(亲测非常实用)【转】
本文转载自:https://blog.csdn.net/u010801439/article/details/80483036 ubuntu 18.04 安装GPU +CUDA+cuDNN : 目前, ...
- [笔记] Ubuntu 18.04安装Docker CE及nvidia-docker2流程
Docker的好处之一,就是在Container里面可以随意瞎搞,不用担心弄崩Host的环境. 而nvidia-docker2的好处是NVidia帮你配好了Host和Container之间的CUDA相 ...
- [笔记] Ubuntu 18.04安装Docker CE及NVIDIA Container Toolkit流程
之前写的[笔记] Ubuntu 18.04安装Docker CE及nvidia-docker2流程已经out了,以这篇为准. Docker的好处之一,就是在Container里面可以随意瞎搞,不用担心 ...
- Ubuntu 18.04 安装MySQL
最近在写东西的时候,需要用到MySQL,在网上查了一下,都说Ubuntu18.04不能安装MySQL5.7.22, 总觉的不可能,所以自己就研究了一下,然后分享给大家 工具/原料 VMware W ...
- Ubuntu 18.04 安装博通(Broadcom)无线网卡驱动
目录 Ubuntu 18.04 安装博通(Broadcom)无线网卡驱动 Package gcc is not configured yet. 解决办法 history history | grep ...
- 在Ubuntu 18.04 安装 MySQL 8.0
在Ubuntu 18.04 安装 MySQL 8.0 ① 登入 mysql 官网,在官网中下载 deb 包,点击该链接,即可下载. https://dev.mysql.com/downloads/re ...
- Ubuntu 18.04 安装部署Net Core、Nginx全过程
Ubuntu 18.04 安装部署Net Core.Nginx全过程 环境配置 Ubuntu 18.04 ,Nginx,.Net Core 2.1, Let's Encrypt 更新系统 sudo a ...
- Ubuntu 18.04 安装和常用软件安装
Ubuntu 18.04 安装 下载 Ubuntu 制作 U 盘启动盘 设置电脑为 U 盘启动 插入 U 盘,重启电脑 按照提示安装 Ubuntu 更新 NVIDIA 显卡和 Broadcom 无线网 ...
- ubuntu 16.04 安装Tensorflow
ubuntu 16.04 安装Tensorflow(CPU) 安装python ubuntu 16.04自带python2.7,因此可以略过这一步 安装pip sudo apt-get install ...
随机推荐
- 用HTML编写漫威页面
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- volatile、static
谈到 volatile.static 就必须说多线程. 1.一个线程在开始执行的时候,会开启一片自己的工作内存(自己线程私有),同时将主内存中的数据复制到自己 的工作内存,从此读写数据都是自己的工作内 ...
- VirtualBox + CentOS详细安装教程
一.前期工作准备 电脑虚拟化开启(必要工作)大致流程: a.电脑开机时长按F12(F10)进入BIOS界面; b.依次选择Configuratio > Intel Virtual Technol ...
- 必须掌握的前端模板引擎之art-template
常用的模板引擎有tpl.js.baiduTemplate.doT.js.art-template等等: 我所理解的模板引擎就是把js数据传到html中展示出来: art-template 是一个简约. ...
- 开发Web版一对一远程直播教室只需30分钟 - 使用face2face网络教室
转载自:https://blog.csdn.net/wo_shi_ma_nong/article/details/88110111 在“为网站开发远程直播教室的折腾过程及最终实现”中,介绍了如何使用f ...
- php设置文件类型content-type
在PHP中可以通过header函数来发送头信息,还可以设置文件的content-type,下面整理了一些常见文件类型对于的content-type值. //date 2015-06-22//定义编码h ...
- 大数据学习--day14(String--StringBuffer--StringBuilder 源码分析、性能比较)
String--StringBuffer--StringBuilder 源码分析.性能比较 站在优秀博客的肩上看问题:https://www.cnblogs.com/dolphin0520/p/377 ...
- T脚本语言学习记录-工具(一)
1.set & unset %set a Hello ;#定义变量 a 并赋值 =>Hello %puts $a ;#输出变量值 =>Hello %set a “Test Tcl” ...
- Linux 下 终端 相关的命令
1. 概述 Linux 服务器, 通常可以由多个终端连接 简单介绍一些 终端 相关的操作 最终的目的, 是定位到某个终端, 然后把它 踢下来, 甚至可以不让他再次连接 2. 环境 操作系统 CentO ...
- Pytorch之Variable求导机制
自动求导机制是pytorch中非常重要的性质,免去了手动计算导数,为构建模型节省了时间.下面介绍自动求导机制的基本用法. #自动求导机制 import torch from torch.autogra ...