Some time ago, I bought a server in Ali Cloud to deploy the website. Recently, I want to play some deep learning projects, which I just use. The installation of TensorFlow official website only mentions Ubuntu, but MY ECS operating system is CentOS 7.6 64-bit, so I encountered many problems in the process of building Python, TensorFlow, and Jupyter development environment. Here will be specific steps to share with you, you can take a lot of detours. \

 

Step 1 Install Anaconda

Anaconda is still powerful on Linux, making it easy to manage toolkits, development environments, and Python versions.

Create a folder in the root directory to store the Anaconda installation package

~# mkdir anaconda

~# cd anaconda

To ensure the download speed, you are advised to select tsinghua University mirror station

mirrors.tuna.tsinghua.edu.cn

Select the version and copy the link

Run in anaconda:

Wget mirrors.tuna.tsinghua.edu.cn/anaconda/ar…

An error may occur, most likely because the host address cannot be resolved, which is also a DNS resolution problem.

Solutions:

Log in to the root

# sudo vim /etc/resolv.conf

The modified content is as follows

Nameserver 8.8.8.8

Nameserver 8.8.4.4

Switch to the file location of Anaconda3

# bash Anaconda3-2019.03 – Linux – x86_64. Sh

Yes all the way until the installation is complete

If there is an error, it is because anaconda3 was created before

Solutions:

# bash Anaconda3-2019.03 – Linux – x86_64. Sh -u

To test this, python PIP has also been installed successfully

If the installation path is not added to the system environment variable during Anaconda installation, you need to manually add it after the installation:

1. On the terminal, enter vim/etc/profile to open the profile file.

2. Add a line at the end of the file:

ExportPATH =/root/anaconda3/bin:$PATH, save.

3. To make the modification of /etc/profile take effect immediately, run the source /etc/profile command

In addition, Anaconda will create a default environment called base after installation. The word “base” appears in the front of Linux terminal interface. If you don’t mind, you can skip this step:

Enter conda deactivate in the terminal to remove the base word. However, this is one-time. The base word still exists when you open the terminal again. Add the command conda deactivate to the. Bashrc file to permanently remove the base word.

1. Open a terminal and run the gedit ~ /. Bashrc \ command

2. Add the conda deactivate command to the end of the. Bashrc file

Step 2 Install the virtual environment

Virtualenv is a tool to create an isolated Python environment, using VirtualEnv to create a folder containing all the executable files necessary to use packages for Python projects.

Conda can also configure virtual environments and clone directly from base

# conda create -n myenv–clone base

However, I am still used to using Virtualenv, conda method of subsequent configuration method, you try your own.

** install virtualenv **

# pip install virtualenv

When installing PIP package, the system default is aliyun image. I have tried several image sources and found that tsinghua image source is faster. Let’s modify the configuration file:

# mkdir ~/.pip\

# cd ~/.pip

# vi pip.conf

Change the file content to the following and save the file.

[global]

index-url =pypi.mirrors.ustc.edu.cn/simple/

2, install the virtual environment, select Python3.7, environment name: myenv\

# conda create -n myenv python=3.7

3. Activate the virtual environment

# source activate myenv

4. Install TensorFlow in the virtual environment

# pip install –ignore-installed –upgrade packageURL

The URL provided on the official website is from Google, for well-known reasons… So we downloaded and installed it from pypi.org

PIP install – ignore – installed – upgrade files.pythonhosted.org/packages/2a…

Test it and install it successfully!

Step 3 Set up Jupyter and access it remotely

After Anaconda was installed, so was Jupyter

Juypter is integrated in Anaconda and not in myenv, so we need to go back to step 2 to activate the environment and then install Jupyter :\ again

# pip install jupyter

Running #jupyter Notebook after the installation is complete will result in an error saying that the file cannot be found or something, and that the environment variable was not configured.

Solution: \

# vim /root/.jupyter/jupyter_notebook_config.py 

Change a few places:

C. notebookapp. IP = ‘IP address’ #

C. notebookapp. password = u’ secret key ‘

C. notebookapp. port = 8889 # Port number, set by yourself

c.NotebookApp.enable_mathjax = True 

C.N otebookApp. Notebookdir = “jupyter installation address \”

The IP address can be queried in the console instance list. The following figure shows the private IP address

The secret key can be generated using ipython, and yes anaconda also has ipython integration. Set a simple password (don’t forget, it will be used later) and copy the generated secret key, with the following code: \

Query the jupyter installation address

Amend the above address to/root/anaconda3 envs/myenv/bin

After the above modification, run Jupyter Notebook \ again

But it’s not over yet.

We also need to set the security rules for the ECS instance so that the inbound and outbound directions are the same.

At this point, all Settings are complete! Run the Jupyter Notebook on the server, and the process runs in the background.

Look up the IP again in the console instance list

http://first IP address :8889, copy to the local PC browser, enter the password, you can access! Let’s test it. Everything’s fine. We’re done!

\

Add wechat and we will continue chatting in the wechat group