目录

机器学习

misaraty 更新 | 2024-11-18
前言
收录些与机器学习相关的数据库、结构搭建、结构搜索、描述符、计算框架、图神经网络、可视化等。

数据库

1
pip install jarvis-tools
1
pip install ase
1
pip install pymatgen

./2024-11-15_094045.jpg

结构搜索

描述符

1
pip install matminer
1
pip install dscribe

神经网络

1
pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html # <= Python3.9`

安装GPU驱动

1
2
3
4
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp
  • 测试
1
2
3
cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\extras\demo_suite
deviceQuery.exe
bandwidthTest.exe

查看是否有Result = PASS输出。

GPU监控

  • nvidia-smi
1
nvidia-smi
  • gpustat
1
2
pip install gpustat
gpustat

安装TensorFlow、PyTorch、Keras

  • PyTorch
1
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
  • TensorFlow
1
2
3
4
pip install tensorflow[and-cuda] # Linux
pip install tensorflow # Windows
# or
pip install tensorflow-gpu==2.10.1 # Windows Python <= 3.10, Anaconda3-2023.03-1*

测试TensorFlow、PyTorch、Keras

 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
35
36
37
38
39
40
# -*-coding:utf-8 -*-

import os
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
import tensorflow as tf
import torch
import jax
from jax.lib import xla_bridge
import keras
import warnings
warnings.filterwarnings("ignore")
os.chdir(os.path.split(os.path.realpath(__file__))[0])
print('copyright by misaraty (misaraty@163.com)\n' + 'last update: 2024-04-23\n')

print("------------")
# TensorFlow GPU test
print("TensorFlow:")
print("TensorFlow version:", tf.__version__)
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
print("------------")

# PyTorch GPU test
print("PyTorch:")
print("PyTorch version:", torch.__version__)
print("Is CUDA available: ", torch.cuda.is_available())
print("Num GPUs Available:", torch.cuda.device_count())
print("GPU Name:", torch.cuda.get_device_name(0) if torch.cuda.is_available() else "No GPU")
print("------------")

# # JAX GPU test
# print("JAX:")
# print("JAX version:", jax.__version__)
# print("JAX backend:", xla_bridge.get_backend().platform)
# print("------------")

# Keras GPU test (uses TensorFlow backend)
print("Keras:")
print("Keras version:", keras.__version__)
print("Keras GPU available:", "Yes" if tf.config.list_physical_devices('GPU') else "No")
print("------------")
问题
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[root@master ~]# python
Python 3.11.7 (main, Dec 15 2023, 18:12:31) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  ...
  File "/opt/ohpc/pub/apps/anaconda3/lib/python3.11/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: /opt/ohpc/pub/compiler/gcc/8.3.0/lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/ohpc/pub/apps/anaconda3/lib/python3.11/site-packages/google/protobuf/pyext/_message.cpython-311-x86_64-linux-gnu.so)
解决
1
2
3
4
5
cd /opt/ohpc/pub/apps/anaconda3/lib
strings libstdc++.so | grep GLIBCXX

# .bashrc export LD_LIBRARY_PATH=/opt/ohpc/pub/apps/anaconda3/lib:$LD_LIBRARY_PATH

图神经网络

  • MEGNet Chen C, Ye W, Zuo Y, et al. Graph networks as a universal machine learning framework for molecules and crystals[J]. Chemistry of Materials, 2019, 31(9): 3564-3572. 被引843

  • CGCNN | Tutorial Park C W, Wolverton C. Developing an improved crystal graph convolutional neural network framework for accelerated materials discovery[J]. Physical Review Materials, 2020, 4(6): 063801. 被引228

    AugLiChem: CGCNN k-fold cross validation

    MatDGL

  • ALIGNN Choudhary K, DeCost B. Atomistic line graph neural network for improved materials property predictions[J]. npj Computational Materials, 2021, 7(1): 185. 被引165

  • M3GNet Chen C, Ong S P. A universal graph deep learning interatomic potential for the periodic table[J]. Nature Computational Science, 2022, 2(11): 718-728. 被引136

    MatGL

1
pip install matgl --no-deps
  • DeeperGATGNN Louis S Y, Zhao Y, Nasiri A, et al. Graph convolutional neural networks with global attention for improved materials property prediction[J]. Physical Chemistry Chemical Physics, 2020, 22(32): 18141-18148. 被引130

  • OGCNN Karamad M, Magar R, Shi Y, et al. Orbital graph convolutional neural network for material property prediction[J]. Physical Review Materials, 2020, 4(9): 093801. 被引94

  • CHGNet Deng B, Zhong P, Jun K J, et al. CHGNet as a pretrained universal neural network potential for charge-informed atomistic modelling[J]. Nature Machine Intelligence, 2023, 5(9): 1031-1041. 被引29

  • KGCNN Reiser P, Eberhard A, Friederich P. Graph neural networks in TensorFlow-Keras with RaggedTensor representation (kgcnn)[J]. Software Impacts, 2021, 9: 100095. 被引14

  • SkipAtom Antunes L M, Grau-Crespo R, Butler K T. Distributed representations of atoms and materials for machine learning[J]. npj Computational Materials, 2022, 8(1): 44. 被引11

  • CEGANN Banik S, Dhabal D, Chan H, et al. CEGANN: Crystal Edge Graph Attention Neural Network for multiscale classification of materials environment[J]. npj Computational Materials, 2023, 9(1): 23. 被引10

  • ChargE3Net Koker T, Quigley K, Taw E, et al. Higher-order equivariant neural networks for charge density prediction in materials[J]. npj Computational Materials, 2024, 10(1): 161. 被引1

  • Matformer

1
2
3
git clone https://github.com/YKQ98/Matformer.git
cd Matformer
python setup.py install
1
pip install torch-geometric
1
2
3
4
5
# Linux:
pip install dgl==1.1.2 -f https://data.dgl.ai/wheels/cu117/repo.html

# Windows:
pip install dgl==1.1.2 -f https://data.dgl.ai/wheels/cu117/repo.html

./2024-11-16_200917.jpg

PyG与DGL对比

原子间势

  • NequIP Batzner S, Musaelian A, Sun L, et al. E (3)-equivariant graph neural networks for data-efficient and accurate interatomic potentials[J]. Nature communications, 2022, 13(1): 2453. 被引637

  • ChemicalMotifIdentifier Sheriff, K., Cao, Y. & Freitas, R. Chemical-motif characterization of short-range order with E(3)-equivariant graph neural networks. npj Comput Mater 10, 215 (2024).

  • SchNetPack Schütt K T, Kessel P, Gastegger M, et al. SchNetPack: A deep learning toolbox for atomistic systems[J]. Journal of chemical theory and computation, 2018, 15(1): 448-455. 被引354

  • Allegro Musaelian A, Batzner S, Johansson A, et al. Learning local equivariant representations for large-scale atomistic dynamics[J]. Nature Communications, 2023, 14(1): 579. 被引296

  • equiformer

     equiformer_v2

  • GPUMD

可视化