Home>Article>Backend Development> Graphical introduction to the steps to install theano and configure GPU in Win10 environment
one. Software and environment
(1)Installation date2016/12/23;
(2)raw materialsVS2013,cuda-8.0(It is best to downloadcuda7.5, currentlytheano-0.8.2The support forcuda-8is not very good),Anaconda3-4.2.0(64bit);
(3)The environment iswin10.
II. Installation steps
(1)InstallVS2013. There is nothing to say about this. After downloading the64version, just take the next step and confirm. Just remember the installation location. My installation directory here isD:\software\VS2013:
##Then right click on me Computer-》Properties-》Advanced System Settings-》EnvironmentVariables, then editsystem variablesPathand add two pathsD:\software\VS2013\VC\binandD:\software\VS2013\Common7\IDE, separated by semicolons, as shown in the figure:
Click OK. (2)Installcuda. There is nothing to say about this. Go to the official website and downloadcuda, and then go to the next step+to confirm. Please note that if you install During the processwin10is prompted to prevent an operation. You must choose to allow this operation or allow all operations of the program, otherwisecudawill installation failed.CudaThe official website address is
http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/ #axzz46v2MC6l8,
The download address ishttps://developer.nvidia.com/cuda-downloads,
Pictured:(Note: This is thecuda-8version. The support for the current version oftheanois not very good, but it does not affect the use. Best It’s better to downloadcuda7.5. I’m too lazy to reinstall it, so I just usecuda-8)
Also be sure to remember the installation path ofcuda. My path isC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0, as shown in the picture:
(3)Right-click My Computer-》Properties-》Advanced system settings-》Environment variables, you can see that two variables have been added to the system variablesCUDA_PATHandCUDA_PATH_V8_0, as shown in the figure:
Then edit the system variablePathand add two paths%CUDA_PATH%\lib\x64and%CUDA_PATH%\bin, separated by semicolons, as shown in the figure:
Click OK.
Open the command line and enternvcc -V. If the following picture appears, the installation is successful:
And go to the directoryC:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQueryUseVS2013to open and run the test sampledeviceQuery_vs2013.vcxprojfile, as shown in the figure: (NoteC: \ProgramDatais a hidden folder, you need to clickCDisk-》View-》Options-》View, select Show hidden files, folders and drives, click OK (as shown in the figure)
The picture shows the viewing options of theC:\ProgramDatafolder
The position of j
The picture shows the running result in
VS2013
The last line ofResult = Passmeans the installation and configuration is successful.
(4)Installation
Anaconda3-4.2.0, this is very simple, just confirm all the way Just remember the installation location. For example, I installed it in
D:\software\Anaconda3, as shown in the picture:
Then right-click My Computer-》Properties
-》Advanced System Settings-》Environment variables, addPATHto the user variables, and add the pathD:\software\Anaconda3,D:\software\Anaconda3\ScriptsandD:\software\Anaconda3\Library\bin, click OK. As shown in the picture:
then enter the command line and enter
python
, if If the message shown in the figure appears, the installation is successful:Close the command line.
(5)Installmingwandlibpython. Open the command line and enterconda install mingw libpython. Currentlylibpythonalready supportspython3.5, there is no need to configure thepython3.4environment. Note that if the installationmingwis very slow, you canctl+cand exit the command line, and then enter the command line to modifyAnacondamirror, Tsinghua mirror is recommended here, enter in the command line:
conda config --add channelshttps://mirrors. tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
, thenconda install mingw libpythonis enough.
After that, go to the installation directory ofAnaconda3and you can see the folder ofMinGW, as shown in the figure:
(Note: It is said online that you need to add the path ofMinGWto the environment variable. In fact, you don’t need to. We will do it laterJust mark the location ofMinGWin theconfiguration fileoftheano)
(6)Installtheano. First open the command line, enterconda install scipy, and then enterpip install theano. (I don’t understand why you need to enterconda install scipy, but there are suggestions online). Then create a new document ".theanorc.txt" under your personal home folder. The personal home folder is the folder path displayed after opening the command line. For example, mine isC:\Users\15540:
Note that the configuration file oftheanois.theanorc.txt, pay attention to the previous point Yes, and the file name is.theanorc,.txtis the file type, don’t make a mistake. Open.theanorc.txtand write the following information:
[global]
openmp=False
device = gpu
optimizer_including=cudnn
floatX = float32
allow_input_downcast=True
[lib]
cnmem = 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 thatcxxflags=-ID:\software\Anaconda3 \MinGWis replaced by the position ofMinGWin yourAnaconda3,flags = -LD: \software\Anaconda3\libsReplace the location oflibsin yourAnaconda3,compiler_bindir = D:\software\VS2013\VC\binReplace with yourVS2013中VC\binThe position of; andcnmem = 0.8is said online to be set to1, but there seems to be a problem. It is recommended to set it to A value less than1, for example, I set it to0.8, which can avoid the subsequent display ofCNMEM is disabled.
(7)Update thecudnnfile, search the Internet forcudnnand download it ( You can download it after registering on the official website. The official website address ishttps://developer.nvidia.com/cudnn). Unzip the downloaded file and extract thecudafolder, which contains3folders, as shown in the figure. Replace the corresponding files in the system with the three folders and overwrite them. For example, my file directory isC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0. When overwriting the later importtheano, theCuDNN not availableprompt will not appear.
(8)Testtheano. Open the command line, enterpython, then enterimport theano, ifUnicodeDecodeError: 'utf-8 appears ' codec can't decode byte 0xd5 inposition11: invalid continuation byteThis encoding problem is due to misuse ofnvccThe returnedstringis the default encoding used bycwindows. Directly find the corresponding error report intheanofile, just change the source code error to*.decode("GBK"). For example, my encoding problem occurred ininit.pyundertheano, then modify it to:
(If the above error occurs, close the command line to correct the error and re-enter the command) The following screen appears, indicating success.
(Note: You can see that there are stillwarning, but it does not affect the use.warningappears The main reason foris thatcuda-8does not support the current version oftheanovery well, but I believe it will be updated in the future.theanowill solve this problem. If you really can’t accept thiswarning, just installcuda7.5, the steps are the same)
3. Other questions
(1)Do not add thePYTHONPATHvariable to the environment variable, otherwise it will be easy toimport After theano, the problem ofconfigparsercannot be found or does not exist (this is the case in my case);
(2)It is recommended to restart the computer after installingcuda;
(3) If any problem occurs after entering the command on the command line, it is recommended to restart the command line after correcting the problem;
(4) If there are other problems, Try restarting the computer and going toimport theano. If there are still problems, it is usually a problem with the configuration file.theanorc.txt(I This configuration method may not be 100% suitable for you), here are some of my references
The above is the detailed content of Graphical introduction to the steps to install theano and configure GPU in Win10 environment. For more information, please follow other related articles on the PHP Chinese website!