0% found this document useful (0 votes)
39 views26 pages

05 Experiment Environment Setup Guide

Uploaded by

mosalah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views26 pages

05 Experiment Environment Setup Guide

Uploaded by

mosalah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Lab Environment Setup Guide Page 1

AI

Experiment Environment
Setup Guide

HUAWEI TECHNOLOGIES CO., LTD.


Lab Environment Setup Guide Page 2

About This Document

Description
This document consists of three parts:
⚫ Lab environment setup on Windows.

⚫ Lab environment setup on Ubuntu.

⚫ HUAWEI CLOUD user guide.

Background Knowledge Required


This course is for Huawei's basic certification. To better understand this lab environment
setup guide, familiarize yourself with the following requirements:
⚫ Have basic Python knowledge, understand basic MindSpore concepts, and be familiar
with basic Python programming knowledge.
Lab Environment Setup Guide Page 3

Contents

About This Document .......................................................................................................................... 2


Description ......................................................................................................................................................................................... 2
Background Knowledge Required ............................................................................................................................................. 2
1 Lab Environment Setup on Windows ........................................................................................... 1
1.1 Installing Anaconda ................................................................................................................................................................. 1
1.1.1 Introduction to Anaconda .................................................................................................................................................. 1
1.1.2 Installation Procedure ......................................................................................................................................................... 1
1.2 Introduction to Anaconda Virtual Environments .......................................................................................................... 4
1.2.1 Introduction to Virtual Environments ............................................................................................................................ 4
1.2.2 Creating a Virtual Environment Using Command Prompt .................................................................................... 5
1.2.3 Activating a Virtual Environment .................................................................................................................................... 6
1.2.4 Viewing Virtual Environments .......................................................................................................................................... 6
1.2.5 Deleting a Virtual Environment ....................................................................................................................................... 8
1.3 Installing MindSpore ............................................................................................................................................................... 9
1.3.1 Installing MindSpore 1.7 .................................................................................................................................................... 9
1.3.2 Third-party library installation .......................................................................................................................................13
2 Lab Environment Setup on Ubuntu ............................................................................................ 14
2.1 Installing Anaconda ...............................................................................................................................................................14
2.1.1 Installation Procedure .......................................................................................................................................................14
2.2 Installing MindSpore .............................................................................................................................................................17
2.2.1 Installing MindSpore 1.7 ..................................................................................................................................................17
3 Huawei Cloud Usage Guide .......................................................................................................... 19
3.1 Overview ....................................................................................................................................................................................19
3.2 Huawei Cloud Account Application .................................................................................................................................19
3.2.1 Procedure ...............................................................................................................................................................................19
3.3 Obtaining the Access Key and Secret Access Key .......................................................................................................21
3.3.1 Overview ................................................................................................................................................................................21
3.3.2 Generating the AK and SK ...............................................................................................................................................21
3.4 Entry to Huawei Cloud Services ........................................................................................................................................22
3.4.1 ModelArts ..............................................................................................................................................................................22
HCIA-AI V3.5 Lab Environment Setup Guide Page 1

1 Lab Environment Setup on Windows

1.1 Installing Anaconda


1.1.1 Introduction to Anaconda
Anaconda is a distribution of the Python programming language for scientific computing.It
supports Linux, Mac, and Windows OSs and provides the package and environment
management functions. It can easily cope with coexistence and switchover of multiple
Python versions and installation of various third-party packages. Anaconda contains Python
and related tools, including the conda and pip command line utilities for package and
environment management. 250 packages are installed by default with Anaconda. After
Anaconda installation, you can install additional open source packages using PyPI. As a
Python tool for enterprise-level big data analysis, Anaconda can also be used in the AI field.
Anaconda has the following features to simplify usage:
1. Python is automatically installed with Anaconda.
2. You only need to add virtual environments in Anaconda when different frameworks are
required for development. This allows you to easily configure and manage separate
environments for projects without worrying about compatibility.

1.1.2 Installation Procedure


Step 1 Download Anaconda.
Download the installation package from the Anaconda official website
(https://repo.anaconda.com/archive/). In this example, the installation package for
Windows is used. You are advised to use Anaconda3-2021.11-Windows-x86_64.exe for a
64-bit Windows system. (This guide uses Anaconda as an example. Alternatively, you can
install Miniconda, a lightweight substitute for Anaconda, whose installation procedure is
similar to that of Anaconda. By default, only Python and conda are installed with Miniconda.
You can install desired packages using pip or conda after Miniconda installation.)

Step 2 Install Anaconda.


Double-click the downloaded Anaconda3-xxxx.xx-Windows-x86_64.exe file. In the
displayed dialog box, click Next.
HCIA-AI V3.5 Lab Environment Setup Guide Page 2

Figure 1-1 Anaconda3 installer


Click I Agree.

Figure 1-2 Anaconda3 license agreement


Choose Install for: Just me, and click Next.
HCIA-AI V3.5 Lab Environment Setup Guide Page 3

Figure 1-3 Choosing the user for installation


Step 3 Set the installation folder.
Select a folder for installation and click Next.

Figure 1-4 Choosing the folder for installation


Step 4 Configure environment variables.
Check both of the options. The first is to add the environment variable, and the second is
to use Anaconda as the default Python 3.9 runtime to reduce subsequent configuration
work. Click Install to start the installation. (Note: You are advised to uninstall other Python
versions before installing Anaconda. Otherwise, environment conflicts may occur.)
HCIA-AI V3.5 Lab Environment Setup Guide Page 4

Figure 1-5 Adding Anaconda3 to the environment variable


After the installation is complete, click Finish.

Figure 1-6 Finishing the installation

1.2 Introduction to Anaconda Virtual Environments


1.2.1 Introduction to Virtual Environments
The virtual environment feature is the reason for the popularity of Anaconda. Different
virtual environments on a machine are independent and isolated from each other. Virtual
environments are useful when development involves complex Python module
dependencies or different frameworks.
HCIA-AI V3.5 Lab Environment Setup Guide Page 5

Note: Modules must be installed in different virtual environments separately. For example,
you must install MindSpore in environment B if you want to use it in the environment, even
though you have installed MindSpore in environment A. This also applies to other modules
like Spyder and Jupyter Notebook.

1.2.2 Creating a Virtual Environment Using Command Prompt

Step 1 Type cmd in the search box on the taskbar and open Command Prompt.

Figure 1-7 Opening Command Prompt


Step 2 Run the conda create -n environment_name python==x.x command. You can customize
the environment name and Python version.

Figure 1-8 Creating virtual environment MS17


Step 3 Enter y when prompted.
Wait until the installation is complete.
HCIA-AI V3.5 Lab Environment Setup Guide Page 6

Figure 1-9 Virtual environment MS17 created

1.2.3 Activating a Virtual Environment


Run the activate environment_name command to activate the virtual environment. If the name
in the brackets before the command prompt is changed, you have activated and entered
the virtual environment.

Figure 1-10 Activating virtual environment MS17


You can then run pip or conda to install desired modules.

1.2.4 Viewing Virtual Environments


You can view created virtual environments in Anaconda Navigator.
HCIA-AI V3.5 Lab Environment Setup Guide Page 7

Figure 1-11 Viewing created virtual environments in Anaconda Navigator


You can click the triangle on the right of the environment name to enter the virtual
environment through Command Prompt.
HCIA-AI V3.5 Lab Environment Setup Guide Page 8

Figure 1-12 Opening the terminal of a virtual environment


This allows you to directly enter the virtual environment to install desired modules.

1.2.5 Deleting a Virtual Environment


Run the conda remove -n environment_name --all command and enter y to delete the
environment. For example:
HCIA-AI V3.5 Lab Environment Setup Guide Page 9

Figure 1-13 Deleting a virtual environment

1.3 Installing MindSpore


MindSpore is a Huawei-developed AI computing framework that implements on-demand
device-edge-cloud synergy in all scenarios. It provides unified APIs and end-to-end
capabilities for AI model development, running, and deployment in all scenarios.
MindSpore uses the distributed architecture across device-edge-cloud for on-demand
collaboration, new paradigm of differential native programming, and new AI Native
execution mode to achieve high resource efficiency, security, and trustworthiness, lower
the AI development threshold, and unleash the computing power of Ascend processors.

1.3.1 Installing MindSpore 1.7


Step 1 Create a virtual environment. (Skip this step if you have completed the operations
in section 1.2 of this guide.)

Virtual environments ensure that different environments do not conflict with each other.
The relationship between virtual environments is similar to that between VMs. Run the
conda create -n MS17 python=3.7 command to create a virtual environment. You can customize
the environment name (text in red). python=3.7 indicates the Python version used in the
HCIA-AI V3.5 Lab Environment Setup Guide Page 10

created virtual environment. If the minor version is not specified, the latest minor version
of the specified major version is installed. For example, to use Python of minor version 7
and patch version 10, enter python=3.7.10.
Enter y when prompted during installation.
HCIA-AI V3.5 Lab Environment Setup Guide Page 11

Figure 1-14 Creating virtual environment MS17

Figure 1-15 Activating the virtual environment.


Step 2 Activate the virtual environment. (Skip this step if you have completed the
operations in section 1.2 of this guide.)

After the installation is complete, run the conda create -n MS17 python=3.7 command to
activate the virtual environment. Text in red is the name of the virtual environment created
in Step 1. After the activation, the name of the virtual environment will be displayed before
the command prompt.

Step 3 Install MindSpore 1.7.


After activating the virtual environment, run the following command:

pip install https://ms-release.obs.cn-north-


4.myhuaweicloud.com/1.7.1/MindSpore/cpu/x86_64/mindspore-1.7.1-cp37-cp37m-win_amd64.whl --
trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com

If Successfully is contained in the output, the installation is successful.


HCIA-AI V3.5 Lab Environment Setup Guide Page 12

Figure 1-16 Successful installation of MindSpore using pip


Step 4 Verify the installation.
After completing the previous step, run the following command to check whether
MindSpore is successfully installed:

python -c "import mindspore;mindspore.run_check()"

If the following information is displayed, MindSpore is successfully installed:

MindSpore version: version_number


The result of multiplication calculation is correct, MindSpore has been installed successfully!
HCIA-AI V3.5 Lab Environment Setup Guide Page 13

1.3.2 Third-party library installation


pip install missingno
pip install scikit-learn
pip install imblearn
pip install seaborn
pip install nltk
pip install wordcloud
pip install xgboost
HCIA-AI V3.5 Lab Environment Setup Guide Page 14

2 Lab Environment Setup on Ubuntu

2.1 Installing Anaconda


2.1.1 Installation Procedure
Step 1 Download Anaconda.
Download the installation package from the Anaconda official website
(https://repo.anaconda.com/archive/). In this example, the installation package for Linux is
used. You are advised to use Anaconda3-2021.11-Linux-x86_64.sh for a 64-bit Linux system.
(This guide uses Anaconda as an example. Alternatively, you can install Miniconda, a
lightweight substitute for Anaconda, whose installation procedure is similar to that of
Anaconda. By default, only Python and conda are installed with Miniconda. You can install
desired packages using pip or conda after Miniconda installation.)

Step 2 Install Anaconda.


Find the downloaded Anaconda3-xxxx.xx-Linux-x86_64.sh file, right-click the file, choose
Properties from the shortcut menu.
HCIA-AI V3.5 Lab Environment Setup Guide Page 15

Figure 2-1 Choosing Properties


Click the Permissions tab and check Allow executing file as program.

Figure 2-2 Allow executing file as program


Right-click the blank area in the folder where the file is located and choose Open in
Terminal.

Figure 2-3 Opening a terminal in the current directory


Run the following command in the terminal to start the installation:

./Anaconda3-2021.11-Linux-x86_64.sh
HCIA-AI V3.5 Lab Environment Setup Guide Page 16

During the installation, press Enter to read the installation terms, and manually enter yes
to agree to the installation terms. The default value is no. After accepting the terms,
confirm the Anaconda3 installation path by specifying an installation path or pressing Enter
to use the default path, which is the user's home directory.

Figure 2-4 Anaconda3 installation path


After the installation is complete, enter yes to initialize Anaconda3.

Figure 2-5 Initializing Anaconda3


After the preceding operations are complete, Anaconda3 is successfully installed. Exit the
current terminal and open a new terminal to for the environment variables to take effect.
HCIA-AI V3.5 Lab Environment Setup Guide Page 17

Figure 2-6 Finishing Anaconda3 installation

2.2 Installing MindSpore


MindSpore is a Huawei-developed AI computing framework that implements on-demand
device-edge-cloud synergy in all scenarios. It provides unified APIs and end-to-end
capabilities for AI model development, running, and deployment in all scenarios.
MindSpore uses the distributed architecture across device-edge-cloud for on-demand
collaboration, new paradigm of differential native programming, and new AI Native
execution mode to achieve high resource efficiency, security, and trustworthiness, lower
the AI development threshold, and unleash the computing power of Ascend processors.

2.2.1 Installing MindSpore 1.7


Step 1 Create a virtual environment.
See Step 1 in section 1.3.1 of this guide.

Step 2 Activate the virtual environment.


See Step 2 in section 1.3.1 of this guide.

Step 3 Install MindSpore 1.7.


After activating the virtual environment, run the following command:

pip install https://ms-release.obs.cn-north-


4.myhuaweicloud.com/1.7.1/MindSpore/cpu/x86_64/mindspore-1.7.1-cp37-cp37m-linux_x86_64.whl --
trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com

If Successfully is contained in the output, the installation is successful.


HCIA-AI V3.5 Lab Environment Setup Guide Page 18

Figure 2-7 Successful installation of MindSpore using pip


Step 4 Verify the installation.
After completing the previous step, run the following command to check whether
MindSpore is successfully installed:

python -c "import mindspore;mindspore.run_check()"

If the following information is displayed, MindSpore is successfully installed:

MindSpore version: version_number


The result of multiplication calculation is correct, MindSpore has been installed successfully!

Figure 2-8 Verifying MindSpore Installation


HCIA-AI V3.5 Lab Environment Setup Guide Page 19

3 Huawei Cloud Usage Guide

3.1 Overview
Huawei Cloud provides abundant cloud resources and cloud services to meet your
requirements. This document describes how to apply for resources on Huawei Cloud,
including account application and obtaining AK and SK, and introduces Huawei Cloud
services.
Upon studying this document, you will be able to:
⚫ Understand AI development environments.
⚫ Apply for an AI development environment.
⚫ Test an established environment.

3.2 Huawei Cloud Account Application


⚫ This is a prerequisite for enabling services on Huawei Cloud to ensure subsequent
operations.
⚫ This is a prerequisite for using cloud services, including deep learning, machine
learning, image recognition, speech recognition, and natural language processing.

3.2.1 Procedure
Step 1 Register for Huawei Cloud.

Go to the Huawei Cloud official website at http://www.huaweicloud.com/intl/en-us/ and


click Register in the upper right corner.
HCIA-AI V3.5 Lab Environment Setup Guide Page 20

Figure 3-1 Register HUAWEI ID


Enter information as prompted and click Register. Then, read and agree to the HUAWEI
CLOUD Customer Agreement and Privacy Statement.

Figure 3-2 Enable HUAWEI CLOUD Services


Step 2 Complete your information.
HCIA-AI V3.5 Lab Environment Setup Guide Page 21

Complete your information as shown in the following image.

Figure 3-3 Complete Information

3.3 Obtaining the Access Key and Secret Access Key


3.3.1 Overview
The AK and SK are access tokens that are required to use Huawei Cloud services. When
you use some Huawei Cloud services for the first time, you must enter the AK and SK.

3.3.2 Generating the AK and SK


Step 1 Click My Credentials.

Log in to the Huawei Cloud console, hover over the account name and click My Credentials.

Figure 3-4 My Credentials


Step 2 Add an access key.

On the My Credentials page, click Access Keys on the left. Then, click Create Access Key to
create an access key. Each access key can be downloaded only once.
HCIA-AI V3.5 Lab Environment Setup Guide Page 22

Figure 3-5 Create Access Key


After an access key is added, a table file storing the access key is automatically downloaded.
Keep it secure.
If AK/SK authentication is no longer required, you can disable or delete the access key you
created.

3.4 Entry to Huawei Cloud Services


3.4.1 ModelArts
ModelArts is a one-stop AI development platform. It provides data preprocessing, semi-
automated data labeling, large-scale distributed training, automated model generation,
and model deployment on devices, edge devices, and the cloud. It helps you develop and
deploy models quickly and manage the AI development lifecycle for machine learning and
deep learning.

Figure 3-6 ModelArts entry


After logging in to ModelArts, you can choose DevEnviron > Notebook on the left to create
an Ascend 910- or GPU-based development environment.
HCIA-AI V3.5 Lab Environment Setup Guide Page 23

Figure 3-7 Creating a development environment

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy