Deep learning environment configuration 6 - tensorflow-cpu=2.2.0 environment configuration under windows

Precautions

1. 2021/10/8 update

Many fans reported that TypeError: array () takes 1 positional argument but 2 were given errors, which can be solved by modifying the pillow version.

pip install pillow==8.2.0

study foreword

Many people don't have a graphics card and want to configure a deep learning environment. The tensorflow-gpu blog is useless. Get a CPU, so that it can be configured!

The environment configuration blog for the tensorflow2-gpu version is https://blog.csdn.net/weixin_44791964/article/details/109161493 .

insert image description here

environmental content

tensorflow-cpu: 2.2.0
does not need to install keras, because tensorflow comes with it.

Environment configuration

1. Anaconda installation

The installation of Anaconda is mainly for the convenience of environment management. You can install multiple environments on one computer at the same time. Different environments place different frameworks: pytorch, tensorflow, and keras can be installed in different environments. You only need to use conda create –n to create a new environment. That's it.

1. Download Anaconda

Students can choose to install the new version of Anaconda and the old version of Anaconda, there is no difference in the installation steps.

Download of the old version of anaconda:
The new version of Anaconda does not have VSCODE. If you can install the old version of Anaconda directly for the convenience of installing VSCODE, the Baidu network disk is connected as follows. You can also install the new version and then install VSCODE separately.
Link: https://pan.baidu.com/s/12tW0Oad_Tqn7jNs8RNkvFA Extraction code: i83n

Download of the new version of anaconda:
If you want to install the latest Anaconda, first log in to Anaconda's official website: https://www.anaconda.com/distribution/ . You can directly download the corresponding installation package.
insert image description here
insert image description here
Usually download 64-bit, open after the download is complete.

2. Installation of Anaconda

insert image description here
Select the installation location, you can not install it in the C drive.
insert image description here
I chose Add Anaconda to my PATH environment variable, which will automatically install anaconda into the system's environment variables, and the configuration will be more convenient.
insert image description here
After waiting for the installation, the installation of Anaconda is over.

Second, configure the tensorflow2 environment

1. Creation and activation of tensorflow2 environment

Win+R to start cmd, enter the following command in the command prompt:

conda create –n tensorflow2 python=3.6
activate tensorflow2

There are two instructions in total:
the previous one is used to create an environment named tensorflow2, and the python version of this environment is 3.6.
The last instruction is used to activate an environment called tensorflow2.

2. Installation of tensorflow2 library

Since all our operations must be performed in the corresponding environment, we need to activate the environment before installing the library.

activate tensorflow2

At this point, the cmd window looks like:
insert image description here
Then we enter the following command:

pip install tensorflow-cpu==2.2.0

Used to install tensorflow-cpu==2.2.0.

3. Installation of other dependent libraries

But if you want to run deep learning models, there are some other dependent libraries that need to be installed. details as follows:

scipy==1.4.1
numpy==1.18.4
matplotlib==3.2.1
opencv_python==4.2.0.34
tensorflow_cpu==2.2.0
tqdm==4.46.1
Pillow==8.2.0
h5py==2.10.0

If you want a more convenient installation, you can create a requirements.txt file on the desktop or elsewhere, and copy the above content into the txt file.
insert image description here

Use the following command to install it. In the following instructions, the path in front of requirements.txt is the path where I put the file on the desktop, and you can modify it according to your computer.

pip install -r C:\Users\33232\Desktop\requirements.txt

4. The installation is slow, please pay attention to changing the source

It should be noted that if the download and installation in pip is slow, you can change the source. You can go to the user folder, create a pip folder, and then create a txt file in the pip folder.
insert image description here
Modify the content of the txt file and change the suffix to ini

[global]
index-url = http://pypi.mirrors.ustc.edu.cn/simple
[install]
use-mirrors =true
mirrors =http://pypi.mirrors.ustc.edu.cn/simple/
trusted-host =pypi.mirrors.ustc.edu.cn

insert image description here
insert image description here
After all installation is complete, restart the computer.

3. Install VSCODE

I personally like VSCODE, so I installed it. Other editing software can also be, personal preference.

1. Download the installation package and install (recommended)

The latest version of Anaconda does not have VSCODE, so it can be installed directly with Baidu VSCODE.

a. Download of VSCODE

Directly load the official website of VSCODE https://code.visualstudio.com/ , click Download for Windows to download.
insert image description here

b. Installation of VSCODE

First agree to the agreement, click Next.
insert image description here
Several ticks in the other should be checked, because this way, you can right-click the folder to open it with VSCODE, which is very convenient. Next step.
insert image description here
Proceed to the next step to install.
insert image description here

After the installation is complete, you can change your environment in the lower left corner.
insert image description here

2. Install on anaconda

Open anaconda and switch environments.
insert image description here
Install VSCODE, you can launch it after installation, and then you can pin VSCODE to the taskbar for easy opening.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44791964/article/details/120656291