Win10 Python3.7 安裝pytorch1.5+ mmdetection2.1,搭建mmdetection環境

目錄

 

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={
            '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,這是人乾的事嘛

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章