Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 w/ VS2019 and torch cpu only #18

Open
Degot opened this issue Aug 8, 2020 · 3 comments
Open

Windows 10 w/ VS2019 and torch cpu only #18

Degot opened this issue Aug 8, 2020 · 3 comments

Comments

@Degot
Copy link

Degot commented Aug 8, 2020

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
Copy link

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
Copy link

thank you so much

@ghost
Copy link

ghost commented Aug 9, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants