Ubuntu16.04+theano Environment

Source: Internet
Author: User
Tags theano continuum analytics cuda toolkit

Install Anaconda:
  • Official website Download Anaconda
  • Switch to download directory
    CD ~/Download/
  • Run the downloaded. sh file with Bash
    bash anaconda2-4.3. 0-linux-x86_64. SH
  • Enter the Welcome screen
    4.3. 0 (by Continuum Analytics, Inc.) In order to continue the installation process, please review the licenseagreement. Please, press ENTER to continue
    >>>
  • Press ENTER
    ================Anaconda License================Copyright ., Continuum Analytics, inc.all rights reserved under the3-clause BSD license:redistribution and useinchsource and binary forms, with or withoutmodification, is permitted provided that the following conditions is met:
          *redistributions of source code must retain the above copyright notice,this List of conditions and the following DISCL Aimer.* Redistributionsinchbinary form must reproduce the above copyright notice,this List of conditions and the following disclaimerinchThe Documentationand/or other materials provided with the distribution.*Neither the name of Continuum Analytics, Inc. nor the names of itscontributors May is used to endorse or promote PROD Ucts derived from Thissoftware without specific prior written permission. This software are provided by the COPYRIGHT holders and CONTRIBUTORS" as is"and any EXPRESS OR implied warranties, including, but not LIMITED to, theimplied warranties of merchantability and FIT NESS for A particular Purposeare disclaimed. In NO EVENT shall CONTINUUM ANALYTICS, Inc. be liable Forany DIRECT, INDIRECT, incidental, special, exemplary, OR Conseque NT--More--

    You can press Q to exit

  • Show whether you agree to the terms, enter Yes
    Do you approve the license terms? [yes| No] >>> Yes
  • Jump out whether to use the default installation path, enter directly (if you want to change the installation path directly)
    Anaconda2'll now being installed into this location:/home/ziven/anaconda2  - Press ENTER to Confi RM  The location-press Ctrl-C to abort the  installation- Or Specify a different location below [/home/ziven/anaconda2] >>>          
  • Waiting for installation
  • Installation is complete, choose whether to configure the environment variable "NOTE: Default is no", so here to enter Yes, otherwise you want to manually add environment variables
    2.7.  -  install in YOUR/HOME/ZIVEN/.BASHRC? [yes|  >>> Yes
  • Anaconda Installation Complete
     prepending path=/home/ziven/anaconda2/bin to PATH in /Home /ziven/.bashrca backup would be a made to: /home/ziven/.bashrc-anaconda2.bakfor This change to become active and you are having to open a new terminal. Thank you  for  installing anaconda2! share your notebooks and packages on Anaconda Cloud ! sign up  for  free : Https:// anaconda.org  
  • Input
    Anacron-v

    can display version

    2.31998  Itai Tzur <[emailprotected]>1999  '  Shaleh' Perry <[email protected]>2004  Pascal Hakim <[email protected]><[email protected]>.
Cuda Installation:
  • Ensure that the GPU is supported by Cuda
    Lspci | Grep-i nvidia

    Reference GPU Support List

  • Determine the system version
    Uname-m && cat/etc/*release
  • Determine the GCC version
    GCC--version
  • Select Video Driver
  • Download Cuda Toolkit, recommended to use. deb
  • Switch to download directory
    sudo dpkg-i cuda-repo-<distro>_<version>_<architecture>.deb
  • Update apt Source
    sudo apt-get updatesudo apt-get upgrade
  • Cuda Installation

    sudo Install Cuda
  • Update apt Source again

    sudo apt-get updatesudo apt-get upgrade

  • Update package
    sudo apt-get cuda
  • Select the latest installed graphics driver
  • If no new graphics driver can be installed as follows
    sudo Install cuda-drivers
  • Adding environment variables
    Export path=/usr/local/cuda-8.0/bin${path:+:${path}}

  • Detect installation

    1 cd/usr/local/cuda-8.0/samples/2sudo make
  • Using Devicequery to detect installation
    1 cd./bin/x86_64/linux/release/2 ./devicequery
  • You can see the video card information and the last pass
    ./Devicequery Starting ... CUDA Device Query (Runtime API) version (Cudart static linking) detected1CUDA capable device (s) device0:"GeForce 940MX"CUDA Driver Version/Runtime Version8.0/8.0CUDA Capability Major/minor Version Number:5.0Total amount of global memory:2002MBytes (2099642368bytes) ( 3) Multiprocessors, ( -) CUDA CORES/MP:384CUDA cores GPU Max Clock rate:1242MHz (1.24GHz) Memory Clock Rate:1001Mhz Memory Bus Width: --bit L2 Cache Size:1048576bytes Maximum Texture Dimension Size (x, Y, z) 1D=(65536), 2d= (65536,65536), 3d= (4096,4096,4096) Maximum layered 1D Texture Size, (num) layers 1D=(16384),2048layers Maximum Layered 2D Texture Size, (num) layers 2D=(16384,16384),2048layers Total amount of constant memory:65536Bytes Total amount of shared memory per block:49152Bytes Total number of registers available per block:65536Warp Size: +Maximum Number of threads per multiprocessor:2048Maximum Number of threads per block:1024x768Max dimension size of a thread block (x, Y, z): (1024x768,1024x768, -) Max dimension size of a grid size (x, Y, z): (2147483647,65535,65535) Maximum memory pitch:2147483647bytes Texture Alignment: +bytes Concurrent Copy and kernel Execution:yes with1copy engine (s) Run Timelimit on Kernels:yes Integrated GPU sharing host Memory:no support Host page-locked Memory Mapping:yes Alignment requirement forsurfaces:yes Device has ECC support:disabled device supports Unified addressing (UVA): Yes Device PCI Domain ID/Bus id/location ID:0/2/0Compute Mode:< Default (multiple host threads can use:: Cudasetdevice () with device simultaneously) >devicequery, CUDA Driver= Cudart, CUDA Driver Version =8.0, CUDA Runtime Version =8.0, Numdevs =1, Device0 =GeForce 940MXResult= PASS
  • SELinux Error if required
    sudo 0
  • Then run for a bandwidthtest and look at it.
    ./bandwidthtest

    Show Pass

  • Cuda Installation Complete
Install Theano:
InstallInstall nose_parameterized

  • Configuration. THEANORC:
    CD ~vim. Theanorc

  • Write and Save:
    [Global]  floatx=float32  device=GPU  base_compiledir=~/external/.theano/   allow_gc=False  warn_float64=warn  [mode]=Fast_run    [NVCC]  Fastmath=True    [cuda]  root=/usr/local/cuda  

  • Create a test.py:

    From Theano Importfunction, config, shared, sandbox import theano.tensor as T import numpy import TimeVlen=Ten* -*768#Tenx #cores x # Threads per core iters= +rng= Numpy.random.RandomState ( A) x=Shared (Numpy.asarray (Rng.rand (Vlen), config.floatx)) F=function([], T.exp (x)) print (F.maker.fgraph.toposort ()) T0= Time. Time()   forIinchRange (iters): R=f () T1= Time. Time() print ("looping%d times took%f seconds"% (iters, T1-t0)) Print ("Result is%s"%(R,))ifNumpy.any ([Isinstance (X.op, T.elemwise) forXinchF.maker.fgraph.toposort ()]): Print ('used the CPU')  Else: Print ('used the GPU')

  • If the last line shows used the GPU is enabled
  • Go to python check Tehano:
    Import theanotheano.test ()

  • If an error
    or libmkl_def.so.

    The execution

    Conda Install NOMKL

  • The result is OK and the installation succeeds

Ubuntu16.04+theano Environment

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.