ubuntu 安装 theano
参考博客: http://www.cnblogs.com/anyview/p/5025704.html
1. 安装gfortran, numpy, scipy, sklearn, blas, atlas等包
# 安装gfortran,后面编译过程中会用到
sudo apt-get install gfortran
# 安装blas,Ubuntu下对应的是libopenblas,其它操作系统可能需要安装其它版本的blas——这是个OS相关的。
sudo apt-get install libopenblas-dev
# 安装lapack,Ubuntu下对应的是liblapack-dev,和OS相关。
sudo apt-get install liblapack-dev
# 安装atlas,Ubuntu下对应的是libatlas-base-dev,和OS相关。
sudo apt-get install libatlas-base-dev
# 安装pip
sudo apt-get install python-pip
sudo apt-get install python-dev
sudo apt-get install python-nose
sudo apt-get install g++
sudo apt-get install git
2. 安装numpy和scipy
安装这两个python库有点问题,如果使用apt-get安装,后面的test不能通过。如果使用pip安装,有得考虑各种依赖关系。
所以,先使用apt-get安装,然后再卸载,最后再使用pip安装。这样,既能不考虑依赖关系,又能通过后面的test()测试。
#安装numpy和scipy
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python-sklearn
#卸载numpy和scipy
sudo apt-get remove python-numpy
sudo apt-get remove python-scipy
# 安装numpy
sudo pip install numpy
# 测试numpy#,如果没有安装python-nose,测试会出错!python -c "
import numpy
numpy.test()
# 安装scipy
sudo pip install scipy
# 测试scipypython -c "
import scipy
scipy.test()"
3. 安装Theano
前面的操作如果没有出现错误,就可以开始安装Theano了。命令如下所示。
- # 安装Theano
- sudo pip install Theano
- # 测试Theano
- import theano;
- theano.test()
- 4.安装pyCUDA
- 测试Theano时,提示PyCUDA import错误,因此需要安装pyCUDA。而PyCUDA需要以Boost为基础,所以应该先安装Boost。
使用pip安装pyCUDA。
- 安装boost
- sudo apt-get install libboost-all-dev
如果使用pip安装pyCUDA出错,使用下面安装方式。参考文章:《Ubuntu Theano CUDA》
sudo ldconfig /usr/local/cuda-7.0/lib64
5. 解决cuda_ndarray.cu错误
如果出现错误:ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.6.5 cannot open shared object file: No such file or directory,需要运行以下命令:
sudo ldconfig /usr/local/cuda-7.0/lib64
6.配置GUP
我的电脑账号名字yf
在主目录下面/home/yf/新建 .theanorc目录,写人如下内容:
[global]
device=gpu
floatX=float32
root=/usr/local/cuda-7.5
[nvcc]
fastmath=True
[blas]
ldflags=-lopenblas
[cuda]
root=/usr/local/cuda-7.5
7.测试Theano是否在使用GPU
将下列python代码复制到useGPU.py,并运行。
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000
rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in xrange(iters):
r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
print('Used the cpu')
else:
print('Used the gpu')
假定上面已经设置文件
.theanorc
,运行命令如下所示:
python useGPU.py
如果出现下面的错误信息,请运行命令
sudo ldconfig /usr/local/cuda-7.0/lib64
参考#错误信息ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.7.0: cannot open shared object file: No such file or directory
然后把调用GPU的测试程序copy一下,在http://deeplearning.net/software/theano/tutorial/using_gpu.html#testing-theano-with-gpu 这里。
终端显示GPU信息表示配置成功!!!
ubuntu 安装 theano的更多相关文章
- ubuntu安装Theano+cuda
由于学习需要用到GPU加速机器学习算法,需要安装theano+cuda. 开源库的一大问题就是:难安装. 为了搞好这个配置,我是前前后后花了3天,重装了3次ubuntu重装了5次驱动才搞定. 故发此贴 ...
- Ubuntu 安装Theano
参考:http://deeplearning.net/software/theano/install_ubuntu.html 编译安装python3.4:http://blog.aboutc.net/ ...
- 在ubuntu安装python, theano, keras , Spearmint, Mongodb
系统配置: Ubuntu 14 (其他系统也差不多如下操作) 1. 通过anaconda安装 python 地址: https://www.continuum.io/downloads#linux 2 ...
- ubuntu系统theano和keras的安装
说明:系统是unbuntu14.04LTS,32位的操作系统,以前安装了python3.4,现在想要安装theano和keras.步骤如下: 1,安装pip sudo apt-get install ...
- 重装Ubuntu16.04及安装theano
一.卸载现有的ubuntu系统 1.下载MbrFix,并放在C盘根目录. 2.管理员身份运行cmd命令符:切换到C盘根目录,然后输入命令符MbrFix /drive 0 fixmbr,回车确认即可. ...
- Python学习笔记(三)windows下安装theano
2016.6.28补充: 不论是实验室的电脑还是我的笔记本,只要是windows下,theano.test()都是不通过的.虽然能使用一些theano中的函数,但是我感觉很不好. 所以还是转Ubunt ...
- Linux下安装theano
http://deeplearning.net/software/theano/install_ubuntu.html#install-ubuntu 以上链接为官网安装教程 在ubuntu中安装the ...
- Linux 下非 root 用户安装 theano(配置 GPU)
非 root 用户,安装 Python 第三方的包,尤其像 theano,存在大量的依赖项,存在的主要问题,是安装各个包时的权限问题.所幸,存在这样一个集成工具,叫 anaconda,其已经内置了许多 ...
- Mac OS、Ubuntu 安装及使用 Consul
Consul 概念(摘录): Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,比如 Airbnb 的 SmartStac ...
随机推荐
- 2015/11/5用Python写游戏,pygame入门(5):面向对象的游戏设计
昨天的内容里有了运动的子弹,虽然我们只添加了一个子弹,但你可以看到我们需要记录子弹的x,y坐标,每次要更新它的坐标.如果我们想要有多颗子弹,就需要存储多个坐标.那时候处理起来就不显得那么简单,也许我们 ...
- android textview空格占位符以及一些其他占位符汇总
== 普通的英文半角空格 == == == no-break space (普通的英文半角空格但不换行) == 中文全角空格 (一个中文宽度) == == en空格 (半个中文 ...
- Lucene之Java实战
1.导包 2.索引的创建 2.1首先,我们需要定义一个词法分析器. Analyzer analyzer = new IKAnalyzer();//官方推荐 Analyzer analyzer = ne ...
- 三个你不知道的CSS技巧
各种浏览器之间的竞争的白热化意味着越来越多的人现在开始使用那些支持最新.最先进的W3C Web标准的设备,以一种更具交互性的方式来访问互联网.这意味着我们终于能够利用更强大更灵活的CSS来创造更简洁, ...
- [gym100956]Problem J. Sort It! BIT+组合数
source : Pertozavodsk Winter Training Camp 2016 Day 1: SPb SU and SPb AU Contest, Friday, January 29 ...
- 七牛云 上传图片 https 修改Nginx 注意事项
仅在这记录下,今天的事情. 问题出自于Nginx 设置http 强制跳转 https设置 1.上午,出于某些需求,我将服务器Nginx 设置http 强行跳转 https server { liste ...
- 常见踩坑案例(二)-Request method 'POST' not supported
一 前言 最近涉及到与前后端的数据对接,按道理来说没一点压力结果被一前端童鞋带坑里去了(不过也是很久没写过这种前后端分离进行联调的事情了,如果是一个人全套弄的话就不会出现下面问题). 二 Reques ...
- Mac 下 gzip 一个文件
gzip -k xxx.json -k 会保留源文件
- 富文本存储型XSS的模糊测试之道
富文本存储型XSS的模糊测试之道 凭借黑吧安全网漏洞报告平台的公开案例数据,我们足以管中窥豹,跨站脚本漏洞(Cross-site Script)仍是不少企业在业务安全风险排查和修复过程中需要对抗的“大 ...
- Android平台介绍
一.Android平台介绍 什么是智能手机 具有独立的操作系统,独立的运行空间,可以由用户自行安装软件.游戏.导航等第三方应用程序,并可以通过移动通讯网络来实现无线网络接入的手机类型总称. 智能手机操 ...