mmcv学习笔记(一):安装
一、要素分析
本文主要介绍GPU版本。
- 
- NVIDIA Driver(CUDA需要)
 
 - 
- CUDA
 
 - 
- conda环境(推荐使用的python虚拟环境管理工具)
 
 - 
- mmcv-full包
 
 
二、安装脚本
假定已经安装conda和CUDA。
本文的安装脚本只支持CUDA 11.3(因为mmcv-full的兼容性问题。未来也只能添加对少数几个版本的支持)。
2.1 安装脚本-Windows
# 1. Create New Conda Environment
echo "Found Conda Installed"
$conda_env="mmcv"
if(conda info --env | findstr $conda_env){
    echo "There has been a conda environment named '$conda_env'. Please set a new one."
    exit 1
}
conda create -n $conda_env python=3.9 -y
conda activate $conda_env
$conda_current_env = (conda info --env | findstr *).split()[0]
if($conda_env -ne $conda_current_env){
    echo "Conda Error: current conda environment is not activated correctly."
    exit 1
}
echo "Conda Environment '$conda_env' created."
  
# 2. Get Version Of CUDA (nvcc)
$cuda_path = (gcm nvcc).Source
$cuda_dir = Split-Path -parent (Split-Path -parent $cuda_path)
$cuda_version = ((Get-Content $cuda_dir/version.json) | ConvertFrom-Json).cuda.version
echo "Found CUDA $cuda_version at $cuda_path"
# 3. Install Pytorch with Conda
if($cuda_version.StartsWith("11.3")){
    conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch -y
}
else {
    echo "CUDA version '$cuda_version' not supported by this script. Please try to install manually."
    exit 1
}
$torch_version = (pip list | findstr 'torch' | findstr /v 'torchvision' | findstr /v 'torchaudio').split()[-1]
# 4. Install mmcv-full
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch$torch_version/index.html
然后在powershell中运行。
2.2 安装脚本-Linux
暂未整理,日后补上。
2.3 安装脚本-MacOS
暂未整理,日后补上。
                    
                
                
            
        
浙公网安备 33010602011771号