WIN10+WSL安装AiiDA及其插件AiiDA-VASP

本文最后更新于:2 个月前

1. AiiDA简介

AiiDA是一款计算科学的工作流管理器软件,有很好的性能和扩展性。AiiDA可以让我们方便地构建高通量计算流程、管理我们的计算数据,提高高通量计算筛选的效率。

AiiDA架构图

2. AiiDA的安装

2.1 安装环境配置

AiiDA需要在Linux环境下安装,所以可以直接在服务器上安装,支持 Python 2Python 3
  这里我们将AiiDA安装在本地电脑,方便管理自己的数据。WIN10之前的电脑,要安装AiiDA,需要先安装Linux虚拟机;WIN10之后,系统有自带的Linux子系统(Windows Subsystem for Linux,WSL),比虚拟机更加简单方便,跟MAC中的终端一样方便使用。

2.2 安装 Python 3

Python环境我们选择 Python 3。虽然,AiiDA同时支持 Python 2Python 3;但是,后续我们需要安装插件 AiiDA-VASP,而 AiiDA-VASP 只支持 Python 3

1
sudo apt install python3 python3-dev python3-pip

2.3 安装 RabbitMQ

1
2
3
4
# 安装 RabbitMQ
sudo apt install rabbitmq-server
# 启动 RabbitMQ
sudo service rabbitmq-server start

2.4 安装 PostgreSQL

1
2
3
4
# 安装 PostgreSQL
sudo apt install git postgresql postgresql-server-dev-all postgresql-client
# 启动 PostgreSQL
sudo service postgresql start

2.5 安装 AiiDA

1
2
python3 -m pip install aiida-core
reentry scan

* 2.6 更新Python库 sqlalchemy-utils

(这是个大坑,写这篇文章这个占主要原因~)

1
python3 -m pip install sqlalchemy-utils -U

若不更新,后续配置步骤可能会报错,错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Traceback (most recent call last):
File "/home/cheng/.local/bin/verdi", line 8, in <module>
sys.exit(verdi())
File "/home/cheng/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/cheng/.local/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/cheng/.local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/cheng/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/cheng/.local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/cheng/.local/lib/python3.6/site-packages/aiida/cmdline/commands/cmd_setup.py", line 51, in setup
from aiida import orm
File "/home/cheng/.local/lib/python3.6/site-packages/aiida/orm/__init__.py", line 15, in <module>
from .computers import *
File "/home/cheng/.local/lib/python3.6/site-packages/aiida/orm/computers.py", line 18, in <module>
from aiida.orm.implementation import Backend
File "/home/cheng/.local/lib/python3.6/site-packages/aiida/orm/implementation/__init__.py", line 19, in <module>
from .querybuilder import *
File "/home/cheng/.local/lib/python3.6/site-packages/aiida/orm/implementation/querybuilder.py", line 22, in <module>
from sqlalchemy_utils.types.choice import Choice
File "/home/cheng/.local/lib/python3.6/site-packages/sqlalchemy_utils/__init__.py", line 1, in <module>
from .aggregates import aggregated # noqa
File "/home/cheng/.local/lib/python3.6/site-packages/sqlalchemy_utils/aggregates.py", line 372, in <module>
from .functions.orm import get_column_key
File "/home/cheng/.local/lib/python3.6/site-packages/sqlalchemy_utils/functions/__init__.py", line 1, in <module>
from .database import ( # noqa
File "/home/cheng/.local/lib/python3.6/site-packages/sqlalchemy_utils/functions/database.py", line 13, in <module>
from ..expressions import explain_analyze
File "/home/cheng/.local/lib/python3.6/site-packages/sqlalchemy_utils/expressions.py", line 4, in <module>
from sqlalchemy.sql.expression import (
ImportError: cannot import name '_literal_as_text'

3. AiiDA 初始配置

3.1 为 AiiDA 创建数据库

(1)切换 postgres 用户

1
sudo su - postgres

(2)打开 PostgreSQL 数据库

1
psql

(3)创建数据库用户

1
CREATE USER aiida WITH PASSWORD '<password>';
  • <password> 替换为你要设置的密码。
  • 最后的分号 ; 不能缺少。
  • 修改密码数据库用户密码:
1
ALTER USER aiida PASSWORD '<password>';

(4)创建数据库

1
CREATE DATABASE aiidadb OWNER aiida ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;

(5)将创建的数据库所有权限赋予用户aiida

1
GRANT ALL PRIVILEGES ON DATABASE aiidadb to aiida;

3.2 初始化 AiiDA

执行以下命令

1
verdi setup

然后按要求填写信息即可,例如我填写的(选项中有方括号 [] 的,可以直接敲回车,表示默认使用方括号 [] 中的内容):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Profile name: aiida
Email Address (for sharing data): cheng7258002@live.com
First name: G.J.
Last name: Cheng
Institution: aiida
Database engine (postgresql_psycopg2) [postgresql_psycopg2]:
Database backend (django, sqlalchemy) [django]:
Database host: localhost
Database port [5432]:
Database name: aiidadb
Database username: aiida
Database password:
Broker protocol (amqp, amqps) [amqp]:
Broker username [guest]:
Broker password [guest]:
Broker host [127.0.0.1]:
Broker port [5672]:
Broker virtual host name []:
Repository directory [/home/cheng/.aiida/repository/aiida]:

4. 安装 AiiDA-VASP

1
python3 -m pip install aiida-vasp

至此,AiiDA及其插件AiiDA-VASP就安装完成了!