Installing MindSpore in CPU by Source Code-Windows
This document describes how to quickly install MindSpore by source code in a Windows system with a CPU environment.
For the detailed steps, see the third-party dependency software installation section in the Installing MindSpore Using Source Code Build on Windows (CPU) provided by the community. Thanks to the community member lvmingfu for sharing.
System Environment Information Confirmation
- Ensure that Windows 10 is installed with the x86 architecture 64-bit operating system.
- Ensure that Visual C++ Redistributable for Visual Studio 2015 is installed.
- Ensure that git tool is installed.
- If git was not installed in
ProgramFiles
, you will need to set environment variable to where patch.exe
is allocated. For example, when git was install in D:\git
, set MS_PATCH_PATH=D:\git\usr\bin
needs to be set.
- Ensure that MinGW-W64 GCC-7.3.0 is installed.
- Ensure that path of source code does not include special characters (Chinese, Janpanese characters etc.). After installing, add the path
MinGW\bin
to the environment variable PATH.For example, the installation directory is in D:\gcc
, then you will need to add D:\gcc\MinGW\bin
to the system environment variable PATH.
- Ensure that CMake 3.18.3 is installed.
- Ensure that path of source code does not include special characters (Chinese, Janpanese characters etc.). After installing, add the path of
cmake.exe
to the environment variable PATH.
- Ensure that ActivePerl 5.28.1.2801 or later is installed.
- Ensure that you have Python versions between 3.7 to 3.9 installed. If not installed, follow the links to Python official website or Huawei Cloud to download and install Python.
- Ensure that path of source code does not include special characters (Chinese, Janpanese characters etc.). After installing, add the path of
python.exe
to the environment variable Path. The Scripts
folder in the same directory of python.exe
is the pip file that comes with Python, and you also need to add the path of the pip file to the environment variable Path.
Note: Python 3.7.5 is the oldest version that supports compiling MindSpore for Windows from source code.
Downloading Source Code from Code Repository
git clone https://gitee.com/mindspore/mindspore.git -b r1.8
Compiling MindSpore
Run the following command in the root directory of the source code to compile MindSpore:
call build.bat
Installing MindSpore
for %x in (output\mindspore*.whl) do pip install %x -i https://pypi.tuna.tsinghua.edu.cn/simple
When the network is connected, dependency items are automatically downloaded during .whl package installation. (For details about the dependency, see required_package in setup.py .) In other cases, you need to install it by yourself. When running models, you need to install additional dependencies based on requirements.txt specified for different models in ModelZoo. For details about common dependencies, see requirements.txt.
Installation Verification
cd ..
python -c "import mindspore;mindspore.run_check()"
Importing MindSpore installed by pip should be done outside MindSpore source code base directory, as Python for Windows processes environment paths differently.
The outputs should be the same as:
MindSpore version: __version__
The result of multiplication calculation is correct, MindSpore has been installed successfully!
It means MindSpore has been installed successfully.
Version Update
Use the following command if you need to update the MindSpore version:
-
Update online directly
pip install --upgrade mindspore
-
Update after source code compilation
After successfully executing the compile script build.bat
in the source code of the root directory, find the .whl package generated by compilation in directory output
, and use the following command to update your version.
pip install --upgrade mindspore-{version}-{python_version}-win_amd64.whl