創建 anaconda 環境

1
conda create -n env_name python=3.8

激活 anaconda 環境

1
conda activate env_name

退出 anaconda 環境

1
conda deactivate

刪除 anaconda 環境

1
conda remove -n env_name --all

列出 anaconda 環境

1
conda env list

列出 anaconda 環境中的套件

1
conda list -n env_name

更新 anaconda 套件

1
conda update -n env_name --all

pytorch 相關套件

1
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113

測試 pytorch 與 gpu 是否相容

1
print(torch.device("cuda" if torch.cuda.is_available() else "cpu"))

openCV 相關套件

1
pip install opencv-python

matplotlib 相關套件

1
pip install matplotlib

tqdm 相關套件

1
pip install tqdm

在 background 中運行 bash 命令

1
nohup python main.py &

查看 ubuntu 後台中的 python 進程

1
ps aux | grep main.py

查看 nohup.out 檔案

1
2
3
4
# 查看最新的 
tail nohup.out
# 查看 nohup.out 檔案的內容
cat nohup.out

殺掉 python 進程

1
kill PID


作者: 微風