ubuntu14.04 installation Theano

Source: Internet
Author: User
Tags theano

Basically according to the official website to line:

First

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

Again is

sudo pip install Theano

(In this step, if you are python3 by default, you will change to pip-2.7)

Under test:

Test the newly installed packages

Python-c "Import numpy; Numpy.test () "   about ~30spython-c" import scipy; Scipy.test () "   about ~1mpython-c" import Theano; Theano.test () "About ~30m

Speed Test Theano/blas

Python ' python-c ' import OS, Theano; Print Os.path.dirname (theano.__file__) "'/misc/check_blas.py

The test is successful and it's basically available.

The following are the GPU settings:

Check if your computer has CUDA-supported GPUs

Lspci | Grep-i nvidia

Generally get results similar to the following

01:00.0 VGA compatible Controller:nvidia ...

In addition, it is also available

Lspci | Grep-i VGA

Display all graphics cards, using

Lspci-v-S 01:00.0

Displays specific graphics card details.

If so, the installation will be OK:

sudo apt-get install nvidia-currentsudo apt-get Install Nvidia-cuda-toolkit

Then the main is to set the parameters, so that the priority to use the GPU

See the http://deeplearning.net/software/theano/install.html using the GPU section.

There are two main methods, a Setup theano_flags, an edit. theanorc file, for example,

Create a ". Theanorc" file under the $home directory (user home directory, typically/home/user name), edited as

[Global]device = Gpufloatx = Float32[cuda]root =/usr/lib/nvidia-cuda-toolkit    //cuda directory One is set to its own Cuda installation directory (contains bin, Lib,include Sub-folders)

Note that this file you created, will generally become invisible, can be used "ls-a" command to list all files so as to see, can be edited with Gedit.

Also, to set the Cuda Lib subfolder (which may also be set under 64-bit lib64 subfolder) to the environment variable $ld_library_path, see http://blog.csdn.net/xsc_c/article/details/ 23470565 (this blog Cuda a few introductory articles are also very good). Or this article http://www.linuxidc.com/Linux/2014-10/107501.htm and http://www.linuxidc.com/Linux/2012-04/58913.htm.
Test examples in Http://deeplearning.net/software/theano/tutorial/using_gpu.html#using-gpu

From Theano import function, config, shared, Sandboximport theano.tensor as timport numpyimport Timevlen = ten * 768
   # x #cores x # threads per coreiters = 1000RNG = Numpy.random.RandomState 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 '% iters, t1-t0, ' seconds ' print ' Result is ', Rif Numpy.any ([Isinstance ( X.op, T.elemwise) for x in F.maker.fgraph.toposort ()]):    print ' used the CPU ' else:    print ' used the GPU '

  

ubuntu14.04 installation Theano

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.