1 Crear un entorno virtual y activarlo
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
2 Instalar cudatoolkit y cudnn
2.1 Ver versión cudnn
conda search cudnn
2.2 Instale cuda y cudnn (elijo el último aquí, puede elegir el apropiado de acuerdo con la imagen de arriba)
conda install cudatoolkit=11.3
conda install cudnn=8.2.1
3 Instalar antorcha y torchvision
https://pytorch.org/get-started/previous-versions/ (sitio web oficial de pytorch)
# ROCM 5.1.1 (Linux only)
pip install torch==1.12.1+rocm5.1.1 torchvision==0.13.1+rocm5.1.1 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/rocm5.1.1
# CUDA 11.6
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
# CUDA 11.3
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
# CUDA 10.2
pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102
# CPU only
pip install torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cpu
3.1 Seleccione la versión adecuada del sitio web oficial e instálela
Nota: torch y torchvison deben corresponder a lo mismo y ser la versión GPU
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
4 Instale manualmente MMCV (muchas personas pueden fallar al instalar aquí)
4.1 Encuentra las versiones correspondientes de MMCV y Cuda, antorcha
https://mmcv.readthedocs.io/en/latest/get_started/installation.html#install-mmcv
4.2 Instalar MMCV
pip install mmcv-full==1.6.2 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.12/index.html
5 Clonar la biblioteca MMAction2
git clone https://github.com/open-mmlab/mmaction2.git
cd mmaction2
6 Instalar dependencias y MMAction2
Versión 6.1 dada por mmaction
pip install -r requirements/build.txt
pip install -v -e .
6.2 La versión del autor (abrir requirements.txt para ver que incluye requirements/build.txt)
pip install -r requirements.txt
pip install -v -e .
7 pruebas
7.1 Cuda de prueba
import torch
flag = torch.cuda.is_available()
if flag:
print("CUDA可使用")
else:
print("CUDA不可用")
7.2 Pruebe mmaction (tome la ejecución de configs/recognition/tsn/tsn_r50_1x1x3_75e_ucf101_rgb.py como ejemplo), y si ve el registro impreso, significa que la generación de su entorno se ha creado correctamente.
python tools/train.py configs/recognition/tsn/tsn_r50_1x1x3_75e_ucf101_rgb.py --validate --seed 0 --deterministic --gpu-ids 0
8 siguiente paso
En el siguiente paso, podrá comprender el código interno de acuerdo con la documentación oficial. Te deseo éxito.
https://mmaction2.readthedocs.io/zh_CN/latest/install.html#mmaction2