1、首选装好系统运行下面的代码:(如果已经安装了nvidia显卡容易出现问题,我出错后,重装了系统)
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential sudo apt-get autoremove
2、安装git
sudo apt-get install git
NVIDIA 驱动安装
下载NVIDIA-Linux-x86_64-367.27.run,下载地址为:
将其与cuda_8.0.27_linux.run(下载地址为:https://developer.nvidia.com/cuda-toolkit 不过需要注册)拷到home/zhou下。
1、将nouveau添加到黑名单,防止它启动
cd /etc/modprobe.d
sudo gedit nvidia-graphics-drivers.conf写入:blacklist nouveau
检查:
cat nvidia-graphics-drivers.conf
对于:/etc/default/grub,添加到末尾。
sudo gedit /etc/default/grub在文件中写入
rdblacklist=nouveau nouveau.modeset=0
检查:
cat /etc/default/grub
2、 Ctrl+alt+F1进入字符界面,关闭图形界面
sudo service lightdm stop
// 必须有,不然会安装失败
3、安装nvidia driver
//获取权限
sudo chmod 777 NVIDIA-Linux-x86_64-367.27.run
//安装驱动
sudo ./NVIDIA-Linux-x86_64-367.27.run
Accept
Continue installation
安装完成之后
sudo service lightdm start
图形界面出现,然后关机,切换到1080
4、nvidia检查
cat /proc/driver/nvidia/version
cuda8.0
1、 在终端运行指令
sudo sh cuda_8.0.27_linux.run
选择
Do you accept the prevIoUsly read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 361.62?
(y)es/(n)o/(q)uit: n
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /home/zhou ]:
Installing the CUDA Toolkit in /usr/local/cuda-8.0 …
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Installing the CUDA Samples in /home/zhou …
Copying samples to /home/zhou/NVIDIA_CUDA-8.0_Samples now…
Finished copying samples.
===========
= Summary=
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-8.0
Samples: Installed in /home/zhou,but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-8.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64,or,add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit,run the uninstall script in /usr/local/cuda-8.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer,run the following command,replacing with the name of this run file:
sudo .run -silent -driver
Logfile is /tmp/cuda_install_2961.log
安装完成,但是缺少一些库。
2、安装所缺少的库
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
这个因为网络问题,可能要安装很久。
还是有线好点。
3、
sudo apt-get install vim
安装完成。
4、设置环境变量
在终端输入这两句:
sudo gedit ~/.bashrc在文件最后添加:
export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
然后更新环境变量
source ~/.bashrc
cudnn
1、安装cudnn_v5
cd ~/Downloads/ tar xvf cudnn*.tgz cd cuda sudo cp */*.h /usr/local/cuda/include/ sudo cp */libcudnn* /usr/local/cuda/lib64/ sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
Check
1、终端查看nvidia-smi
OpenCV
1. 先下载OpenCV的源码
下载opencv2.4.13
2. 解压到任意目录
unzip opencv-2.4.13.zip
3. 进入源码目录,创建release目录
cd opencv-2.4.13 mkdir release
4. 可以看到在OpenCV目录下,有个CMakeLists.txt文件,需要事先安装一些软件
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config Python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev
5. 进入release目录,安装OpenCV是所有的文件都会被放到这个release目录下
cd release
6. cmake编译OpenCV源码,安装所有的lib文件都会被安装到/usr/local目录下
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..7. 安装
make sudo make install
8. 测试,在某个目录下建立一个test.cpp文件
#include <cv.h> #include <highgui.h> using namespace cv; int main(int argc,char* argv[]) { Mat image; image = imread(argv[1],1); if (argc != 2 || !image.data) { printf("No image data\n"); return -1; } namedWindow("Display Image",CV_WINDOW_AUTOSIZE); imshow("Display Image",image); waitKey(0); return 0; }
9. 写一个cmake的makefile,也叫CMakeLists.txt
project(test)
find_package(OpenCV required)
add_executable(test test)
target_link_libraries(test ${OpenCV_LIBS})
cmake_minimum_required(VERSION 2.8)
10. 编译+运行
cmake . make
得到可执行文件test
11. 随便弄个jpg图片做个测试,注意要和上面那个可执行文件放在同一目录下面,我这里名字取的是test.jpg。
12. ./test test.jpg 如果能看到照片,那就表示成功了。
Tensorflow
1、先下载v0.8版的GPU支持
现在的方法:参考https://www.tensorflow.org/versions/r0.12/get_started/os_setup.html#pip-installation
sudo apt-get install python-pip python-dev
2、下载安装Tensorflow
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.0rc0-cp27-none-linux_x86_64.whl
3、测试Tensorflow
python >>> import tensorflow as tf >>> exit()
成功的话会出现以下信息:
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
4、我碰到的一个问题"AttributeError: NewBase is_abstract,ImportError: libcudart.so.7.5"
sudo pip install six --upgrade --target="/usr/lib/python2.7/dist-packages"
5、推荐IDE调试工具
pyCharm免费的社区版(community release)不支持远程调试,百度下载然后到bin里面,运行pycharm安装文件就可以了。
安装atlas(如果装了这个就不需要装下面的OpenBLAS了)
sudo apt-get install libatlas-base-dev
OpenBLAS
1、先下载git,然后安装OpenBLAS
2、添加lib库的变量路径
-
@H_435_502@echo'exportLD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH'>>~/.bashrc
Common Tools
1、安装来自Scipy的普通tools
-
@H_435_502@sudoapt-getinstall-ylibfreetype6-devlibpng12-dev
- pipinstall-Umatplotlibipython[all]jupyterpandasscikit-image
2、如果安装matplotlib时无法安装,按照下面方法:
先下载:here
然后减压matplotlib-1.5.0,并进入matplotlib-1.5.0里面
最后运行
-
@H_435_502@pythonsetup.pybuild
- pythonsetup.pyinstall
Caffe
1、caffe相信大家都很熟悉了,下面是一些基础依赖库
-
@H_435_502@sudoapt-getinstalllibprotobuf-devlibleveldb-devlibsnappy-devlibopencv-devlibhdf5-serial-devprotobuf-compiler
- sudoapt-getinstall--no-install-recommendslibboost-all-dev @H_435_502@sudoapt-getinstallpython-skimageipythonpython-pilpython-h5pyipythonpython-gflagspython-yaml
- sudoapt-getinstalllibgflags-devlibgoogle-glog-devliblmdb-dev
2、克隆caffe
3、如果安装了cuDNN然后把Makefile文件的USE_CUDNN := 1注释去掉
-
@H_435_502@sed-i's/#USE_CUDNN:=1/USE_CUDNN:=1/'Makefile.config
4、如果安装了OpenBLAS,修改BLAS参数,如果没有装openblas就不用修改
sed -i 's/BLAS := atlas/BLAS := open/' Makefile.config
5、开启python接口
WITH_PYTHON_LAYER := 1
6、开启matlab接口
MATLAB_DIR := /usr/local/MATLAB/MATLAB_Production_Server/R2015a
8、如果你装了3.0的opencv需要开启这个接口
OPENCV_VERSION := 3
9、安装需求build和测试caffe,编译PyCaffe
sudo pip install -r python/requirements.txt make all -j $(($(nproc) + 1)) make test -j $(($(nproc) + 1)) make runtest -j $(($(nproc) + 1)) make pycaffe -j $(($(nproc) + 1))
10、添加caffe的环境变量
echo 'export CAFFE_ROOT=$(pwd)' >> ~/.bashrc echo 'export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH' >> ~/.bashrc source ~/.bashrc
11、测试caffe接口
ipython >>> import caffe >>> exit()
Theano
1、安装Theano
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ python-pygments python-sphinx python-nose sudo pip install Theano
2、测试接口
python >>> import theano >>> exit()
Keras
1、这个编译器(关于Theano和Tensorflow)不是很熟悉,顺便安装一下试试。默认是Theano,如果想换Tensorflow,可以按照here.
-
@H_435_502@sudopipinstallkeras
Torch
1、这个是facebook的深度框架
2、添加环境变量
-
@H_435_502@source~/.bashrc
3、推荐IDE工具eclipse,安装相应的插件(Lua Development Tools)
首先安装eclipse c/c++的开发版,然后在官网搜索Lua,看到LDT就点进去,找到Existing Eclipse installation,按照官网指示安装插件,就ok了。
Mxnet
mxnet是cxxnet的下一代,目前实现了cxxnet所有功能,但借鉴了minerva/torch7/theano,加入更多新的功能。
- ndarray编程接口,类似matlab/numpy.ndarray/torch.tensor。独有优势在于通过背后的engine可以在性能上和内存使用上更优
- symbolic接口。这个可以使得快速构建一个神经网络,和自动求导。
- 更多binding 目前支持比较好的是python,马上会有julia和R
- 更加方便的多卡和多机运行
- 性能上更优。目前mxnet比cxxnet快40%,而且gpu内存使用少了一半。
1、安装依赖库
-
@H_435_502@sudoapt-getupdate
- sudoapt-getinstall-ybuild-essentialgitlibatlas-base-devlibopencv-dev
将mxnet/目录里找到mxnet/make/子目录,把该目录下的config.mk复制到mxnet/目录,用文本编辑器打开,找到并修改以下两行:
USE_CUDA=1
USE_CUDA_PATH=/usr/local/cuda
-
@H_435_502@gitclone--recursivehttps://github.com/dmlc/mxnet
- cdmxnet;make-j$($(nproc)+1
1、X2GO是一个远程控制桌面,下面是安装教程
sudo apt-get install software-properties-common sudo add-apt-repository ppa:x2go/stable sudo apt-get update sudo apt-get install x2goserver x2goserver-xsession
2、X2Go 不支持Unity desktop environment (the default in Ubuntu
sudo apt-get update sudo apt-get install -y xfce4 xfce4-goodies xubuntu-desktop
3、找使用机子的IP
hostname -I原文链接:https://www.f2er.com/ubuntu/355359.html