---
title: 运行和验证
description: 1. 使用PuTTY工具，以root用户登录服务器。
url: "https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengmpi4py_02_0009.html"
---

# 运行和验证

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令验证mpi4py。

```
cd
/path/to/mpi4py
```


3. 执行以下命令创建示例。

  a. 新建“test.py”文件。

```
vim test.py
```


  b. 按“i”进入编辑模式，在文件中输入以下内容。

```
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
print ('My rank is ', rank)
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
4. 执行以下命令验证。

```
mpirun --allow-run-as-root -np 4 python3 test.py
```


  回显显示信息如下图所示。
