深度工具合集安装(Nvidia+CUDA+cuDNN+Tensorflow+OpenBLAS+Caffe+Theano+Keras+Torch+Mxnet+X2Go)

来源:互联网 发布:layout拼图软件 编辑:程序博客网 时间:2024/04/30 15:27

 

[置顶] 深度工具合集安装(Nvidia+CUDA+cuDNN+Tensorflow+OpenBLAS+Caffe+Theano+Keras+Torch+Mxnet+X2Go)

 1055人阅读 评论(2) 收藏 举报
 分类:

目录(?)[+]

之前在装有caffe的基础上,换CUDA7.5不成功,然后终于找到github上一个教程,一定要按里面的流程安装.把市面上用到的深度工具都装在ubuntu14.04上.有问题请留言.

Basics

1、首选装好系统运行下面的代码:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get update    
  2. sudo apt-get upgrade    
  3. sudo apt-get install build-essential    
  4. sudo apt-get autoremove   

2、安装git

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install git   

Nvidia Drivers

1、找机子的显卡

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. lspci | grep -i nvidia   

2、自己下载Nvidia-352.41.run或在线安装

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo add-apt-repository ppa:graphics-drivers/ppa  
  2. sudo apt-get update  
  3. sudo apt-get install nvidia-352  

3、重启

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo shutdown -r now  

4、nvidia检查

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. cat /proc/driver/nvidia/version  

CUDA

1、下载CUDA7.5

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo dpkg -i cuda-repo-ubuntu1404*amd64.deb  
  2. sudo apt-get update  
  3. sudo apt-get install cuda  

2、添加CUDA环境

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc  
  2. echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc  
  3. source ~/.bashrc  

3、检查CUDA版本

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. nvcc -V  

4、重启

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo shutdown -r now  

Checking your CUDA Installation (Optional)

1、编译cuda的sample:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. /usr/local/cuda/bin/cuda-install-samples-7.5.sh ~/cuda-samples  
  2. cd ~/cuda-samples/NVIDIA*Samples  
  3. make -j $(($(nproc) + 1))  

2、查看显卡里面的信息

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. bin/x86_64/linux/release/deviceQuery  

cuDNN

1、安装cudnn_v5

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. cd ~/Downloads/  
  2. tar xvf cudnn*.tgz  
  3. cd cuda  
  4. sudo cp */*.h /usr/local/cuda/include/ 
  5. sudo cp */libcudnn* /usr/local/cuda/lib64/  
  6. sudo chmod a+r /usr/local/cuda/lib64/libcudnn*  

Check

1、终端查看
[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. nvidia-smi  

Tensorflow

1、先下载v0.8版的GPU支持

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install python-pip python-dev   

2、如果中途安装不了可以先下载那个网址东西,下载好了,然后安装,中途会有几个包的numpy、six、protobuf、wheel下载安装比较慢或者下载不了,可以单独安装。

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl  

3、测试Tensorflow

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. python  
  2. >>> import tensorflow as tf  
  3. >>> exit()  

4、我碰到的一个问题"AttributeError: NewBase is_abstract, ImportError: libcudart.so.7.5"

解决:是因为six版本问题。

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. $sudo pip install six --upgrade --target="/usr/lib/python2.7/dist-packages"  

5、推荐IDE调试工具

pyCharm免费的社区版(community release)不支持远程调试,百度下载然后到bin里面,运行pycharm安装文件就可以了。

OpenBLAS

1、先下载git,然后安装OpenBLAS

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. mkdir ~/git  
  2. cd ~/git  
  3. git clone https://github.com/xianyi/OpenBLAS.git  
  4. cd OpenBLAS   
  5. sudo apt-get install gfortran  
  6. make FC=gfortran -j $(($(nproc) + 1))  
  7. sudo make PREFIX=/usr/local install  

2、添加lib库的变量路径

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc  

Common Tools

1、安装来自Scipy的普通tools

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install -y libfreetype6-dev libpng12-dev  
  2. pip install -U matplotlib ipython[all] jupyter pandas scikit-image  

2、如果安装matplotlib时无法安装,按照下面方法:

先下载:here

然后减压matplotlib-1.5.0,并进入matplotlib-1.5.0里面

最后运行

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. python setup.py build  
  2. python setup.py install  

Caffe

1、caffe相信大家都很熟悉了,下面是一些基础依赖库

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler  
  2. sudo apt-get install --no-install-recommends libboost-all-dev  
  3. sudo apt-get install python-skimage ipython python-pil python-h5py ipython python-gflags python-yaml  
  4. sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev  

2、克隆caffe

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. cd ~/git  
  2. git clone https://github.com/BVLC/caffe.git  
  3. cd caffe  
  4. cp Makefile.config.example Makefile.config  

3、如果安装了cuDNN然后把Makefile文件的USE_CUDNN := 1注释去掉

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sed -i 's/# USE_CUDNN := 1/USE_CUDNN := 1/' Makefile.config  

4、如果安装了OpenBLAS,修改BLAS参数

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sed -i 's/BLAS := atlas/BLAS := open/' Makefile.config  

5、安装需求build和测试caffe,编译PyCaffe

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo pip install -r python/requirements.txt  
  2. make all -j $(($(nproc) + 1))  
  3. make test -j $(($(nproc) + 1))  
  4. make runtest -j $(($(nproc) + 1))  
  5. make pycaffe -j $(($(nproc) + 1))  

6、添加caffe的环境变量

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. echo 'export CAFFE_ROOT=$(pwd)' >> ~/.bashrc  
  2. echo 'export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH' >> ~/.bashrc  
  3. source ~/.bashrc  

7、测试caffe接口

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. ipython  
  2. >>> import caffe  
  3. >>> exit()  

Theano

1、安装Theano

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ python-pygments python-sphinx python-nose  
  2. sudo pip install Theano  

2、测试接口

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. python  
  2. >>> import theano  
  3. >>> exit()  

Keras

1、这个编译器(关于Theano和Tensorflow)不是很熟悉,顺便安装一下试试。默认是Theano,如果想换Tensorflow,可以按照here.

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo pip install keras  

Torch

1、这个是facebook的深度框架

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. git clone https://github.com/torch/distro.git ~/git/torch --recursive  
  2. cd torch; bash install-deps;  
  3. ./install.sh  

2、添加环境变量

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. source ~/.bashrc   

3、推荐IDE工具eclipse,安装相应的插件(Lua Development Tools)

首先安装eclipse c/c++的开发版,然后在官网搜索Lua,看到LDT就点进去,找到Existing Eclipse installation,按照官网指示安装插件,就ok了。

Mxnet

mxnet是cxxnet的下一代,目前实现了cxxnet所有功能,但借鉴了minerva/torch7/theano,加入更多新的功能。

  1. ndarray编程接口,类似matlab/numpy.ndarray/torch.tensor。独有优势在于通过背后的engine可以在性能上和内存使用上更优
  2. symbolic接口。这个可以使得快速构建一个神经网络,和自动求导。
  3. 更多binding 目前支持比较好的是python,马上会有julia和R
  4. 更加方便的多卡和多机运行
  5. 性能上更优。目前mxnet比cxxnet快40%,而且gpu内存使用少了一半。
目前mxnet有更多的binding,更好的文档,和更多的应用(language model、语音,机器翻译,视频)。
1、安装依赖库
[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get update  
  2. sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev  
2、安装mxnet

mxnet/目录里找到mxnet/make/子目录,把该目录下的config.mk复制到mxnet/目录,用文本编辑器打开,找到并修改以下两行:

USE_CUDA = 1

USE_CUDA_PATH = /usr/local/cuda

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. git clone --recursive https://github.com/dmlc/mxnet  
  2. cd mxnet; make -j$($(nproc)+1  
X2Go

1、X2GO是一个远程控制桌面,下面是安装教程

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install software-properties-common  
  2. sudo add-apt-repository ppa:x2go/stable  
  3. sudo apt-get update  
  4. sudo apt-get install x2goserver x2goserver-xsession  
2、X2Go 不支持Unity desktop environment (the default in Ubuntu)

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get update  
  2. sudo apt-get install -y xfce4 xfce4-goodies xubuntu-desktop  
3、找使用机子的IP

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. hostname -I  
0 0
原创粉丝点击