Install theano and configure GPU in Win10, win10theano
I. Software and Environment
(1) installation date;
(2) Raw Materials VS2013, cuda-8.0 (it is best to download cuda7.5, the current theano-0.8.2 for cuda-8 support is not very good), Anaconda3-4.2.0 (64-bit );
(3) The environment is win10.
Ii. Installation Steps
(1) install VS2013. There is nothing to say. After downloading the 64-bit version, you just need to take the next step. Remember to install the 64-bit version. The installation directory here is D: \ software \ VS2013:
Right-click my computer-> properties-> advanced system settings-> environment variables, edit the system variable Path, and add two paths D: \ software \ VS2013 \ VC \ bin and D: \ software \ VS2013 \ Common7 \ IDE, separated by semicolons,
Click OK.
(2) install cuda. There is nothing to say about this. Download cuda from the official website and click "Next" and click "OK". Note that if win10 prompts to block an operation during installation, be sure to allow this operation or all the operations of the program. Otherwise, the cuda installation will fail. Cuda official website address:
Http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/#axzz46v2MC6l8,
For https://developer.nvidia.com/cuda-downloads,
(Note: This is the cuda-8 version, the current version of theano support is not very good, but does not affect the use, it is best to download cuda7.5, I am too lazy to reload it again, so the use of the cuda-8)
Remember the cuda installation path, which is C: \ Program Files \ nvidia gpu Computing Toolkit \ CUDA \ v8.0,
(3) Right-click my computer and choose Properties> advanced system Settings> environment variables. Two variables CUDA_PATH and CUDA_PATH_V8_0 are added to the system variables,
Then, edit the system variable Path and add two paths, % CUDA_PATH % \ lib \ x64 and % CUDA_PATH % \ bin, separated by semicolons,
Click OK.
Open the command line and enter nvcc-V. If yes, the installation is successful:
Go to the C: \ ProgramData \ NVIDIA Corporation \ CUDA Samples \ v8.0 \ utiutilities \ deviceQuery directory and open and run the test sample deviceQuery_vs2013.vcxproj in VS2013. (note C: \ ProgramData is a hidden folder. You need to click drive C-> View-> options-> View, select and display the hidden files, folders, and drives, and click OK .)
The figure shows the viewing options of the C: \ ProgramData folder.
Figure shows the location of deviceQuery_vs2013.vcxproj.
The figure shows the running result in VS2013.
If the last row is Result = Pass, the configuration is successfully installed.
(4) install the Anaconda3-4.2.0, this is very simple, is a way to determine, remember the installation location, such as I am installed in D: \ software \ Anaconda3,
Right-click my computer> Properties> advanced system Settings> environment variables, add PATH to user variables, and add path d: \ software \ Anaconda3, D: \ software \ Anaconda3 \ Scripts and D: \ software \ Anaconda3 \ Library \ bin, click OK.
Enter the command line and enter python. If any information appears, the installation is successful:
Close the command line.
(5) install mingw and libpython. Open the command line and enter conda install mingw libpython. Currently, libpython supports python3.5, so you do not need to configure the python3.4 environment. NOTE: If mingw installation is slow, you can run ctl + c and exit the command line. Then, go to the command line to modify the Anaconda image. Here, we recommend the Tsinghua image by entering:
Conda config -- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Conda config -- set show_channel_urls yes
And then conda install mingw libpython.
Then you can see the MinGW folder in the installation directory of Anaconda3,
(Note: You need to add the MinGW path to the environment variable on the Internet. In fact, you don't need to. Just mark the MinGW location in theano's configuration file later)
(6) install theano. First open the command line, enter conda install scipy, and then enter pip install theano. (I do not understand why I need to enter conda install scipy, but it is recommended on the Internet ). Then, create a new file named .theanorc.txt under the personal master folder. The personal master folder is the path of the folder displayed after the command line is opened. For example, my folder is C: \ Users \ 15540:
When theano's configuration file is .theanorc.txt, the file name is .theanorc, and .txt is the file type. Do not make a mistake. Open .theanorc.txt and write the following information:
[Global]
Openmp = False
Device = gpu
Optimizer_including = cudnn
FloatX = float32
Allow_input_downcast = True
[Lib]
Cnmem = 1, 0.8
[Blas]
Ldflags =
[Gcc]
Cxxflags =-ID: \ software \ Anaconda3 \ MinGW
[Nvcc]
Flags =-LD: \ software \ Anaconda3 \ libs
Compiler_bindir = D: \ software \ VS2013 \ VC \ bin
Fastmath = True
Note that you need to replace cxxflags =-ID: \ software \ Anaconda3 \ MinGW with the position of MinGW in your Anaconda3, flags =-LD: \ software \ Anaconda3 \ libs for the libs position in your Anaconda3, compiler_bindir = D: \ software \ VS2013 \ VC \ bin for the VC \ bin position in your VS2013; in addition, cnmem = 0.8 is set to 1 on the Internet, but it seems a bit problematic. It is recommended to set it to a value smaller than 1. For example, set it to 0.8 here, this avoids displaying the CNMEM is disabled.
(7) Update the cudnn file, to the Internet search cudnn download (to the official website registration can be downloaded, the official website for https://developer.nvidia.com/cudnn ). Decompress the downloaded file and decompress the cuda folder, which contains three folders ,. Replace the three folders with the corresponding Files in the system and overwrite them. For example, my file directory is C: \ Program Files \ nvidia gpu Computing Toolkit \ CUDA \ v8.0. When theano is imported after overwriting, the prompt CuDNN not available will not appear.
(8) test theano. Open the command line, input python, and input import theano. If UnicodeDecodeError: 'utf-8 'codec can' t decode byte 0xd5 in position 11: invalid continuation byte occurs, this is because the default cwindows encoding is used to drop the string returned by nvcc. Find the corresponding error file in theano and change the source code error *. decode ("GBK. For example, if my encoding problem occurs in _ init _. py under theano, change it:
(If the above error occurs, close the command line modification error and re-enter the command again.) If the following screen appears, the operation is successful.
(Note: we can see that there is still warning, but does not affect the use, the reason for the emergence of warning is mainly because the cuda-8 of the current version of theano support is not good, however, I believe the updated theano will solve this problem in the future. If you cannot accept this warning, install cuda7.5. The steps are the same)
Iii. Other problems
(1) do not add the PYTHONPATH variable to the environment variable; otherwise, it is easy to see the problem that configparser cannot be found or this component does not exist after import theano (this is my case here );
(2) We recommend that you restart your computer after installing cuda;
(3) If any problem occurs after you enter a command in the command line, we recommend that you restart the command line after modifying the problem;
(4) If there are other problems, try to restart the computer and import theano, if there are still questions, the general configuration file .theanorc.txt (my configuration method is not necessarily suitable for you), the following lists some articles for my reference:
Http://blog.csdn.net/u011821462/article/details/50145221
Http://blog.csdn.net/stormragewang/article/details/51261465
Http://blog.csdn.net/voidfaceless/article/details/53711550