conansherry / detectron2

detectron2 windows build
Apache License 2.0
223 stars 54 forks source link

Windows 10 w/ VS2019 and torch cpu only #18

Open Degot opened 4 years ago

Degot commented 4 years ago

This way I'm able to build and instal detectron2 on Windows 10.. I use CPU only for pytorch.

conda create -n test conda activate test conda install pip opencv numpy scipy git curl conda install pytorch torchvision cpuonly -c pytorch pip install git+https://github.com/facebookresearch/fvcore pip install cython

curl -o pycocotools-2.0.1.tar.gz https://files.pythonhosted.org/packages/5c/82/bcaf4d21d7027fe5165b88e3aef1910a36ed02c3e99d3385d1322ea0ba29/pycocotools-2.0.1.tar.gz#sha256=1c06e73a85ed9874c1174d47064524b9fb2759b95a6997437775652f20c1711f tar -xzf pycocotools-2.0.1.tar.gz git clone https://github.com/facebookresearch/detectron2

python with open('./pycocotools-2.0.1/setup.py') as f: newText=f.read().replace("extra_compile_args", "extra_compile_args={'gcc': ['/Qstd=c99']},#extra_compile_args")

with open('./pycocotools-2.0.1/setup.py', "w") as f: f.write(newText)

with open('./detectron2/setup.py') as f: newText=f.read().replace("BuildExtension},", "BuildExtension.with_options(use_ninja=False)},")

with open('./detectron2/setup.py', "w") as f: f.write(newText)

with open('./detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp') as f: newText=f.read().replace("py::dict Accumulate(", "struct tm localtime_r(time_t _clock, struct tm _result) { struct tm p = localtime(_clock); if (p) (_result) = p; return p;};py::dict Accumulate(")

with open('./detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp', "w") as f: f.write(newText)

exit()

cd pycocotools-2.0.1 python setup.py build install

cd ..\detectron2 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" set DISTUTILS_USE_SDK=1 python setup.py build develop install

(test) D:\Temp\CondaEnvs\detectron2>python Python 3.8.5 (default, Aug 5 2020, 09:44:06) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.

import detectron2 detectron2.version '0.2.1'

markstrefford commented 3 years ago

Thanks for this. There's a couple of changes for me: 1) The file vcvars64.bat was at a different location (I'm not using the Enterprise version of VS) 2) I used detectron2.__version__

hihishenxian commented 3 years ago

thank you so much

ghost commented 3 years ago

Thanks for the script. Works like a charm on the latest commit version 0.5. detectron2-0.5-py3.7-win-amd64.egg.zip