Deep Learning (1): Building TensorFlow

Recently reinstalled it again, here is a stroke:

1. Build a Linux virtual machine under win7

Reference link: Build a Linux virtual machine under win7

For Linux systems. The most easy-to-understand version is the famous Ubuntu, which is free to download and use. Download link: Ubuntu download , because it is said that the Ubuntu16 version will be stuck, so I chose Ubuntu14, desktop version, ubuntu-14.04.5-desktop-amd64. iso.

2. Build TensorFlow on Linux system

Because it is a Linux system installed in a virtual machine, TensorFlow chooses the CPU version instead of the GPU version.

There are many ways to install Tensorflow . For example, the official website provides:
① Pip installation
② Virtualenv installation
Anaconda installation
④ Docker installation :


2.1 Install pip

When installing with pip, make sure your pip is already present on your computer. If pip is not installed, press Ctrl+Alt+T to bring up the Terminal window, run the following code, and upgrade the necessary components:

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

You may need to install updates later (just follow the prompts):

pip install --upgrade pip

2.2 Install Python3 (skipable)

Download the version you like, address: https://www.python.org/getit/

installation steps:

  1. tar -xvzf Python -3.5.2.tgz -- decompress   the archive  
  2. cd Python- 3.5 . 1 /  
  3. ./configure --prefix=/usr/python --configure path  
  4. make  
  5. sudo make install -- perform the installation  
  6.   

 linux View python installation path, version number

Switch Python version:

First look at our default Python version

Use quit(), exit(), or Ctrl-D to exit the Python command line.

2.3. Installation of basic library anaconda and integrated development environment IDE spyder

Installation link reference: (Written very comprehensively, just follow the installation)

https://blog.csdn.net/Solo95/article/details/78960389

https://blog.csdn.net/colourful_sky/article/details/73823939

Follow the two references above. :

① Before activating TensorFlow, possible problems: conda: command not found:

https://blog.csdn.net/w5688414/article/details/78647063

Solution:

export PATH=~/anaconda3/bin:$PATH  

②Create a conda computing environment named tensorflow: just enter the command in the terminal, here is the Python3.6 version

      cd ~ #Switch root directory
conda create -n tensorflow python=3.6

It may be very slow in this process, you can replace it with other Chinese sources, in the step of operation ②, the download speed will be much faster:

Source link:

https://www.cnblogs.com/moonlightpoet/p/5615602.html (University of Science and Technology of China)

https://blog.csdn.net/Solo95/article/details/78960389 (Tsinghua source)

③ Activate the tensorflow environment and continue to enter the following command in the terminal:

source activate tensorflow


④Install TensorFlow:

Tensorflow (after 0.12) has been updated to bypass the complicated installation steps. If you only need to install the CPU version of Tensorflow, Ctrl+Alt+T can call up the terminal and run the following:

# For users of python 2+:
$ pip install tensorflow

# For users of python 3+:
$ pip3 install tensorflow

If you follow the above command, most of the failures will be caused by the download failure. You can download it first, then use the cd command to open the installation package folder, (for example, I put it in Documents and use cd Documents), and then run sudo pip install --upgrade tensorflow-0.8.0-cp27-none-linux_x86_64.whl, the terminal is case-sensitive and space-sensitive, pay attention.

⑤ In order to write the code in the later stage, we need to add a function base library and a Spyder editor for easy debugging

If you want to use spyder in the TensorFlow environment, then install another spyder in the tensorflow environment. OK, then let's start the installation. 
In the tensorflow environment, install spyder with conda in the terminal. Enter the following command:

conda install spyder
  • 1

然后会看见安装目录位于我们之前建好的tensorflow环境下,也会看到安装spyder会安装许多依赖包,然后输入y,大概10分钟后就安装好了。这时我们在终端输入spyder打开spyder,在IPython console下输入import tensorflow,如果没有报错则表明安装成功了。


3.如何使用Spyder调试:

看下面链接前需了解:简单Linux的终端操作杂记


调试步骤参考:

https://blog.csdn.net/qq_33256688/article/details/77675885?locationNum=1&fps=1

4. 安装好后每次打开Spyder:

① 激活tensorflow环境,继续在终端输入一下命令:

source activate tensorflow

② 在TensorFlow环境下激活Spyder,,继续在终端输入一下命令:

spyder


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324776842&siteId=291194637