ubuntu14.04 installation TensorFlow

Source: Internet
Author: User
Tags lua theano mxnet

If the content of infringement, contact me, I will immediately delete the ~ because of the reference too much, if the one by one contact again, such as reply, the battle line is too long ~ ~ Crab crab to me to contribute to the author of the source of technology ~

Recently prepared to learn from the theory and experiment two aspects of deep learning, so, the front installed Theano environment, later know to see this answer, on the study of each deep learning framework, I did not look at the source code, research is not very deep, just to choose a deep learning framework to do a general understanding ~

1. How to choose the deep learning framework?

The resources are as follows:

1. https://github.com/zer0n/deepframeworks/blob/master/README.md

2. http://blog.csdn.net/qiexingqieying/article/details/51734347

3. https://www.zhihu.com/question/41907061

4. Http://www.open-open.com/news/view/1069a70

5. http://www.kuqin.com/shuoit/20151124/349098.html

Blog 2 summarizes the following:

Library name Development language Speed Flexibility Document Fit model Platform Use
Caffe C++/cuda Fast So so Comprehensive Cnn All Systems Medium
TensorFlow C++/cuda/python Medium Good Medium Cnn/rnn Linux\osx Difficult
MXNet C++/cuda Fast Good Comprehensive Cnn All Systems Medium
Torch C/lua/cuda Fast Good Comprehensive Cnn/rnn Linux\osx Medium
Theano Python/c++/cuda Medium Good Medium Cnn/rnn Linux\osx Easy

(1) Caffe

The first major industrial-level deep learning tool. It began at the end of 2013 with an excellent convolutional neural network that was written and maintained by the yangqing Jia teacher at UC Berkely. Caffe is still the most popular toolkit in the field of computer vision. It has many extensions, but is inflexible and poorly supported for recursive networks and language modeling due to some legacy architectural issues.

(2) TensorFlow

Google open-Source's second-generation deep learning technology is used in deep learning frameworks for Google search, image recognition, and mailboxes. is an ideal RNN (recursive neural network) API and implementation, TensorFlow uses the vector operation of the symbolic graph method, making the designation of the new network quite easy to support the rapid development. The disadvantage is that the speed is slow and the memory consumption is large. (e.g. relative to torch)

(3) MXNet

The open-source deep learning framework, Li Yu and Chen Tianchi, is an important part of the Common Toolkit DMLC for distributed machine Learning (Heroes). It focuses on flexibility and efficiency, and the documentation is very detailed, emphasizing the efficiency of memory usage and even the task of running image recognition on smartphones. (4) Torchfacebook's deep learning framework, the main development language is C and Lua. Have better flexibility and speed. It implements and optimizes the basic computational units, and the user can easily implement their own algorithms on this basis without wasting energy on computational optimization. The core computing unit uses C or Cuda to do a good job of optimization. Based on this, a common model is built using LUA. The disadvantage is that the interface is LUA language and takes a little time to learn. (5) Theano2008 was born in Montreal Polytechnic Institute, the main development language is Python. Theano derives a lot of deep learning python packages, most notably the blocks and Keras. Theano is very flexible, suitable for academic research experiments, and the recursive network and language modeling has a good support, the disadvantage is that the speed is relatively slow. The user's answer is as follows: Stanford's cs231n-convolutional neural Networks for Visual recognition (Winter 2016) in Lecture 12, by course lecturer @justin Johnson details his personal experience and views on the mainstream third-party library, with new time and dry goods:


Then he emphasized a few use case Issues
1.Extract AlexNet or Vgg features? Use Caffe
2.Fine tune AlexNet for new classes? Use Caffe
3.Image caption with finetuning?

Need pretrained models (Caffe, Torch, lasagne)

Need Rnns (Torch or lasagne)
, use Torch or lasagna

4.Segmentation? (Classify every pixel)

-Need pretrained model (Caffe, Torch, lasagna), Need funny loss function
If loss function exists in Caffe:use Caffe
If you want to write your own loss:use Torch

5.Object Detection?

-Need pretrained model (Torch, Caffe, lasagne)
-Need lots of custom imperative code (not lasagne), use Caffe + Python or Torch

6.Language modeling with new RNN structure?

-Need easy recurrent nets (not Caffe, Torch)

--No need for pretrained models
, use Theano or TensorFlow

7.Implemente batchnorm?

Don ' t want to derive gradient? Theano or TensorFlow

Implement Efficient Backward pass? Use Torch

Finally, JJ gives his own preference in a more personal way:

<img src= "Https://pic4.zhimg.com/162dfaed5ea30a18779ecb0eb9f2378b_b.png" data-rawwidth= " 1270 "data-rawheight=" 716 "class=" Origin_image zh-lightbox-thumb "width=" 1270 "data-original=" https:// Pic4.zhimg.com/162dfaed5ea30a18779ecb0eb9f2378b_r.png ">

The first part of the 5 framework of the introduction of some concepts and the basic advantages and disadvantages, first of all, I use the text training to learn, may need to use the RNN model, and I am more familiar with Python, C + + and Lua are not very good, so basically determine to understand Theano and TensorFlow these two frameworks, Redot in the content of the answer, choose TensorFlow or Theano, you can see that Daniel introduced mainly in the field of the image of some applications, and then 6th, Language modeling with new RNN Structure can also basically determine that we need both frameworks.

and choose who? Although Caffe's author, Jiayanqing, said "All are based on Python's symbolic arithmetic library, TensorFlow obviously supports better, Google also has more human input than the university." Theano's main developers are now at Google, and can expect to see more of a TF in future engineering resources. " User Zhang Hao said "1. See what you do application 2. See which framework can provide you with the most resources related to the problem you are doing. For example, such as doing language-related, in small data run experiments on the words I think Theano good, online can find the relevant resources (such as other related paper implementation, model) a lot. Caffe and torch may be a better choice if the Theano resources associated with visual correlation are much less than those of Caffe and torch. TF is also good, recently Google promote very strong, it is estimated that with the use of more and more people in a year or two more resources will be more and more. "Given that I'm only studying now, I decided to use Theano, but today I spent the crab time installing TensorFlow.

2. Installing TensorFlow

Ubuntu14.04+cuda7.5+cudnnv4+tensorflow

Basic according to the official tutorial can be installed https://www.tensorflow.org, and then the school sometimes do not open the interface, so you can also refer to here.

I choose the pip install mode.

$ sudo apt-get install Python-pip Python-dev

In fact, these tools seem to have been installed in front of, but afraid of the problem will be executed again, choose to meet their own situation of the command to carry on.

 - 2.7  7.5"Install from sources"  below.$ export tf_binary_url=https: // STORAGE.GOOGLEAPIS.COM/TENSORFLOW/LINUX/GPU/TENSORFLOW-0.9.0-CP27-NONE-LINUX_X86_64.WHL

An error occurred, in the tutorial common problems said:

... Sslerror: [ssl:certificate_verify_failed] CERTIFICATE VERIFY FAILED

Solution:download the wheel manually via curl or wget, and pip install locally. So use the wget command to download and then perform the installation.

wget https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64. WHLsudo pip install tensorflow-0.9. 0-CP27-NONE-LINUX_X86_64.WHL

Then test the TensorFlow.

Open a terminal and type the following:

$ python ...  as tf>>> hello = tf.constant ('Hello, tensorflow! ' )>>> sess = TF. Session ()>>> print (Sess.run (hello)) Hello, TensorFlow!>>> a = tf.constant (10  )>>> b = tf.constant (+)>>> print (Sess.run (A + b))  >>>

No problem.

' Import os; import inspect; import TensorFlow; print (Os.path.dirname (Inspect.getfile (TensorFlow))) '

The results are as follows:

Test run:

$ python-m tensorflow.models.image.mnist.convolutional

Error occurred:

[Email protected]:~$ python-m tensorflow.models.image.mnist.convolutional
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so Locallyi TensorFlow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so Locallyi TensorFlow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so Locallyi TensorFlow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so Locallyi TensorFlow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locallyextracting Data/train-images-idx3-Ubyte.gztraceback (most recent): File"/usr/lib/python2.7/runpy.py", line162,inch_run_module_as_main"__main__", fname, loader, pkg_name) File"/usr/lib/python2.7/runpy.py", line the,inch_run_code EXEC Codeinchrun_globals File"/usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist/convolutional.py", line the,inch<module>Tf.app.run () File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line -,inchRun Sys.exit (Main (SYS.ARGV)) File"/usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist/convolutional.py", line -,inchMain Train_data= Extract_data (Train_data_filename,60000) File"/usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist/convolutional.py", line the,inchExtract_data buf= Bytestream.read (image_size * image_size *num_images) File"/usr/lib/python2.7/gzip.py", line261,inchread Self._read (readsize) File"/usr/lib/python2.7/gzip.py", line308,inch_read self._read_eof () File"/usr/lib/python2.7/gzip.py", line347,inch_read_eof Hex (SELF.CRC))) IOERROR:CRC check failed0XE1D362BA!=0x90dd462el

Solution in https://github.com/tensorflow/tensorflow/issues/1319:

Therefore, enter the directory where the convolutional.py is located, modify the file permissions, and then modify the Work_directory data to/usr/local/lib/python2.7/dist-packages/tensorflow/ Models/image/mnist/data can be.

777 convolutional.py

Re-execute:

Python-m tensorflow.models.image.mnist.convolutional

There's still an error.

E tensorflow/stream_executor/cuda/cuda_dnn.cc:28650054007using from Sources, make sure the library loaded matches the version of you specified during the configuration.

You can see that the CUDNN version inconsistency is causing the problem.

Then there is a sentence on the official network "Download CuDNN V4 (V5 is currently a release candidate and was only supported when installing TensorFlow from so urces). "So I downloaded CUDNN v4.

Tar xvzf cudnn-7.0-linux-x64-v4.tgzsudo cp cuda/include/cudnn.h/usr/local/cuda-7.5/  Includesudo CP cuda/lib64/libcudnn*/usr/local/cuda-7.5/lib64sudo chmod a+r/usr/local/cuda-7.5/ include/cudnn.h/usr/local/cuda-7.5/lib64/libcudnn*

I forgot how to do it before, my/esr/local folder has two cuda files, one is Cuda one is cuda-7.5. Here I put him under the cuda7.5 folder.

Then execute the above command and there is no problem.

The middle Halo is also trying to install the source code, is the official online installation from sources, the basic steps are also in accordance with the above, combined with blog blog can be, hit the crab problem, the basic Google can find a solution.

This blog explains some of the knowledge of the TensorFlow source directory structure.

Here are a few small questions and workarounds:

(1)Oserror-errno Permission denied

Chown-r user-id:group-id/path/to/the/directory

(2)AttributeError: type object ‘NewBase‘ has no attribute ‘is_abstract‘

sudo pip install six--upgrade--target="/library/python/2.7/site-packages/"

(3)./configure in the TensorFlow directory, this configuration is used in the source code installation mode.

ubuntu14.04 installation TensorFlow

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.