这里写自定义目录标题
1. Ubuntu 换源
修改 /etc/apt/sources.list
2. conda安装
- 安装miniconda
bash ~/.M+<Tab>补全.sh
- Conda换源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda config --set show_channel_urls yes`
- 测试
conda --version
3. pip换源
mkdir ~/.pip
cd ~/.pip
sudo gedit ~/.pip/pip.conf
填入
# coding: GBK
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
#清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
#阿里云:http://mirrors.aliyun.com/pypi/simple/
#豆瓣:http://pypi.douban.com/simple/
4. 安装cuda
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-wsl-ubuntu-12-1-local_12.1.1-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-1-local_12.1.1-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
- bashrc中添加
export PATH=$PATH:/usr/local/cuda/bin
- 检测
nvcc -V
5. 安装p10k
6. 配置代理
chmod +x .proxy.sh
alias proxytest='/root/.proxy.sh display'
alias proxyset='/root/.proxy.sh set'
alias proxyunset='/root/.proxy.sh unset'
#!/bin/bash
# .proxy.sh 文件内容
hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
wslip=$(hostname -I | awk '{print $1}')
port=7890
PROXY_SOCKS="socks5://${hostip}:${port}"
function display() {
echo "Host ip: ${hostip}"
echo "WSL client ip: ${wslip}"
echo "current PROXY: ${PROXY_SOCKS}"
}
function set_proxy() {
export http_proxy="${PROXY_SOCKS}"
export https_proxy="${PROXY_SOCKS}"
echo "env http/https proxy set."
}
function unset_proxy() {
unset http_proxy
unset https_proxy
echo "env proxy unset."
}
function set_git_proxy() {
git config --global http.proxy "${PROXY_SOCKS}"
git config --global https.proxy "${PROXY_SOCKS}"
echo "git config proxy set."
}
function unset_git_proxy() {
git config --global --unset http.proxy
git config --global --unset https.proxy
echo "git conffig proxy unset."
}
if [ "$1" = "display" ]; then
display
elif [ "$1" = "set" ]; then
set_proxy
elif [ "$1" = "unset" ]; then
unset_proxy
elif [ "$1" = "setgit" ]; then
set_git_proxy
elif [ "$1" = "ungit" ]; then
unset_git_proxy
else
echo "incorrect arguments."
fi
7.配置git
安装环境
- 安装pytorch
conda create -n py310 python=3.10
conda activate py310
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
python
import torch
print(torch.__version__)
print(torch.version.cuda)
conda install --channel conda-forge pymatgen
conda install --channel conda-forge ase
- 安装pyg
conda install pyg -c pyg
❯ python
Python 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
nt(torch.__version__)
print(torch.version.cuda)>>> print(torch.__version__)
2.0.1
>>> print(torch.version.cuda)
11.8
- 在线安装
pip install torch_sparse -f https://pytorch-geometric.com/whl/torch_sparse-0.6.17+pt20cu118-cp310-cp310-linux_x86_64.whl
pip install torch_scatter -f https://pytorch-geometric.com/whl/torch_scatter-2.1.1+pt20cu118-cp310-cp310-linux_x86_64.whl
pip install torch_cluster -f https://pytorch-geometric.com/whl/torch_cluster-1.6.1+pt20cu118-cp310-cp310-linux_x86_64.whl
pip install torch_spline_conv -f https://pytorch-geometric.com/whl/torch_spline_conv-1.2.2+pt20cu118-cp310-cp310-linux_x86_64.whl
- 离线安装(建议)
下载对应版本[https://pytorch-geometric.com/whl]
pip install torch_<Tab>补全.whl
- 安装其他环境
conda install pandas
conda install -c conda-forge wandb torchmetrics accelerate
conda install -y -c conda-forge tensorboard # -y参数是自动确认
-y: 自动确认安装过程中出现的提示信息,不需要人工手动确认;
-c conda-forge: 指定从 conda-forge 这个第三方 channel 中下载相应的软件包。conda-forge 是一个社区维护的 channel,提供了大量的开源软件包,可以满足更多用户的需求;