|
| 1 | +# Windows Installation |
| 2 | + |
| 3 | +This document contains detailed instructions for installing the necessary dependencies for PyTracking on Windows. The instructions have been tested on a Windows 10 system with Visual Studio 2015. **Notice that Windows installation is much more complex. [Installation on Linux (Ubuntu) is highly recommended.](INSTALL.md)** |
| 4 | + |
| 5 | +### Requirements |
| 6 | +* Conda 64 installation with Python 3.7. If not already installed, install from https://www.anaconda.com/distribution/. |
| 7 | +* Nvidia GPU. |
| 8 | +* Visual Studio 2015 or newer. |
| 9 | +* Pre install CUDA 10.0 (not necessarily v10) with VS support. |
| 10 | + |
| 11 | +## Step-by-step instructions |
| 12 | +#### Create and activate a conda environment |
| 13 | +```bash |
| 14 | +conda create --name pytracking python=3.7 |
| 15 | +conda activate pytracking |
| 16 | +``` |
| 17 | + |
| 18 | +#### Install PyTorch |
| 19 | +Install PyTorch with cuda10. |
| 20 | +```bash |
| 21 | +conda install pytorch torchvision cudatoolkit=10.0 -c pytorch |
| 22 | +``` |
| 23 | + |
| 24 | +**Note:** |
| 25 | +- It is possible to use any PyTorch supported version of CUDA (not necessarily v10), but better be the same version with your preinstalled CUDA (if you have one) |
| 26 | +- For more details about PyTorch installation, see https://pytorch.org/get-started/previous-versions/. |
| 27 | + |
| 28 | +#### Install matplotlib, pandas, opencv, visdom and tensorboad |
| 29 | +```bash |
| 30 | +conda install matplotlib pandas |
| 31 | +pip install opencv-python visdom tb-nightly |
| 32 | +``` |
| 33 | + |
| 34 | + |
| 35 | +#### Install the coco toolkit |
| 36 | +If you want to use COCO dataset for training, install the coco python toolkit. You additionally need to install cython to compile the coco toolkit. |
| 37 | +```bash |
| 38 | +conda install cython |
| 39 | +pip install pycocotools |
| 40 | +``` |
| 41 | + |
| 42 | +#### Install Precise ROI pooling |
| 43 | + |
| 44 | +This is thecomplicated part. There are two options: |
| 45 | + |
| 46 | +##### Install pre-build Precise ROI pooling package |
| 47 | + |
| 48 | +DiMP and ATOM trackers need Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling). You can download the [pre-build binary file](https://visionml.github.io/dimp/prroi_pool.pyd) (build on Windows 10) and install it. Or you could build your own package by following [Build Precise ROI pooling with Visual Studio (Optional)](#build-precise-roi-pooling-with-visual-studio-optional). |
| 49 | + |
| 50 | ++ The package is built with VS2015, so in some cases (such as you don't have VS2015) you will need to install [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145) from Microsoft. |
| 51 | + |
| 52 | ++ Add `Anaconda3\envs\pytracking\Lib\site-packages\torch\lib` to users path (Right click this PC --> Properties --> Advanced System settings --> Environment Variables --> User variables --> Path). |
| 53 | + |
| 54 | ++ Copy the `prroi_pool.pyd` file to the conda environment python path (such as `Anaconda3\envs\pytracking\Lib\site-packages\`). This will take action after restart the shell. |
| 55 | + |
| 56 | ++ Add this code to `pytracking\ltr\external\PreciseRoIPooling\pytorch\prroi_pool\functional.py`: |
| 57 | + |
| 58 | + ```python |
| 59 | + ... |
| 60 | + def _import_prroi_pooling(): |
| 61 | + global _prroi_pooling |
| 62 | + |
| 63 | + #load the prroi_pool module |
| 64 | + import imp |
| 65 | + file, path, description = imp.find_module('prroi_pool') |
| 66 | + with file: |
| 67 | + _prroi_pooling = imp.load_module('prroi_pool', file, path, description) |
| 68 | + ... |
| 69 | + ``` |
| 70 | + |
| 71 | + which should then look like: |
| 72 | + |
| 73 | + ```python |
| 74 | + import torch |
| 75 | + import torch.autograd as ag |
| 76 | + |
| 77 | + __all__ = ['prroi_pool2d'] |
| 78 | + |
| 79 | + _prroi_pooling = None |
| 80 | + |
| 81 | + def _import_prroi_pooling(): |
| 82 | + global _prroi_pooling |
| 83 | + |
| 84 | + #load the prroi_pool module |
| 85 | + import imp |
| 86 | + file, path, description = imp.find_module('prroi_pool') |
| 87 | + with file: |
| 88 | + _prroi_pooling = imp.load_module('prroi_pool', file, path, description) |
| 89 | + |
| 90 | + if _prroi_pooling is None: |
| 91 | + try: |
| 92 | + from os.path import join as pjoin, dirname |
| 93 | + from torch.utils.cpp_extension import load as load_extension |
| 94 | + root_dir = pjoin(dirname(__file__), 'src') |
| 95 | + |
| 96 | + _prroi_pooling = load_extension( |
| 97 | + '_prroi_pooling', |
| 98 | + [pjoin(root_dir, 'prroi_pooling_gpu.cpp'), pjoin(root_dir, 'prroi_pooling_gpu_impl.cu')], |
| 99 | + verbose=True |
| 100 | + ) |
| 101 | + except ImportError: |
| 102 | + raise ImportError('Can not compile Precise RoI Pooling library.') |
| 103 | + |
| 104 | + return _prroi_pooling |
| 105 | + ... |
| 106 | + ``` |
| 107 | + |
| 108 | ++ If the pre-build package don't work on your platform, you can build your own package as described in the next section. |
| 109 | + |
| 110 | +##### Build Precise ROI pooling with Visual Studio (Optional) |
| 111 | + |
| 112 | +To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling) on Windows, you need Visual Studio with CUDA installed. |
| 113 | + |
| 114 | ++ First make a DLL project by the following step. |
| 115 | + |
| 116 | + 1. Download the Precise ROI pooling module with `git clone https://github.com/vacancy/PreciseRoIPooling `. |
| 117 | + 2. Download pybind11 `git clone https://github.com/pybind/pybind11 ` |
| 118 | + 3. Open Visual Studio and start a new C++ `Empty project`. |
| 119 | + 4. Add `PreciseRoIPooling\src\prroi_pooling_gpu_impl.cu` and `PreciseRoIPooling\pytorch\prroi_pool\src\prroi_pooling_gpu.c` to the `Source File` and change the name `prroi_pooling_gpu.c` to `prroi_pooling_gpu.cpp`. |
| 120 | + 5. Add `PreciseRoIPooling\src\prroi_pooling_gpu_impl.cuh` and `PreciseRoIPooling\pytorch\prroi_pool\src\prroi_pooling_gpu.h` to the `Header File`. |
| 121 | + 6. Right click the project --> Property. **Change Configuration to `Release` and `x64`**. |
| 122 | + Then Configuration Properties --> General --> change Configuration Type to `.dll` and Target Extension to `.pyd` . |
| 123 | + |
| 124 | ++ Set the VC++ Directories. |
| 125 | + |
| 126 | + 1. Find the following dirs and add them to VC++ Directories --> Include Directories. |
| 127 | + ``` |
| 128 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\include\torch\csrc\api\include |
| 129 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\include\THC |
| 130 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\include\TH |
| 131 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\include |
| 132 | + Anaconda3\envs\pytracking\include |
| 133 | + CUDA\v10.0\include |
| 134 | + pybind11\pybind11\include |
| 135 | + ``` |
| 136 | +
|
| 137 | + 2. Find the following dirs and add them to VC++ Directories --> Lib Directories. |
| 138 | + |
| 139 | + ``` |
| 140 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\lib |
| 141 | + Anaconda3\envs\pytracking\libs |
| 142 | + ``` |
| 143 | + |
| 144 | ++ Set the Linker. |
| 145 | +
|
| 146 | + 1. Find and add them to Linker --> General -->Additional Library Directories. |
| 147 | +
|
| 148 | + ``` |
| 149 | + CUDA\v10.0\lib\x64 |
| 150 | + Anaconda3\envs\pytracking\libs |
| 151 | + Anaconda3\envs\pytracking\Lib\site-packages\torch\lib |
| 152 | + ``` |
| 153 | +
|
| 154 | + 2. Add them to Linker --> Input -->Additional Dependencies |
| 155 | + |
| 156 | + ``` |
| 157 | + python37.lib |
| 158 | + python3.lib |
| 159 | + cudart.lib |
| 160 | + c10.lib |
| 161 | + torch.lib |
| 162 | + torch_python.lib |
| 163 | + _C.lib |
| 164 | + c10_cuda.lib |
| 165 | + ``` |
| 166 | + |
| 167 | ++ Set the CUDA dependence. |
| 168 | +
|
| 169 | + 1. Right click the project --> Build dependencies --> Build Customizations --> click CUDA |
| 170 | + 2. Right click the `*.cu` and `*.cuh` files --> Property. And change the type from `C/C++` to `CUDA C/C++` |
| 171 | +
|
| 172 | ++ Set the package name and build. |
| 173 | +
|
| 174 | + Change `prroi_pooling_gpu.cpp` file in `line 109` |
| 175 | +
|
| 176 | + from |
| 177 | +
|
| 178 | + ``` |
| 179 | + PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { |
| 180 | + ``` |
| 181 | +
|
| 182 | + to |
| 183 | +
|
| 184 | + ``` |
| 185 | + PYBIND11_MODULE(prroi_pool, m) { |
| 186 | + ``` |
| 187 | +
|
| 188 | + then build the package with **`Release` and `x64`**. You will get a `*.pyd` file. Rename it as `prroi_pool.pyd`. |
| 189 | +
|
| 190 | ++ Last but not least, follow the step in [Install pre-build Precise ROI pooling package](#install-pre-build-precise-roi-pooling-package). |
| 191 | +
|
| 192 | + In case of issues, we refer to https://github.com/vacancy/PreciseRoIPooling. |
| 193 | +
|
| 194 | +#### Install jpeg4py |
| 195 | +In order to use [jpeg4py](https://github.com/ajkxyz/jpeg4py) for loading the images instead of OpenCV's imread(), install jpeg4py in the following way, |
| 196 | +```bash |
| 197 | +pip install jpeg4py |
| 198 | +``` |
| 199 | + |
| 200 | +In case of issues, we refer to https://github.com/ajkxyz/jpeg4py. |
| 201 | + |
| 202 | + |
| 203 | +#### Setup the environment |
| 204 | +Create the default environment setting files. |
| 205 | +```bash |
| 206 | +# Environment settings for pytracking. Saved at pytracking/evaluation/local.py |
| 207 | +python -c "from pytracking.evaluation.environment import create_default_local_file; create_default_local_file()" |
| 208 | + |
| 209 | +# Environment settings for ltr. Saved at ltr/admin/local.py |
| 210 | +python -c "from ltr.admin.environment import create_default_local_file; create_default_local_file()" |
| 211 | +``` |
| 212 | + |
| 213 | +You can modify these files to set the paths to datasets, results paths etc. |
| 214 | + |
| 215 | + |
| 216 | +#### Download the pre-trained networks |
| 217 | +You can download the pre-trained networks from the [google drive folder](https://drive.google.com/drive/folders/1WVhJqvdu-_JG1U-V0IqfxTUa1SBPnL0O). |
| 218 | +The networks shoud be saved in the directory set by "network_path" in "pytracking/evaluation/local.py". By default, it is set to |
| 219 | +pytracking/networks. |
| 220 | +You should download them manually and copy to the correct directory. |
| 221 | + |
| 222 | +```bash |
| 223 | +# directory of the default network for DiMP-50 and DiMP-18 |
| 224 | +pytracking/networks/dimp50.pth |
| 225 | +pytracking/networks/dimp18.pth |
| 226 | + |
| 227 | +# directory of the default network for ATOM |
| 228 | +pytracking/networks/atom_default.pth |
| 229 | + |
| 230 | +# directory of the default network for ECO |
| 231 | +pytracking/networks/resnet18_vggmconv1.pth |
| 232 | +``` |
0 commit comments