msracver / FCIS

Fully Convolutional Instance-aware Semantic Segmentation
MIT License
1.57k stars 414 forks source link

In-depth guide to getting FCIS working on Windows 10 #153

Open ferakon opened 4 years ago

ferakon commented 4 years ago

Hi all,

I had quite a bit of trouble getting this working on Windows 10, so wanted to share my setup process for others who may be struggling to get FCIS working. I understand that this isn't really an 'Issue' per se, but I think it might help a lot of people until these steps are better highlighted in the official repo README. Remember to replace Your_User_Name in some of the file paths I discuss here.

After following these steps I successfully managed to train FCIS on the COCO 2014 40K validation dataset.

1. Required software etc.

Visual Studio Community 2015 https://visualstudio.microsoft.com/vs/older-downloads/

CUDA Toolkit 8.0 GA2 (Feb 2017) and Patch 2: https://developer.nvidia.com/cuda-toolkit-archive

cuDNN 6.0: https://developer.nvidia.com/rdp/cudnn-download

CMake: https://cmake.org/download/

Open CV 3.4.9: https://opencv.org/releases/ *OpenCV - 3.4.9 > Windows

OpenBLAS: https://sourceforge.net/projects/openblas/files/v0.3.6/ *OpenBLAS-0.3.6-x64.zip

mingw64 DLLs: https://sourceforge.net/projects/openblas/files/v0.2.12/mingw64_dll.zip/download

2. Set Environment Variables:

Start > Advanced System Settings > Environment variables...

Then under User variables for User:

Path > Edit > New ...add the following to Path:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\
C:\opencv\build\x64\vc14\bin
C:\common
C:\Program Files (x86)\MSBuild\14.0\Bin

OK

Now back on 'Environment Variables' Add the following new variables: New...

Variable Name: CUDACXX
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe
Variable Name: CUDNN_ROOT 
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
Variable Name: OpenBLAS_HOME
Variable Value: C:\OpenBLAS-0.3.6-x64
Variable Name: OpenCV_DIR
Variable Value: C:\opencv\build

3. Setup Python:

Anaconda 2.7 (...yes FCIS is written in 2.7 and would otherwise d require a lot of work to convert to 3) https://www.anaconda.com/distribution/

... everything else seemed to already be there but you might want to make sure to also pip: Cython easydict hickle

4. Install git

Open Anaconda2 prompt and type:

conda install git

5. Download FCIS and fix code for Windows:

git clone https://github.com/msracver/FCIS.git

fix windows cuda setup by adding:

# remove ID=2
elif ',ID=2' in c: del cmd[idx]

...to the bottom of the elif statements in: setup_windows_cuda.py in lib\nms (elif statement should be added within for loop that starts at line 85) setup_windows.py in lib\mask (elif statement should be added within for loop that starts at line 82)

fix kvstore param problem by following instructions at https://github.com/msracver/FCIS/issues/135 In summary:

Change some lines between 570--590 in ./fcis/core/module.py to the following:

if self._update_on_kvstore:
    try: # Add this try above following code
        _update_params_on_kvstore(self._exec_group.param_arrays,
        self._exec_group.grad_arrays,
        self._kvstore)
# Add this exception block below the above try
    except:
        _update_params_on_kvstore(self._exec_group.param_arrays,
        self._exec_group.grad_arrays,
        self._kvstore, param_names=self._exec_group.param_names)

6. Setup and compile proper mxnet version:

In command prompt go to: C:\Users\**Your_User_Name**\Anaconda2\Lib\site-packages

Enter the follwoing commands:

git clone --recursive https://github.com/dmlc/mxnet.git

wait for mxnet to download...

git checkout 998378a
git submodule init
git submodule update

wait for submodules to update...

Copy files in FCIS repo .\fcis\operator_cxx to C:\Users\**Your_User_Name**\Anaconda2\Lib\site-packages\mxnet\src\operator\contrib

... 3 files will be overwritten

Navigate Anaconda2 prompt to: C:\Users\**Your_User_Name**\Anaconda2\Lib\site-packages\mxnet

Enter commands:

mkdir build
cd build

make the code with the following command:

cmake -G "Visual Studio 14 2015 Win64" -T cuda=8.0,host=x64 -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_LIST=Common -DCUDA_TOOLSET=8.0 -DCUDNN_INCLUDE="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -DCUDNN_LIBRARY="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cudnn.lib" "C:\Users\**Your_User_Name**\Anaconda2\Lib\site-packages\mxnet"

...compile code with the following command (may take a while, should end with warnings but no errors if previous steps have been followed correctly):

msbuild mxnet.sln /p:Configuration=Release;Platform=x64

After compile, setup mxnet for python (assuming you are currently still in C:\Users\**Your_User_Name**\Anaconda2\Lib\site-packages\mxnet\build:

cd ..
cd python
python setup.py install

Fix mxnet to behave like older version in base_module.py as described in https://github.com/msracver/FCIS/issues/107

.. in summary:

Open: C:\Users\*Your_User_Name*\Anaconda2\Lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\base_module.py

...delete allow_extra=allow_extra on line 649

Everything should now be ready to go. Follow instructions in README.md of FCIS repo to try demo code.

Hope that helps some people struggling with software versions / setup, or just finding it hard to get this working on windows.

oguzhannysr commented 1 year ago

Hello, I got the following result after the compile process. I have too many errors

https://pasteboard.co/SyYBYzosAPf1.png

oguzhannysr commented 1 year ago

https://pasteboard.co/pVYzoTUIL3Hd.png I also encountered such a column. Can you help me ?

ferakon commented 1 year ago

I am not sure that I could help you with your specific issues as I wrote this guide a few years ago now and have not used this FCIS repo since then. The authors have also not updated the repo in 4+ years so there has probably been quite a few updates to required packages and software since release. I would imagine you are most likely encountering a version incompatibility issue somewhere. I would start by checking that your mxnet is the same as that listed in the guide. Sorry I can't be of further help.