目录

机器学习

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

数据库

结构搭建

描述符

计算框架

安装GPU驱动

注意
也可以使用nvidia-smi查看。
警告
不要使用cuDNN 历史版本,而应使用cuDNN Archive。因为前者登录账号会在跳转下载页面时退出,并要求重新登录,并一直反复下去。

修改环境变量:右键此电脑属性高级系统设置环境变量Path编辑新建

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
  • nvitop
1
2
pip install nvitop
nvitop

安装TensorFlow、PyTorch、JAX、Keras

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

测试TensorFlow、PyTorch、JAX、Keras

警告
安装TensorFlowPyTorchJAXKeras需在CUDAcuDNN安装好之后再进行。
 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("------------")
警告
通过安装TensorFlow来顺带安装Keras,否则会在keras.__version__出现报错。
问题
 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

  • 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

  • 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

  • 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

  • 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

  • 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 -f https://data.dgl.ai/wheels/cu117/repo.html

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

可视化