惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
月光博客
月光博客
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
PCI Perspectives
PCI Perspectives
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Latest news
Latest news
P
Palo Alto Networks Blog
Blog — PlanetScale
Blog — PlanetScale
Cyberwarzone
Cyberwarzone
P
Privacy International News Feed
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
S
Securelist
H
Hackread – Cybersecurity News, Data Breaches, AI and More
NISL@THU
NISL@THU
GbyAI
GbyAI
H
Hacker News: Front Page
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
U
Unit 42
T
The Blog of Author Tim Ferriss
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cloudbric
Cloudbric
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
L
LINUX DO - 最新话题
The Hacker News
The Hacker News
WordPress大学
WordPress大学
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
T
Threatpost
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
L
LINUX DO - 热门话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
K
Kaspersky official blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - AI产品观察

公式截图怎么转LaTeX代码?这个免费工具一键搞定 免费白嫖Google顶尖算力?深度揭秘这个满血版Gemini 3 Pro体验入口 深度解析 VoGen:2026 年最强免费 AI 语音合成与情感克隆技术方案 分享一个网站,Crealens.ai - 可以免费体验 AI图像/视频 生成-编辑-创作 WriteRightly 这个AI 可以像教授一样批改论文 免费、快速、可靠:揭秘IsGPT如何精准检测AI内容 Crealens.ai 免费体验GPT-4o 生图+吉卜力风格化 目标检测-基于Pytorch实现Yolov3(1)- 搭建模型 01布尔模型&倒排索引 openpose模型在AI challenge人体骨骼关键点检测的表现 隐马尔可夫模型(HMM) 概率生成模型 卷积神经网络经验-CS231n笔记 Exynos 4412 Uboot源码解析 隐马尔可夫模型 基于WDF的PCI/PCIe接口卡Windows驱动程序(5)-如何为硬件移植驱动程序 进程详解(1)——可能是最深入浅出的进程学习笔记 贪吃蛇游戏C语言源代码学习 经典功率谱估计及Matlab仿真 CAN总线(一)
双显卡笔记本安装CUDA+theano、tensorflow环境
AI产品观察 · 2017-02-08 · via 博客园 - AI产品观察

原文出处:http://www.cnblogs.com/jacklu/p/6377820.html

个人知乎主页欢迎关注:https://www.zhihu.com/people/jack_lu,相信我会提供高质量的timeline。

“站在岸上学不会游泳。”看了各种深度学习的新闻、有意思的paper,要开始搭建深度学习环境入坑了。昨天看到一视频展现了tensorflow在Android平台上的应用,感觉潜力巨大,所以选择了tensorflow。

结合几篇安装博客总结了安装方法,可能是最简便的一种了~

笔记本Y430p 显卡GTX850M

操作系统Ubuntu 16.04(经本人测试 14.04 14.10 15.04 15.10 对双显卡的支持都不是特别好)安装好后建议关掉所有更新选项。

python版本 2.7

1、首先保证安装好NVIDIA驱动。如下图所示:

image

2、安装CUDA

sudo apt-get update
sudo apt-get install nvidia-cuda-toolkit

默认安装cuda 7.5.18 安装之后,是没有/usr/local/cuda*这个文件夹,也没有sample的

3、由于Ubuntu16.04的gcc和g++都是5.0版的,不兼容CUDA7.5版本,需要降级

sudo apt-get install gcc-4.9 g++-4.9
cd /usr/bin
sudo rm gcc
sudo rm g++
sudo ln -s gcc-4.9 gcc
sudo ln -s g++-4.9 g++

4、安装cudnn

下载cudnn 5.0 for cuda7.5 需要nvidia的开发者帐号登录

image
解压

tar -zxf cudnn-7.5-linux-x64-v5.0-ga.tgz

cd cuda

复制头文件到/usr/local/include

sudo cp include/cudnn.h /usr/local/include/

复制lib文件到/usr/local/lib

sudo cp lib64/* /usr/local/lib/

并编辑~/.bashrc 添加环境变量

export LD_LIBRARY_PATH=/usr/local/lib

5、安装theano

sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose python-mock python-wheel g++ libopenblas-dev git
sudo pip install Theano

编辑配置文件

加入

[global]
device = gpu
floatX = float32
[nvcc]
flags=-D_FORCE_INLINES

注意有符号-

测试,注意cuDNN版本5005

image

6、安装tensorflow

根据自己的实际情况参照官网的这张表选择适合的下载链接。

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only, Python 2.7:
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.4
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.5
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl

# Mac OS X, CPU only, Python 3.4 or 3.5:
 export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py3-none-any.whl

我在这里选择 64-bit GPU Python 2.7

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

然后根据自己情况选择

# Python 2
 pip install --upgrade $TF_BINARY_URL

# Python 3
 pip3 install --upgrade $TF_BINARY_URL

我在这里选择Python 2

pip install --upgrade $TF_BINARY_URL

测试Tensorflow是否安装成功并使用了CUDA,依次执行以下python代码

import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print sess.run(c)

实验结果如下,表示安装成功!可以开始新的征程啦~

image

remark:

cudnn version should be 5.1

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"

export CUDA_HOME=/usr/local/cuda

参考资料:

https://zhuanlan.zhihu.com/p/23042536?refer=tomasen

https://www.zhihu.com/question/48027732?from=profile_question_card

http://www.ifcoder.us/2003