Windows Installation for pytracking

Windows Installation

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.

Requirements

  • Conda 64 installation with Python 3.7. If not already installed, install from https://www.anaconda.com/distribution/.
  • Nvidia GPU.
  • Visual Studio 2015 or newer.
  • Pre install CUDA 10.0 (not necessarily v10) with VS support.

Step-by-step instructions

Create and activate a conda environment

conda create --name pytracking python=3.7
conda activate pytracking

Install PyTorch

Install PyTorch with cuda10.(RTX3090 推荐cuda 11.1, 否则会报错

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

Note:

  • 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)
  • For more details about PyTorch installation, see https://pytorch.org/get-started/previous-versions/.

Install matplotlib, pandas, opencv, visdom and tensorboad

conda install matplotlib pandas
pip install opencv-python visdom tb-nightly

Install the coco toolkit

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.

conda install cython
pip install pycocotools

Install Precise ROI pooling

This is the complicated part. There are two options:

Install pre-build Precise ROI pooling package

DiMP and ATOM trackers need Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling). You can download the pre-build binary file (build on Windows 10) and install it. Or you could build your own package by following Build Precise ROI pooling with Visual Studio (Optional).

  • 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 from Microsoft.

  • 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).

  • 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.

  • Add this code to pytracking\ltr\external\PreciseRoIPooling\pytorch\prroi_pool\functional.py:

def _import_prroi_pooling():
    global _prroi_pooling
    
    #load the prroi_pool module    
	import imp
    file, path, description = imp.find_module('prroi_pool')
    with file:
        _prroi_pooling = imp.load_module('prroi_pool', file, path, description)

which should then look like:

import torch
import torch.autograd as ag

__all__ = ['prroi_pool2d']

_prroi_pooling = None

def _import_prroi_pooling():
    global _prroi_pooling

    #load the prroi_pool module
    import imp
    file, path, description = imp.find_module('prroi_pool')
    with file:
        _prroi_pooling = imp.load_module('prroi_pool', file, path, description)
    
    if _prroi_pooling is None:
        try:
            from os.path import join as pjoin, dirname
            from torch.utils.cpp_extension import load as load_extension
            root_dir = pjoin(dirname(__file__), 'src')

            _prroi_pooling = load_extension(
                '_prroi_pooling',
                [pjoin(root_dir, 'prroi_pooling_gpu.cpp'), pjoin(root_dir, 'prroi_pooling_gpu_impl.cu')],
                verbose=True
            )
        except ImportError:
            raise ImportError('Can not compile Precise RoI Pooling library.')

    return _prroi_pooling
...
  • If the pre-build package don’t work on your platform, you can build your own package as described in the next section.
Build Precise ROI pooling with Visual Studio (Optional)

To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling) on Windows, you need Visual Studio with CUDA installed.

  • First make a DLL project by the following step.
  1. Download the Precise ROI pooling module with

git clone https://github.com/vacancy/PreciseRoIPooling

.
2. Download pybind11

git clone https://github.com/pybind/pybind11

  1. Open Visual Studio and start a new C++ Empty project.
  2. 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.
  3. Add PreciseRoIPooling\src\prroi_pooling_gpu_impl.cuh and PreciseRoIPooling\pytorch\prroi_pool\src\prroi_pooling_gpu.h to the Header File.
  4. Right click the project --> Property. Change Configuration to Release and x64. Then Configuration Properties --> General --> change Configuration Type to .dll and Target Extension to .pyd .
  • Set the VC++ Directories.
  1. Find the following dirs and add them to VC++ Directories --> Include Directories.

Anaconda3\envs\pytracking\Lib\site-packages\torch\include\torch\csrc\api\include
Anaconda3\envs\pytracking\Lib\site-packages\torch\include\THC
Anaconda3\envs\pytracking\Lib\site-packages\torch\include\TH
Anaconda3\envs\pytracking\Lib\site-packages\torch\include
Anaconda3\envs\pytracking\include CUDA\v10.0\include
pybind11\pybind11\include

  1. Find the following dirs and add them to VC++ Directories --> Lib Directories.

Anaconda3\envs\pytracking\Lib\site-packages\torch\lib
Anaconda3\envs\pytracking\libs

  • Set the Linker.
  1. Find and add them to Linker --> General -->Additional Library Directories.

CUDA\v10.0\lib\x64 Anaconda3\envs\pytracking\libs
Anaconda3\envs\pytracking\Lib\site-packages\torch\lib Add them to
Linker --> Input -->Additional Dependencies

python37.lib python3.lib cudart.lib c10.lib torch.lib torch_python.lib
_C.lib c10_cuda.lib

  • Set the CUDA dependence.
  1. Right click the project --> Build dependencies --> Build Customizations --> click CUDA
  2. Right click the *.cu and *.cuh files --> Property. And change the type from C/C++ to CUDA C/C++
  • Set the package name and build.

Change prroi_pooling_gpu.cpp file in line 109

from

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {

to

PYBIND11_MODULE(prroi_pool, m) {

then build the package with Release and x64. You will get a *.pyd file. Rename it as prroi_pool.pyd.

In case of issues, we refer to https://github.com/vacancy/PreciseRoIPooling.

Install jpeg4py

In order to use jpeg4py for loading the images instead of OpenCV’s imread(), install jpeg4py in the following way,

pip install jpeg4py

In case of issues, we refer to https://github.com/ajkxyz/jpeg4py.

Setup the environment

Create the default environment setting files.

#Environment settings for pytracking. Saved at pytracking/evaluation/local.py python -c “from
pytracking.evaluation.environment import create_default_local_file;
create_default_local_file()”

#Environment settings for ltr. Saved at ltr/admin/local.py python -c “from ltr.admin.environment import create_default_local_file;
create_default_local_file()”

You can modify these files to set the paths to datasets, results paths etc.

Download the pre-trained networks

You can download the pre-trained networks from the google drive folder. The networks shoud be saved in the directory set by “network_path” in “pytracking/evaluation/local.py”. By default, it is set to pytracking/networks. You should download them manually and copy to the correct directory.

#directory of the default network for DiMP-50 and DiMP-18
pytracking/networks/dimp50.pth
pytracking/networks/dimp18.pth

#directory of the default network for ATOM
pytracking/networks/atom_default.pth

#directory of the default network for ECO
pytracking/networks/resnet18_vggmconv1.pth
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值