目录
1、安装CUDA10.1版本。参照:
2、安装Pytorch
3、安装pycocotools
4、安装mmcv
5、安装mmdetection
1、安装CUDA10.1版本。参照:
https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/105293721
2、安装Pytorch
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
或者:
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
3、安装pycocotools
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
4、安装mmcv
pip install mmcv
5、安装mmdetection
官方网站:https://github.com/open-mmlab/mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements.txt
修改编译文件:
.将~Lib\site-packages\torch\utils\cpp_extension.py 中 info = info.decode().lower()修为 info=info.decode("utf8","ignore").lower()
所有decode() 都改成decode("utf8","ignore")
修改mmdetection-master的setup.py文件。
将:
def make_cuda_ext(name, module, sources, sources_cuda=[]):
define_macros = []
extra_compile_args = {'cxx': []}
if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1':
define_macros += [('WITH_CUDA', None)]
extension = CUDAExtension
extra_compile_args['nvcc'] = [
'-D__CUDA_NO_HALF_OPERATORS__',
'-D__CUDA_NO_HALF_CONVERSIONS__',
'-D__CUDA_NO_HALF2_OPERATORS__',
]
sources += sources_cuda
else:
print(f'Compiling {name} without CUDA')
extension = CppExtension
# raise EnvironmentError('CUDA is required to compile MMDetection!')
return extension(
name=f'{module}.{name}',
sources=[os.path.join(*module.split('.'), p) for p in sources],
define_macros=define_macros,
extra_compile_args=extra_compile_args)
修改为:
def make_cuda_ext(name, module, sources, sources_cuda=[]):
return CUDAExtension(
name='{}.{}'.format(module, name),
sources=[os.path.join(*module.split('.'), p) for p in sources],
extra_compile_args={undefined
'cxx': ["-DMS_WIN64","-MD"],
'nvcc': [
'-D__CUDA_NO_HALF_OPERATORS__',
'-D__CUDA_NO_HALF_CONVERSIONS__',
'-D__CUDA_NO_HALF2_OPERATORS__',
]
})
然后运行:
python setup.py build_ext --inplace 进行编译
python setup.py install develop 完成安装
执行完成后运行pip list查看:
补充一句:即使安装成功后,也不能使用!新版本不支持Windows了! TMD,这是人干的事嘛