Different from the “handgrip” of other introductory tutorials, this article emphasizes “cause” rather than “effect”. The reason why I add “general” is that after you understand the development environment, you will not make those very low mistakes.
We all know that deep learning involves a large number of models and algorithms. Looking at those messy formula symbols, we must have “WTF” in mind. What I want to say is that you don’t have to worry about all these things. It’s said that there must be a way for a car to get to the front of the mountain.
Installation package required
Usually, my habit is to contact a new technology in the simplest way, and try to get rid of the involvement of new (edge) technology. If the learning tree continues to expand due to some other factors, it will become very inefficient, so we go straight to the core. Take the most commonly used Windows environment as an example.
Here towindows7+TensorFlow-gpu1.5+cuda8+cudnn6+anaconda5+python3.6For example. The GPU version is highly recommended here, because deep learning can run in the market for hours, days and weeks, and GPU acceleration will save you a lot of time (even electricity).
- CUDA? 8.0.61? Windows.exe http://developer2.download.nvidia.com/compute/cuda/8.0/secure/prod2/local? Installers / CUDA? 8.0.61? Windows.exe: to download from nivdia official website, you need to find the historical versionLegacy Releases。 The CUDA library referenced by tensorflow code mustAbsolute matchingFor example, tensorflow1.3-1.5 all use cuda8 libraries. Currently (2017-10-24 20:40:53) cuda9 libraries are not supported.
Here is a patch about cuda8, which fixes some bugs of 8.0 http://developer2.download.nvidia.com/compute/cuda/8.0/secure/prod2/patches/2/cuda_.0.61.2_windows.exe
- cudnn-8.0-windows7-x64-v6.0.zip http://developer2.download.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170427/cudnn-8.0-windows7-x64-v6.0.zip：
As for the above reasons, please match version 6.0.
- tensorflow https://github.com/tensorflow/tensorflow：
The reason why I give the address of GitHub is that tensorflow team builds GitHub at 12:34 every day, and GitHub is not affected by “various” network factors. Find the GPU build history corresponding to Python 3.6 in tensorflow, and find the address of the what file.
- Anaconda3-5.0.0-Windows-x86_64.exe https://www.anaconda.com/download/：
One of the biggest advantages of anaconda is that it is convenient to install various Python libraries.
Installation package relationship
Anaconda is the container that tensorflow runs in. Anaconda can create multiple “boxes” (environments), and the environments in each box do not interfere with each other, so using Anaconda can install Python 3.5 / 3.6 and tensorflow 1.3 / 1.5 at the same time.
CUDA and cudnn are the necessary libraries for tensorflow to call GPU. That is to say, tensorflow must call GPU of computer through CUDA and cudnn.
Install anaconda, anaconda, CUDA, cudnn
- Anaconda, CUDA and cudnn can be installed. Environment variables are automatically configured during installation.
- However, you need to manually configure CUDA’s development directory to
- After extracting the cudnn, copy the file to the CUDA directory.
- Start anaconda, clickenvironments(environment), clickcreate(New), naming
- Click tensorflow GPU to startOpen TerminalInput
activate tensorflow-gpu。 Now, AnacondaEnvironment called tensorflow GPUIt’s already started. Now we are really starting to install tensorflow.
pip install --ignore-installed --upgrade http://ci.tensorflow.org/view/tf-nightly/job/tf-nightly-windows/M=windows-gpu,PY=36/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tf_nightly_gpu-1.5.0.dev20171024-cp36-cp36m-win_amd64.whl
After a while, tensorflow is installed successfully.
Test tensorflow environment
- Click the environment we created under Anaconda
tensorflow-gpustart-upOpen With Python
import tensorflowIf no error is reported, the installation is successful.
- Importerror: DLL load failed: the specified module could not be found. This error is usually the version of CUDA or cudnn corresponding to tensorflow. It is recommended to download cuda8 + cudnn6.
Of course, these versions will be phased out over time, but this tutorial still applies. Find the tensorflow project on GitHub and search within the project
TF_CUDNN_VERSIONYou will see which CUDA and cudnn version the current tensorflow corresponds to.
- Other errors.
I haven’t encountered any other errors except 1. If there is a troubleshooting idea, confirm that the version > confirms whether the library is included in the path. If it still can’t be solved, you can add my wechat
Running the MNIST example
- When running the MNIST example, you need to install the Matplotlib library. At this time, the convenience of anaconda is reflected. Click under Anaconda
tensorflow-gpuEnvironment, search Matplotlib on the right, check it and click apply.
- Download the MNIST tutorial example on GitHub https://github.com/martin-gorner/tensorflow-mnist-tutorial, and extract it.
- Start under Anaconda
tensorflow-gpuEnvironmental ScienceOpen TerminalInput
activate tensorflow-gpu, CD to step 2 extract the directory.