Record of configuring deep learning environment under Windows 10 (graphics card driver+CUDA+TensorFlow+Anaconda+PyCharm)
Preface
Since I mostly use Linux and less win10 when running models, I have written relatively few related blogs. This time, I took advantage of helping my classmates configure the environment to conduct a full documentary.
Installed software:
GTX 950M graphics card driver
tensorflow1.12.x and tensorflow1.13.x
CUDA9.2 and CUDA10.0
Anaconda3
PyCharm
First, the TensorFlow versions required by this environment are tensorflow-gup==1.12
and tensorflow-gup==1.13
. Therefore, if you check the version correspondence, you will know that the cuda versions that need to be installed are cuda9 series and cuda10.0. Simply put, if you want to use a graphics card to accelerate your deep learning, you need to install these two toolkits. [ Correspondence between tensorflow and cuda ], [ What is CUDA ], [ What is cudnn ].
Since the CUDA supported by the graphics card driver is backward compatible, just install the latest graphics card driver.
For the Python environment, choose to install Anaconda, which can be simply understood as an enhanced version of Python. [ What is Anaconda ], [ Correspondence between TensorFlow and Python ]
IDE chooses PyCharm. [ Pycharm common operation tutorial ]
1 Graphics card driver installation
Using nvidia-smi, I found that the command was invalid, so I chose to reinstall the graphics card driver on his computer. Just install the latest version of the graphics card driver. The CUDA version it supports is backward compatible.
GTX series graphics card download URL (it is faster to access this URL directly for gtx series graphics cards. You can also open NVIDIA's official website first. After all, you still need to log in when downloading cudnn. Um, let's complain about the access speed of Nvidia's website this month. slow). Select the corresponding driver to download and install. This step is very simple, please allow me to skip it.
2 Install CUDA and cudnn
CUDA download address
cuDNN download address (need to log in to Nvidia account)
2.1 CUDA download
CUDA10.0 and CUDA9.2 download location:
CUDA9.2 download: Select the configuration [ Windows- x86_64 - 10 - exe
], and download the installation package and patches. When installing, first install the installation package, and then install the patch:
CUDA10.0 download: similar to CUDA9.2.
2.2 cudnn download
Search for cudnn corresponding to CUDA9.2 and CUDA10.0 respectively, use CTRL+F to search, and download any one of them.
2.3 CUDA and cudnn installation
2.3.1 cuda9.2 installation package installation
1: Select the installation package extraction location (a temporary location, just create a new English path as the directory, the system will automatically delete it after the installation is completed), and the system compatibility will be checked after the decompression is completed.
2. Agree to the license agreement
3. Select custom installation [Note: Select custom installation (please develop the habit of selecting custom installation when installing software in the future)] 4. Custom
option [ Devolopment+Runtime
], the remaining documents and samples will not be installed, and No need to integrate into VS. The following three drivers have basically been installed or do not need to be installed when installing the graphics card.
5. Select the installation location [I customized the location of the development tools that I am used to, please choose and remember this by yourself] 6. The
installation package is installed
7. Patch installation: The patch installation process and the installation package installation process are very similar. 【提取位置不变+都选择自定义安装+自定义选项只有Development和Runtime两个全选+安装位置选择和安装包相同的安装位置
】
2.3.2 cudnn for CUDA9.2 installation
bin目录
As shown in the figure, you only need to put the files under , include目录
and in the decompressed cudnn lib目录
folder into the corresponding folder under the CUDA installation package.
bin
- cudnn64_7.dll
include
- cudnn.h
lib
- x64
-cudnn.lib
2.3.3 CUDA9.2 inspection
Use nvcc -V
the command to detect (nvidia-smi is used to check whether the graphics card driver is installed successfully), and then 重启
.
2.3.4 CUDA10.0 installation
As long as CUDA9.2 can be installed successfully, there will be no problem with the installation of CUDA10 and the corresponding cudnn. Since CUDA10.0 has no patch, it is more convenient to install.
注意在进行安装时,需要将CUDA9.2卸载,或者在环境变量中将CUDA9.2对应的变量利用【# 、*等特殊符号】进行注释(推荐,这样更加方便切换)
.
2.3.5 cudnn for CUDA10.0 installation
(slightly)
2.3.6 CUDA10.0 inspection
Remember to restart (omitted)
3 Anaconda3 installation
3.1 Anaconda download
You can choose to download from the official website or Tsinghua Mirror Station . It is recommended to download from Tsinghua Mirror Station. Sort by date first.
Select the latest Windows version 64-bit to download.
3.1 Anaconda installation
1. Check whether it is 64-bit or 32-bit, and then proceed to the next step.
2. Agree to the license agreement
3. Available to everyone.
4. Select the installation directory.
5. Click the first check mark: add it to the environment variable! ! !
6. Installation in progress. Wait for some time.
7. The installation is completed. If you want to see the introduction, you can select these two options.
3.3 Anaconda source change
Since the official website of anaconda is abroad, the download speed is extremely slow, and download failures often occur. In order to download the required software package faster, you need to wake up anaconda to change the source. Just follow the help in the Anaconda Tsinghua Mirror Station to change the source . very simple.
4 Generate virtual environment
4.1 Creation and use of virtual environment
Open Anaconda prompt
or windows PowerShell(管理员)(A)
.
Create a virtual environment
conda create -n VE1 python=3.6
Open virtual environment
conda activate VE1
Install tensorflow1.13.1
pip install -i https://mirrors.aliyun.com/pypi/simple tensorflow-gpu==1.13.1
4.2 Virtual environment location
The virtual environment is under the Anaconda installation path envs文件夹
.
Install opencv-python
pip install -i https://mirrors.aliyun.com/pypi/simple opencv-python
Install PIL
pip install -i https://mirrors.aliyun.com/pypi/simple pillow
Exit the virtual environment
conda deactivate
5 PyCharm installation and trial activation
5.1 PyCharm download
1. Open the PyCharm official website and click Download.
2. Download other versions under Windows (click the blue Download directly to download the latest version, which is not recommended here). Click on the lower left corner Other versions
.
3. Select the appropriate version to download [win-64-bit-Professional Edition-2018.3].
5.2 PyCharm installation
1. Select the installation location
. 2. Select the version. [64-bit + added to environment variables]
3. Installation
5.3 PyCharm running
1 Enter the activation code to activate.
Enter activation code.
2 Select Evaluate for free.
Set the virtual environment just created for the project: [ File - Settings - Project Interpreter - Add - Conda Environment - Existing environment(下边忘了用框框起来了) - Interpreter路径 - python.exe
]
The virtual environment is in the env folder under the Anaconda installation path.