编程语言
首页 > 编程语言> > 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

标签:full,mmcv,py37,torch,源码,CUDA,Miniconda3,CPU
来源: https://www.cnblogs.com/jeshy/p/15125594.html