# Detectron2 on windows

**URL:** <https://discuss.pytorch.org/t/detectron2-on-windows/111974>\
**Category:** vision\
**Created:** [February 15, 2021, 8:15pm UTC](https://discuss.pytorch.org/t/detectron2-on-windows/111974 "2021-02-15T20:15:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammad4hmed](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/muhammad4hmed/32/26387_2.png) [@Muhammad4hmed](https://discuss.pytorch.org/u/Muhammad4hmed)\
**Post date:** [February 15, 2021, 8:15pm UTC](https://discuss.pytorch.org/t/detectron2-on-windows/111974/1 "2021-02-15T20:15:03Z")

</div>

Hi, I’m trying to install detectron on my windows, here is what I have tried:

My pytorch version is: 1.5.1+cpu and torchvision is 0.6.1+cpu.  
First of all, I installed pycocotools from [https://pypi.org/project/pycocotools-windows/](https://pypi.org/project/pycocotools-windows/)  
then cloned the detectron2 from [https://github.com/DGMaxime/detectron2-windows](https://github.com/DGMaxime/detectron2-windows)  
and then ran the setup

```auto
cd detectron2-windows
pip install -e .

```

But getting the following error:

```auto
Running setup.py develop for detectron2
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Retrocausal\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Retrocausal\\detectron2-windows\\setup.py'"'"'; __file__ ='"'"'C:\\Users\\Retrocausal\\detectron2-windows\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)( __file__ );code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__ , '"'"'exec'"'"'))' develop --no-deps
         cwd: C:\Users\Retrocausal\detectron2-windows\
    Complete output (22 lines):
    running develop
    running egg_info
    creating detectron2.egg-info
    writing detectron2.egg-info\PKG-INFO
    writing dependency_links to detectron2.egg-info\dependency_links.txt
    writing requirements to detectron2.egg-info\requires.txt
    writing top-level names to detectron2.egg-info\top_level.txt
    writing manifest file 'detectron2.egg-info\SOURCES.txt'
    reading manifest file 'detectron2.egg-info\SOURCES.txt'
    writing manifest file 'detectron2.egg-info\SOURCES.txt'
    running build_ext
    building 'detectron2._C' extension
    C:\Users\Retrocausal\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py:305: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
      warnings.warn(msg.format('we could not find ninja.'))
    C:\Users\Retrocausal\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py:238: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
      warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "C:\Users\Retrocausal\Anaconda3\lib\site-packages\colorama\ansitowin32.py", line 59, in closed
        return stream.closed
    ValueError: underlying buffer has been detached
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Retrocausal\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Retrocausal\\detectron2-windows\\setup.py'"'"'; __file__ ='"'"'C:\\Users\\Retrocausal\\detectron2-windows\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)( __file__ );code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__ , '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

```

I have followed a few tutorial on internet regarding installation of detectron2 but none of them worked have spent almost 2 weeks on this, Kindly guide regarding this. Thanks.

---

<div class="post-metadata">

**Author:** ![mobassir94](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mobassir94/32/21181_2.png) [@mobassir94](https://discuss.pytorch.org/u/mobassir94)\
**Post date:** [April 26, 2021, 1:25pm UTC](https://discuss.pytorch.org/t/detectron2-on-windows/111974/2 "2021-04-26T13:25:12Z")

</div>

follow this discussion carefully : [yml file isn't working(CondaEnvException: Pip failed) · Issue #2 · markstrefford/running-detectron2-on-windows-wsl2-rtx30xx · GitHub](https://github.com/markstrefford/running-detectron2-on-windows-wsl2-rtx30xx/issues/2)

you will get to know how i installed detectron2 in windows successfully using rtx 3060ti,thanks

---

<div class="post-metadata">

**Author:** ![solarflarefx](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@solarflarefx](https://discuss.pytorch.org/u/solarflarefx)\
**Post date:** [June 8, 2021, 9:44pm UTC](https://discuss.pytorch.org/t/detectron2-on-windows/111974/3 "2021-06-08T21:44:50Z")

</div>

@mobassir94 Are you running detectron2 using the CPU or GPU on Windows?

---

<div class="post-metadata">

**Author:** ![mobassir94](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mobassir94/32/21181_2.png) [@mobassir94](https://discuss.pytorch.org/u/mobassir94)\
**Post date:** [June 14, 2021, 8:43am UTC](https://discuss.pytorch.org/t/detectron2-on-windows/111974/4 "2021-06-14T08:43:44Z")

</div>

i didn’t train anything on gpu using detectron2,but i was able to import detectron2 and also this import :  
from detectron2 import \_C  
i guess as i didn’t get any error,means i can use both cpu and gpu
