This article describes how inAnacondaenvironment, download and configure thePythonA new version of the commonly used machine learning, deep learning intensorflow
The library approach.
In two previous postsPython TensorFlow deep learning regression code: DNNRegressortogether withPython TensorFlow deep neural network regression:In it, we introduced the use ofPythonhit the nail on the headtensorflow
library that implements themachine learningtogether withdeep learningspecific ideas and code implementations; however, there was no specific description of the originaltensorflow
library configuration method. So, in this article, we'll cover the methods for configuring the library in theAnacondaenvironment, configure thetensorflow
library for detailed methods; in addition, it should be noted here that in newer versions of thetensorflow
Libraries (versions greater than1.5
But forWindowsFor users, the version cannot yet be higher than2.10
), which already supports bothCPU、GPUtraining, there is no longer a need to distinguish between being configuredCPUversion of the library or theGPUversion of the library now.
First, andAnacondaenvironment to configure other libraries as well, we need to open theAnaconda Promptsoftware; as shown below.
A terminal window will then pop up as shown below.
Next, we can begintensorflow
Configuration of the library. Since I'm hoping here to set thetensorflow
library is configured to another existingAnacondaIn the virtual environment (the name of this virtual environment ispy36tf
,PythonThe version is3.6
) instead of this current defaultbase
environment and therefore need to follow the articleWays to create an Anaconda virtual Python environmentThe first thing to do is to go to the program calledpy36tf
in the virtual environment, as shown in the following figure.
If people need to configure the default environment intensorflow
libraries, you can perform the next actions directly; if you wish to create a new environment to configure thetensorflow
library, then refer to the article mentioned aboveWays to create an Anaconda virtual Python environment, create and enter a new virtual environment, and then just continue with the next actions.
Next, go ahead and enter the following code to begin configuration immediatelytensorflow
Coop.
pip install --upgrade tensorflow
After running the above code, you can see that it will start immediatelytensorflow
The library is configured as shown below. Among other things, since I'm herePythonThe version is3.6
of the newestPythonversion, so as you can see from the image belowtensorflow
The library version is also not up-to-date, but2.6.2
version of it - and that's certainly enough for me. If people wish to use the latest version oftensorflow
library, care needs to be taken to also use the latestPythonVersion.
Also, it's important to mention here - if I use the code shown below for thetensorflow
library configuration, the configuration gets thetensorflow
The library, on the other hand, isversion, rather than the one we just got above which is the
version, it was never possible to get the latest version of the
tensorflow
library; and no matter how it is updated after thattensorflow
libraries, all of which report an error message.
conda install tensorflow
For example, on my computer, if I run the above code, the result is shown below.
I don't know exactly where the problem is, but you can see from the picture above that this method gets thetensorflow
The library is alwaysversion (e.g. shown above)
tensorflow
library1.2.1
(the version). So, if people need to compare newer versions oftensorflow
library, it is still recommended to use the previously mentionedpip install --upgrade tensorflow
This code does it.
Let's go back to the foregoingtensorflow
The library configuration is in the works; wait a moment and it's usually done!tensorflow
library configuration. It is important to note here that if at this point you get an error as shown below, thetensorflow
The library is still not configured successfully for now.
This situation is due topip
This is caused by not having a high enough version, so we need to set thepip
Upgrade.
python -m pip install --upgrade pip
Enter the above code as shown below.
After running this code, we re-run it oncepip install --upgrade tensorflow
This code is sufficient. However, in my case, after re-running this code, I got the problem again as shown below.
By checking, it was found that there was a problem with the web proxy; after closing the proxy, the problem could be solved (but it was strange, I don't know why this error was not reported just now, and it appeared only after re-running this code). In the end, the resulting interface is shown below.
Next, we can check this by entering the following codetensorflow
Whether the library has been configured successfully.
python -c "import tensorflow as tf;print(tf.reduce_sum(([1000, 1000])))"
As shown below, if you end up with aThe result will show that our
tensorflow
The library is finally configured.
At this point, the big success is complete. Of course, getting here may not be a complete success - as you can see from the image above, the currenttensorflow
The library does not carryGPUCalculations. If everyone's computer does not haveGPUor do not need to useGPUAdd it to the calculation, then you don't have to worry about the problem, which is equivalent to having been fully successful, and follow up by starting directly with thetensorflow
libraries for all kinds of deep learning applications will suffice; but for computers withGPUand also wants to makeGPUFor those joining computing, we'll cover the specifics of how to configure it in the next blog.