Configure TensorFlow in CentOS

Source: Internet
Author: User

Configure TensorFlow in CentOS

I recently learned machine learning and started to learn deep learning. I have to mention TensorFlow of Google's family. Today I will record how to install TensorFlow.

TensorFlow only supports Linux, so you do not need to consider it. Either a dual system or a virtual machine. Here I installed it in a notebook for employment, so I can only use a virtual machine. In fact, it is best to use a dual-system, so that you can use the power of the video card, provided that you have a megada video card.

Step 1: Go to the Anaconda official website to download the installation package, find the Linux 64-bit Python2.7 installation package, and download the package to your local device.

Step 2: Use WinScp to upload the file to the CentOS virtual machine. The preparation is complete.

I am used to uploading data to the root directory, so I can directly repeat the command line. If you want to put it in another directory, you need to set the path first.

The command is as follows:

 
 
[Plain] view plain copy 
 
  1. <Spanstyle = "font-size: 14px;"> bashAnaconda2-4.0.0-Linux-x86_64.sh </span>
By default, the installation is good. It is best to test the command after installation: conda -- v. if the version information is displayed, the installation is successful.
 
 

I tried it several times but failed. I was prompted to run conda: command not found. At first, I thought the installation version was incorrect. I checked that the directory was correctly installed, it is best to find that the system path is not successfully configured, so you have to manually add it. The command is as follows:

export PATH=~/anaconda/bin:$PATH
Test again. The version information is successfully output.

Step 3: Create a Conda virtual environment to run TensorFlow. The command is as follows,

[Plain] view plaincopy
  1. <Spanstyle = "font-size: 14px;"> # Python2.7
  2. $ Condacreate-ntensorflowpython= 2.7 </span>

In this case, Conda will install some necessary packages. After installation, a virtual space named tensorflow is created.

Next, activate the space. The command is as follows,

[Plain] view plaincopy
  1. <Spanstyle = "font-size: 14px;"> $ sourceactivatetensorflow </span>

The space name is displayed before the command prompt.

Step 4: Install TensorFlow in this space. The command is as follows,

[Plain] view plaincopy
  1. <Spanstyle = "font-size: 14px;"> $ pipinstall -- ignore-installed -- upgradehttps: // upgrade </span>

After a long wait, the installation is complete! I have to talk about the company's network speed

The last step is test!

[Plain] view plaincopy
  1. $ Python
  2. ...
  3. >>> Importtensorflowastf
  4. >>> Hello = tf. constant ('hello, TensorFlow! ')
  5. >>> Sess = tf. Session ()
  6. >>> Print (sess. run (hello ))
  7. Hello, TensorFlow!

The output is successful! You can enjoy learning AI!

Exit the virtual environment after testing.

[Plain] view plaincopy
  1. (Tensorflow) $ deactivate

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.