I went through many pitfalls when setting up a Windows environment. Here I record the process and some solutions I tried to solve the problems.
If possible, it is best to install an Ubuntu system on the machine to run it.
1. Environment
(It does not necessarily follow my version of installation, it just provides an idea. Other versions also have successful installation cases, so you can explore on your own)
My installation environment:
Windows 11
RTX1650(Notebook)
miniconda3 creates Python2.7 environment
Visual Studio Ultimate 2013
nvidia-dirver-535
CUDA 8.0.61
cuDNN v5.1
CMAKE 3.10.3
The following are the environmental requirements in Caffe’s Readme.md
2. Installation steps (must be done in order!!!)
Before installing Caffe, please make sure that the above items have been installed and configured. If it is a GPU version, you need CUDA and cuDNN, as well as nvidia’s graphics card driver. It is best to install CUDA version 8.0 and the corresponding cuDNN version 5.x, here There are corresponding managements for both. The CMAKE version should not be too low. You can read the documentation provided by the Caffe official website, which explains the configuration.
You can also download the Berkeley version of Caffe here (there are also Intel and Microsoft versions, I use the official BVLC version, please see this blog introduction for details)
2.1 miniconda3
2.1.1 Install miniconda
Download the Windows version that suits you from the official website of miniconda3.
Double-click the downloaded installer and follow the on-screen instructions to complete the installation. During the installation process, you can select the installation path and other options.
After the installation is complete, open a command prompt or Anaconda prompt and enter the following command to verify whether miniconda3 is successfully installed:
(Remember to add environment variables)
conda -V
If the installation is successful, the corresponding version number will pop up.
2.1.2 python environment creation
Win + R and enter cmd to open the terminal
conda creates a Python 2.7 environment
conda create -n [environment_name] python=2.7
activate environment
conda activate [environment]
If you quit
conda deactivate
Before exiting, we first install some necessary packages (some external network downloads will be a bit slow, remember to change the pip source)
pip install numpy matplotlib scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
2.2 Visual Studio Ultimate 13
Microsoft official download
Just follow the official download and install it step by step. Search the Internet for the serial code and go to “HELP”->”Register Product” to authenticate it.
2.3 NVIDIA DRIVER
Go to NVIDIA official download driver
Select the corresponding parameters and click Search
(The Download Type column is default)
Choose a version that suits your graphics card and install it (try not to install the latest one)
Choose to install the graphics driver, do not install the graphics driver!
2.4 CUDA
Download address (you can open a proxy to download, which is much faster)
1. If the Windows system version is win11, choose win10.
2. Select Local for Installer Type and install it locally.
It has been installed by default since then.
//After the installation is complete, remember to add the system Path environment variable //According to your own installation directory, add ../include and ../lib paths // Below is my path C:\Program Files\\ VIDIA GPU Computing Toolkit\CUDA\v8.0\include C:\Program Files\\ VIDIA GPU Computing Toolkit\CUDA\v8.0\lib
You will find two more lines in the system environment variables
The other four lines need to be added by ourselves
// Place it here for ease of copying //The path of CUDA_SDK_PATH is based on your own location. I default to ProgramData on drive C. CUDA_LIB_PATH_V8 = %CUDA_PATH%\lib\x64 CUDA_SDK_PATH = C:\ProgramData\\ VIDIA Corporation\CUDA Samples\v8.0 CUDA_SDK_BIN_PATH = %CUDA_SDK_PATH%\bin\win64 CUDA_SDK_LIB_PATH = %CUDA_SDK_PATH%\common\lib\x64
2.5 cuDNN
cuDNN needs to match and correspond to CUDA. CUDA is a tool library (GPU Computing toolkit) built on the graphics card driver, and cuDNN is a deep learning-related tool library built on CUDA. Therefore, cuDNN must be installed to run the deep learning framework Caffe.
Click here, you can see the corresponding relationship between cuDNN and CUDA. Here we choose the v5 version
Download address (it’s faster to open an agent. In addition, you need to register an account to download. If you have one, just log in. It’s at the bottom of the page)
After the download is completed, decompress and copy the decompressed files to the corresponding folders in CUDA.
Different versions may correspond to different files, but just copy them to the corresponding folder.
2.6 CMAKE
According to the documentation, this version should be >=3.4, but if the version is too low, there will be some problems in running it, so I don’t dare to choose a version that is too new. Finally I chose version 3.10.3
download link
After downloading, unzip it to a fixed location and add it to the system Path environment variable.
Check it and enter in cmd terminal
cmake --version
Outputting the version number means the installation is successful.
3. Install Caffe
There are many problems in this part, which need to be solved patiently and be patient.
3.1 Download
If you have git, you can download the project file through git
git clone https://github.com/BVLC/caffe.git
Or go to GitHub to download the Zip file
Enter the project file ../caffe-windows/scripts
directory and modify the build_win.cmd file
3.2 Configuration compilation file
Mainly modify the contents of lines 7-31 and 70-99
Lines 7-31
For the other 70-99 lines, just modify the content in IF
Note: There is a parameter CUDA_ARCH_NAME = Auto in IF here. You can select the corresponding parameters according to the table below. For details, see this link
If you are not sure, just default to Auto and leave it alone.
Now that all the preliminary preparations are done, the next step is compilation (the part that causes the most problems)
3.3 Compilation
Before starting compilation, first check whether the CMakeFiles folder and CMakeCache.txt file exist in the ../caffe-windows/scripts/build
directory. >, if they exist, delete these two files before proceeding to the next step (they must be deleted every time you recompile!!!)
Win + R and enter cmd to open the terminal, cd into the ../caffe-windows/scripts
path and enter
build_win.cmd
The process was very slow during this period. If you need to download things from the external network, you can turn on the proxy. I downloaded it for more than half an hour and compiled it. The screen was full of yellow, and it was successful.
Then copy the caffe folder under the project path ../caffe-windows/python
to the python installation path or under the python environment path created by conda. ./lib/site-packages
Under
Then find Caffe.sln in ../caffe-windows/scripts/build
and open it with vs 2013, switch to release, generate the solution, and wait for the compilation to complete.
... ... ... ... ========= Regenerate all: n successes, 0 failures, 0 skips =========
Then add the ../caffe-windows/scripts/build/tools/Release
path to the system Path environment variable. If it is compiled in Debug mode, add the Debug file path under the tools path to the system Path environment variable.
Open cmd and enter
caffe.exe --version
Get the version information, indicating that caffe has been installed successfully.
4. Problems encountered
When MSB6006 cmd.exe exit code: 1
appears, you can try changing CUDA_ARCH_NAME=Auto to CUDA_ARCH_NAME=Kepler
For many problems, you can check these articles to find solutions.
https://blog.csdn.net/qq_35756383/article/details/102491852
https://blog.csdn.net/pp2373886592/article/details/123816636
https://blog.csdn.net/qq_37618450/article/details/115719956
https://www.cnblogs.com/david97/p/8949713.html