1. 程式人生 > 其它 >window下原始碼編譯mmcv-full==1.2.1

window下原始碼編譯mmcv-full==1.2.1

window下原始碼編譯mmcv-full==1.2.1

軟體準備:
Git、vs2019_community、Miniconda3-4.6.14、cuda_10.2+cudnn_7.6.5

一、確認NVIDIA GeForce RTX 2080 Ti已安裝
cmd 命令:nvidia-smi OR nvidia-smi -L
*************************************
>nvidia-smi -L
GPU 0: NVIDIA GeForce RTX 2080 Ti (UUID: GPU-6a2b3f72-b96d-f2d4-bb59-87e7e869b070)

二、下載Miniconda3安裝並設定環境變數
1. Miniconda3-4.6.14-Windows-x86_64.exe
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
2. 設定環境變數 Set Environment variable:
F:\Miniconda3\Library\bin
F:\Miniconda3\Scripts
F:\Miniconda3

三、開啟Anaconda prompt並建立虛擬環境py37
Launch Anaconda prompt:
conda create -n py37 python=3.7
conda activate py37
# conda remove -n py37 --all# remove 虛擬環境py37
# CUDA 10.2 安裝pytorch和torchvision
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch

四、檢視torch依賴的cuda和cudnn版本,並下載對應版本的cuda和cudnn,並安裝
>python
import torch
print(torch.__version__)
print(torch.version.cuda)
print(torch.backends.cudnn.version())

五、git clone mmcv==1.2.1
mmcv==1.2.1
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
git checkout 91a7fee
pip3 install -r requirements.txt

六、設定編譯器 Set up MSVC compiler: Set Environment variable, add
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\Hostx86\x64
to PATH, so that cl.exe will be available in prompt

full version with CUDA: Make sure CUDA_PATH or CUDA_HOME is already set, as
CUDA_PATH C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2
CUDA_PATH_V10_2 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2

七、設定CUDA的算力Set CUDA target arch
# Suppose you are using RTX 2080 Ti , which is of capability 7.5
TORCH_CUDA_ARCH_LIST=7.5

八、可選,設定CPU執行配置# Optional
MMCV_WITH_OPS=1
MAX_JOBS=16# based on available number of CPU cores and amount of memory

九、build、install、check mmcv
cd mmcv
# build
python setup.py build_ext # if success, cl will be launched to compile ops
# install
python setup.py develop
# check
pip list

其他:檢視物理CPU數、CPU核心數、執行緒數
在cmd命令中輸入“wmic”,然後在出現的新視窗中輸入“cpu get *”

NumberOfCores:表示CPU核心數
NumberOfLogicalProcessors:表示CPU執行緒數

cmd->wmic
cmd->CPU GET NumberOfCores,NumberOfLogicalProcessors

NumberOfCores NumberOfLogicalProcessors
16 32
16 32

個人學習記錄