Ubuntu16.04+Theano环境
来源:互联网 发布:mpv播放器 mac 编辑:程序博客网 时间:2024/06/11 04:55
安装Anaconda:
- 官网下载Anaconda
- 切换到下载目录
cd ~/下载/
- 用bash运行下载好的.sh文件
bash Anaconda2-4.3.0-Linux-x86_64.sh
- 进入欢迎界面
Welcome to Anaconda2 4.3.0 (by Continuum Analytics, Inc.)In order to continue the installation process, please review the licenseagreement.Please, press ENTER to continue
>>> - 按回车
================Anaconda License================Copyright 2016, Continuum Analytics, Inc.All rights reserved under the 3-clause BSD License:Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:* Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyright notice,this list of conditions and the following disclaimer in the documentationand/or other materials provided with the distribution.* Neither the name of Continuum Analytics, Inc. nor the names of itscontributors may be used to endorse or promote products derived from thissoftware without specific prior written permission.THIS SOFTWARE IS 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 FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL CONTINUUM ANALYTICS, INC. BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT--更多--
可以按q退出
- 显示是否同意条款,输入yes
Do you approve the license terms? [yes|no]>>> yes
- 跳出是否使用默认安装路径,直接回车(如果要改直接输入想要的安装路径)
Anaconda2 will now be installed into this location:/home/ziven/anaconda2 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below[/home/ziven/anaconda2] >>>
- 等待安装
- 安装完成,选择是否配置环境变量【注意:默认是no】,因此这里要输入yes,否则之后要手动添加环境变量
Python 2.7.13 :: Continuum Analytics, Inc.creating default environment...installation finished.Do you wish the installer to prepend the Anaconda2 install locationto PATH in your /home/ziven/.bashrc ? [yes|no][no] >>> yes
- Anaconda安装完成
Prepending PATH=/home/ziven/anaconda2/bin to PATH in /home/ziven/.bashrcA backup will be made to: /home/ziven/.bashrc-anaconda2.bakFor this change to become active, you have 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
- 输入
anacron -V
可显示版本
Anacron 2.3Copyright (C) 1998 Itai Tzur <itzur@actcom.co.il>Copyright (C) 1999 Sean 'Shaleh' Perry <shaleh@debian.org>Copyright (C) 2004 Pascal Hakim <pasc@redellipse.net>Mail comments, suggestions and bug reports to <pasc@redellipse.net>.
安装CUDA:
- 确保GPU为CUDA所支持的GPU
lspci | grep -i nvidia
参照GPU支持列表
- 确定系统版本
uname -m && cat /etc/*release
- 确定gcc版本
gcc --version
- 选择显卡驱动
- 下载CUDA Toolkit,建议使用.deb
- 切换到下载目录
sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
- 更新apt源
sudo apt-get updatesudo apt-get upgrade
安装cuda
sudo apt-get install cuda
再次更新apt源
sudo apt-get updatesudo apt-get upgrade
- 更新软件包
sudo apt-get cuda
- 选择最新安装的显卡驱动
- 如果没有新的显卡驱动可以如下安装
sudo apt-get install cuda-drivers
- 添加环境变量
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
检测安装
1 cd /usr/local/cuda-8.0/samples/2 sudo make
- 使用deviceQuery检测安装
1 cd ./bin/x86_64/linux/release/2 ./deviceQuery
- 可以看到显卡信息和最后的PASS即可
./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "GeForce 940MX" CUDA Driver Version / Runtime Version 8.0 / 8.0 CUDA Capability Major/Minor version number: 5.0 Total amount of global memory: 2002 MBytes (2099642368 bytes) ( 3) Multiprocessors, (128) CUDA Cores/MP: 384 CUDA Cores GPU Max Clock rate: 1242 MHz (1.24 GHz) Memory Clock rate: 1001 Mhz Memory Bus Width: 64-bit L2 Cache Size: 1048576 bytes 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), 2048 layers Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 2048 Maximum number of threads per block: 1024 Max dimension size of a thread block (x,y,z): (1024, 1024, 64) Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535) Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and kernel execution: Yes with 1 copy engine(s) Run time limit on kernels: Yes Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled Device supports Unified Addressing (UVA): Yes Device PCI Domain ID / Bus ID / location ID: 0 / 2 / 0 Compute 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报错的话需要
sudo setenforce 0
- 然后跑一下bandwidthTest看一下
./bandwidthTest
显示PASS即可
- CUDA安装完成
安装cuDNN:
- 下载cuDNN
- 进入下载目录解压tar包
1 cd ~/下载/2 tar -zxf cudnn-8.0-linux-x64-v5.1.tgz cuda/
- 进入cuda文件夹
cd ~/cuda
- 复制头文件到/usr/local/include
sudo cp include/cudnn.h /usr/local/include/
- 复制lib文件到/usr/local/lin
sudo cp lib64/* /usr/local/lib
- 编辑.bashrc添加环境变量
vim ~/.bashrc
在最后一行添加
export LD_LIBRARY_PATH=/usr/local/lib
安装theano:
conda install theanopip install nose_parameterized
- 进入Python检查tehano:
import theanotheano.test()
- 如果报错
Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.
则执行
conda install nomkl
- 结果为ok则安装成功
- 配置.theanorc(配置GPU加速):
cd ~vim .theanorc
- 写入并保存:
[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
创建一个test.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 range(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')
- 如果最后一行显示Used the gpu则表示GPU已启用
0 0
- Ubuntu16.04+Theano环境
- Ubuntu16.04+Theano环境
- Ubuntu16.04+Theano环境
- Ubuntu16.04 LTS配置caffe、tensorflow和theano环境
- ubuntu16.04+keras+theano+GPU
- 深度学习(四十一)cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建
- 深度学习(四十一)cuda8.0+ubuntu16.04+theano、caffe、tensorflow环境搭建
- 配置ubuntu16.04下Theano使用GPU运行程序的环境
- Ubuntu16.04lts 安装Theano配置GPU
- Ubuntu16.04+CUDA+Theano+keras配置
- 深度学习环境搭建 ubuntu16+GTX1080+CUDA8+Theano+Tensorflow+keras
- Caffe & Theano安装教程——ubuntu16.04系统
- ubuntu16.04下对theano进行cuda配置
- [DL] GTX1080 + Ubuntu16.04 + CUDA 8.0RC + Tensorflow + Theano + keras
- Ubuntu16.04+CUDA8.0+CUNN5.1+caffe+tensorflow+Theano
- Ubuntu16.04+CUDA8.0+CUNN5.1+caffe+tensorflow+Theano
- Ubuntu16.04 Anaconda+Theano+Cuda8.0+Cudnn5.1+keras配置
- Ubuntu16.04环境搭建
- mysql中tinyint、smallint、mediumint,int 和bigint 的区别
- Oracle大量数据的优化2
- select执行顺序
- iOS设计模式-中介者模式
- HiveQL:数据定义
- Ubuntu16.04+Theano环境
- POJ 1001 Exponentiation 求幂
- Spring高级运用之浅析多线程与计划任务
- 线上故障处理
- Centos7.3安装python2.7.12+ipython1.2.1
- Android一些常用指令
- 【Linux】【cmdline】uboot传递给内核的root设备序号动态变化导致启动失败
- 通信协议:HTTP、TCP、UDP
- 游戏程序员自学之路(一)