参考博客: 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 timevlen = 10 * 30 * 768  # 10 x #cores x # threads per core
    iters = 1000rng = 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信息表示配置成功!!!

转载于:https://www.cnblogs.com/txg198955/p/6109509.html

ubuntu 安装 theano相关推荐

  1. ubuntu安装Theano+cuda

    ubuntu安装Theano+cuda 由于学习需要用到GPU加速机器学习算法,需要安装theano+cuda. 开源库的一大问题就是:难安装. 为了搞好这个配置,我是前前后后花了3天,重装了3次ub ...

  2. Theano 中文文档 0.9 - 5.1 Ubuntu安装说明

    5.1 Ubuntu安装说明 译者:Python 文档协作翻译小组,原文:Ubuntu Installation Instructions. 本文以 CC BY-NC-SA 4.0 协议发布,转载请保 ...

  3. 在ubuntu安装python, theano, keras , Spearmint, Mongodb

    系统配置: Ubuntu 14 (其他系统也差不多如下操作) 1. 通过anaconda安装 python 地址: https://www.continuum.io/downloads#linux 2 ...

  4. 【DeepLearning工具】Fedora下安装theano

    http://blog.csdn.net/u012162613/article/details/42651233 author:wepon @blog:http://blog.csdn.net/u01 ...

  5. Ubuntu15.04 64位安装Theano(已经测试可执行)

    备注:之前服务器上已经安装caffe,后安装Theano,所有有些步骤简略. 安装caffe详情见 Caffe + Ubuntu 15.04 + CUDA 7.5 在服务器上安装配置及卸载重新安装(已 ...

  6. Theano 中文文档 0.9 - 5. 安装Theano

    5. 安装Theano 译者:Python 文档协作翻译小组,原文:Installing Theano. 本文以 CC BY-NC-SA 4.0 协议发布,转载请保留作者署名和文章出处. Python ...

  7. Linux 下非 root 用户安装 theano(配置 GPU)

    非 root 用户,安装 Python 第三方的包,尤其像 theano,存在大量的依赖项,存在的主要问题,是安装各个包时的权限问题.所幸,存在这样一个集成工具,叫 anaconda,其已经内置了许多 ...

  8. ubuntu+cuda+theano

    基础平台:64-bit,Ubuntu14.04 1.安装NVIDIA驱动(参考技术文章,基本是复制啊,蟹蟹作者~) (1) 在官网下载NVIDIA驱动,根据自己买的型号选择下载,放到 /home/lv ...

  9. ubuntu14.04安装theano,cuda7.5

    转自:http://www.myexception.cn/cuda/2017261.html 折腾记录--Ubuntu 14.04系统安装Nvidia CUDA7.5并搭建Python Theano深 ...

最新文章

  1. 【数据结构与算法】之深入解析“冗余连接”的求解思路与算法示例
  2. 装 linux后 win7消失了,win7系统重装后ubuntu启动消失不见的解决方法
  3. 配置spring、SpringMVC,mybatis进行整合
  4. Python全栈工程师(字符串/序列)
  5. PS网页设计教程XXIX——如何在PS中设计一个画廊布局
  6. java调用shell脚本及注意事项
  7. 考拉Android统一弹框
  8. 安卓显示视频画面的动画效果及代码
  9. 亿图图示 软件下载与安装 20200715
  10. Windows 无法启动 vmwave workstation server 服务 错误1075
  11. ibd 导入mysql_拷贝ibd实现MySQL的数据导入
  12. 专家调查显示:液晶电视坏眼超等离子电视
  13. win10找不到文件无法卸载的解决方法
  14. 转载 禁止ie浏览器打开
  15. 一文教你分清持续集成,持续交付,持续部署
  16. BetterGeo Mod 中文
  17. 在中国,40岁程序员是如何工作的?
  18. Linux下安装钉钉
  19. 计算机多媒体教学的缺点,多媒体教学与传统教学的优劣势探讨-20210716004535.docx-原创力文档...
  20. QT + TSC条码打印机 打印相应的产品条码标签

热门文章

  1. Unity 3D 正交相机(Orthographic)
  2. SignalR循序渐进(三)简易的集群通讯组件
  3. 《Troubleshooting Windows 7 Inside Out》文摘-1
  4. FILE类型指针的头文件
  5. [原创]group by和compute 的使用
  6. python列表生成式原理_三元表达式/和/或如何在Python中工作/真与假的性质/列表生成/生成器,and,or,执行,原理,True,False,本质,生成式...
  7. Safari 是什么
  8. TrueNAS SCALE是什么
  9. 新能源车为什么不加变速箱解决高速高耗电的问题?
  10. 创业项目筹备了两个多月,确实不容易