This document describes how to quickly install MindSpore by source code in a Linux system with a GPU environment.
Confirm that Ubuntu 18.04 is installed with 64-bit operating system.
Confirm that GCC 7.3.0 is installed.
Confirm that gmp 6.1.2 is installed.
Confirm that Python 3.7.5 is installed.
Confirm that CMake 3.18.3 or later is installed.
cmake
to the environment variable PATH.Confirm that patch 2.5 or later is installed.
patch
to the environment variable PATH.Confirm that Autoconf 2.69 or later is installed. (Default versions of these tools built in their systems are supported.)
Confirm that Libtool 2.4.6-29.fc30 or later is installed. (Default versions of these tools built in their systems are supported.)
Confirm that Automake 1.15.1 or later is installed.(Default versions of these tools built in their systems are supported.)
Confirm that cuDNN 7.6 or later is installed.
Confirm that Flex 2.5.35 or later is installed.
Confirm that wheel 0.32.0 or later is installed.
Confirm that OpenSSL 1.1.1 or later is installed.
export OPENSSL_ROOT_DIR="OpenSSL installation directory"
.Confirm that CUDA 10.1 is installed as default configuration.
PATH
(e.g. export PATH=/usr/local/cuda-${version}/bin:$PATH
) and LD_LIBRARY_PATH
(e.g. export LD_LIBRARY_PATH=/usr/local/cuda-${version}/lib64:$LD_LIBRARY_PATH
) need to be set. Please refer to CUDA installation guide for detailed post installation actions.Confirm that OpenMPI 3.1.5 is installed. (optional, required for single-node/multi-GPU and multi-node/multi-GPU training)
Confirm that NCCL 2.7.6-1 is installed. (optional, required for single-node/multi-GPU and multi-node/multi-GPU training)
Confirm that the git tool is installed.
If not, use the following command to install it:
apt-get install git
git clone https://gitee.com/mindspore/mindspore.git -b r1.0
Run the following command in the root directory of the source code to compile MindSpore:
bash build.sh -e gpu
Of which,
build.sh
script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, bash build.sh -e ascend -j4
.chmod +x build/package/mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl
pip install build/package/mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
Of which,
{version}
denotes the version of MindSpore. For example, when you are downloading MindSpore 1.0.1, {version}
should be 1.0.1.{arch}
denotes the system architecture. For example, the Linux system you are using is x86 architecture 64-bit, {arch}
should be x86_64
. If the system is ARM architecture 64-bit, then it should be aarch64
.import numpy as np
from mindspore import Tensor
import mindspore.ops as ops
import mindspore.context as context
context.set_context(device_target="GPU")
x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(ops.tensor_add(x, y))
[[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],
[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],
[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]]]
It means MindSpore has been installed successfully.
Using the following command if you need update MindSpore version.
Update online
pip install --upgrade mindspore-gpu
Update after source code compilation
After successfully executing the compile script build.sh
in the root path of the source code, find the whl
package in path build/package
, use the following command to update your version.
pip install --upgrade mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl
If you need to analyze information such as model scalars, graphs, computation graphs and model traceback, you can install MindInsight.
For more details, please refer to MindInsight.
If you need to conduct AI model security research or enhance the security of the model in you applications, you can install MindArmour.
For more details, please refer to MindArmour.
If you need to access and experience MindSpore pre-trained models quickly, you can install MindSpore Hub.
For more details, please refer to MindSpore Hub.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。