Configure cuda_caffe_cudnn_anaconda_digits and caffecudacudnn on ubuntu14.04
Refer to many web sites on the Internet, mainly to this: http://blog.csdn.net/yhl_leo/article/details/50961542
This is the beginning of my summary series for caffe. First, because caffe has many dependencies, it is also difficult to configure. This article details the configuration of caffe in detail. Indicate the source for reprinting.
We recommend ubuntu14.04 because digits supports better. If the video card support does not support GPU acceleration, you need to be clear. If it does not support it, use the CPU. Don't waste time on cuda.
Follow the instructions in the official tutorial. However, some of the pitfalls in the official tutorials have not been found. This article is also tied up.
I. graphics cardInstallation
Disable the nouveau driver. nouveau is an open source driver for nivida that comes with ubuntu. It has problems with installing the nvidia official driver, so disable it first.
Press Ctrl + Alt + F1 to enter the tty1 console and enter
Sudo vim/etc/modprobe. d/blacklist-nouveau.conf
Write in it
Blacklist nouveau
Options nouveau modeset = 0
Press esc and enter wq to save and exit.
Ps: The vim editor is very easy to use. It doesn't take any time for anyone to learn it.
Run
Lspci | grep nouveau
Query whether there is nouveau In the pci bus. Follow the Regular Expression Filter after grep.
Nothing indicates that it is disabled successfully.
After the restart, you may enter the logon password cyclically and cannot enter the system. Press Ctrl + Alt + F1 to log on,
How to uninstall a video card:
Sudo apt-get remove -- purge nvidia *
Install the video card driver:
$ Sudo add-apt-repository ppa: xorg-edgers/ppa
$ Sudo apt-get update
$ Sudo apt-get install nvidia-352
Run sudo start lightdm and enter the password to view the desktop.
Ps: after the video card driver is down, you may not be able to see the system interface. After the driver is started, the monitor turns dark. In fact, the system is running. My practice is to install the SSH service in advance. In this case, log in to another computer using SSH to install the driver.
II,CUDA Installation
Download the CUDA official website. In fact, the download should be done first. If you don't have time to use the graphical interface to download it, use wget, curl, and so on. It is said that 331 of the drivers are pitfall. We should not use that driver. Install some dependencies below/
Sudo service lightdm stop
Sudo apt-get install g ++
Sudo apt-get install git
Sudo apt-get install freeglut3-dev
First download the installation file on the official website (provided above ):
I downloaded the deb local Installation File. After the download is complete, follow the command prompted in the document to install it:
Sudo dpkg-I cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
Sudo apt-get update
Sudo apt-get install cuda
Download the Installation Guide for Linux below, which contains the setting methods for environment variables:
If yes, the installation is successful. You cannot unmount it as follows:
Sudo/usr/local/cuda-7.5/bin/uninstall_cuda_7.5.plsudo/usr/bin/nvidia-uninstall
Finally, to configure environment variables, we put them in the System Configuration File profile and open the profile file first.
Sudo vi/etc/profile
Add two lines of code at the end:
Export PATH =/usr/local/The cuda-7.5/bin: $ PATH
Export LD_LIBRARY_PATH =/usr/local/cuda-7.5/lib64: $ LD_LIBRARY_PATH
Run source/etc/profile to make the environment variable take effect.
Cuda installation is now complete
III,CUDNN Installation
CUDNN accelerates CUDA. CuDNN is the library for GPU-accelerated deep neural networks. Download the cudnn official website. It seems that the download must be registered first, and it may take several days to pass the review. Decompress the downloaded package.
Run the following command:
Sudo tar xvf cudnn-7.0-linux-x64-v4.0-prod.tgz & cd cuda/include & sudo cp *. h/usr/local/include/& cd .. /lib64 & sudo cp lib */usr/local/lib/& cd/usr/local/lib & sudo chmod + r libcudnn. so.4.0.7 & sudo ln-sf libcudnn. so.4.0.7 libcudnn. so.4 & sudo ln-sf libcudnn. so.4 libcudnn. so & sudo ldconfig
In this way, the installation of CUDNN is complete, isn't it easy.
IV,Installing Anaconda
To download anaconda from the https://www.continuum.io/downloads, we recommend using python 2.7 For linux, because some of tensorflow's stuff does not support python3.5 (such as cPickle ).
After the download is successful, run it on the terminal (version 2.7 ):
# Bash Anaconda2-4.1.1-Linux-x86_64.sh
Or version 3.5:
# Bash Anaconda3-4.1.1-Linux-x86_64.sh
During the installation process, you will be asked about the installation path. Press enter to set the default installation path. If you want to add the installation path of anaconda to the environment variable (. bashrc), enter yes.
After the installation is successful, an anaconda2 folder is generated under the root directory of the current user, which contains the installed content. You can enter
Conda info to query installation information
Enter the conda list to query which libraries you have installed, including python, numpy, and scipy. You can run
Conda install *** to install (** indicates the package name). If a package version is not the latest, run conda update.
V,Caffe Installation
First, install opencv. We recommend that you use version 2.4. Opencv1.x is written in c language only. 2.x c and c ++ packages are available. opencv3 is only written in c ++. It is recommended to install 2.xfor the code written by others to run normally.
Opencv2.4 is easy to install. Download and decompress opencv2.4. Then, go to the make directory and run sudo make install.
For caffe official download, follow the official Installation Guide. l another method is to download the command line.
Download caffe:
Sudo git clone https://github.com/BVLC/caffe.git
If you have not installed Git, read the blog: install and use Ubuntu Git.
Then compile caffe: first install the dependency:
Sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
$ Sudo apt-get install -- no-install-recommends libboost-all-dev
$ Sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
$ Sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
Jia Yang, the god of the Qing Dynasty, also said, everyone must be clear!
Configure caffe and compile caffe.
Sudo cp Makefile. config. example Makefile. config
# Adjust Makefile. config (for example, if using Anaconda Python, or if cuDNN is desired) make all make test make runtest
Note the following points in the configuration file:
# CuDNN acceleration switch (uncomment to build with cuDNN ).
USE_CUDNN: = 1
# CPU-only switch (uncomment to build without GPU support ).
# CPU_ONLY: = 1 BLAS choice: # atlas for ATLAS (default)
# Mkl for MKL
# Open for OpenBlasBLAS: = atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (Which shocould work )!
# BLAS_INCLUDE: =/path/to/your/blas
# BLAS_LIB: =/path/to/your/blas
Choose from the following options based on your needs.
If make all is okay, caffe will be successful.
Save and re-compile: (if the computer has eight threads, add-j8 to the end to speed up compilation)
Sudo make clean
Sudo make all-j8
Sudo make test-j8
Sudo make runtest-j8
The following error occurs during the last step of Compilation:
Libcudart. so.7.5 cannot open shared object file: No such file or directory
There are a bunch of introductions on the internet, how to set the environment variables (we have already set them), you can check whether the environment variables have been added as follows:
$ Echo $ PATH $ echo $ LD_LIBRARY_PATH
You can see that the environment variable has been added.
The solution is to copy some files to the/usr/local/lib Folder:
Sudo cp/usr/local/cuda-7.5/lib64/libcudart. so.7.5/usr/local/lib/libcudart. so.7.5 & sudo ldconfig
Sudo cp/usr/local/cuda-7.5/lib64/libcublas. so.7.5/usr/local/lib/libcublas. so.7.5 & sudo ldconfig
Sudo cp/usr/local/cuda-7.5/lib64/libcurand. so.7.5/usr/local/lib/libcurand. so.7.5 & sudo ldconfig
Again, try the sudo make runtest command and the following occurs:
Caffe has been installed.
Import the caffe path to the environment variable and run the following command:
Sudo vi ~ /. Bashrc
Add export PYTHONPATH =/home/***/caffe/python: $ PYTHONPATH
Export CAFFE_HOME =/home/***/caffe: $ CAFFE_HOME
Then run sudo ldconfig.
Then execute sudo make pycaffe in caffe. If there is no error, OK. Test whether caffe is successful,
Enter python press enter on the terminal, and the import caffe parameter is OK,
If No module named google. protobuf. internal appears
Solution reference link: http://www.th7.cn/system/lin/201605/164288.shtml
Sudo chmod 777-R anaconda2 (folder) change the permission and then
Conda install protobuf
That's it ~
Sat.,Install DIGITS
Reference link:Http://www.cnblogs.com/denny402/p/5136155.html
1. Install digits 3.0
Digits runs on cuda and caffe. Therefore, you have to configure cuda + caffe first. Not yet configured. Please refer to: Caffe Learning Series (1): install and configure ubuntu14.04 + cuda7.5 + caffe + cudnn
Open a terminal and run the following commands in sequence:
Cd
Sudo-s
Enter the root directory of the current user and switch to the superuser (the symbol is changed from $ to #, and sudo is not required for every sentence)
CUDA_REPO_PKG = cuda-repo-ubuntu1404_7.5-18_amd64.deb &&
Wget tables &&
Sudo dpkg-I $ CUDA_REPO_PKG
Next
ML_REPO_PKG = nvidia-machine-learning-repo-ubuntu1404_4.0-2_amd64.deb &&
Region &&
Sudo dpkg-I $ ML_REPO_PKG
Apt-get update
Apt-get install digits