pytracking框架 服务器端配置采坑(ubuntu18.04+cuda11.3)

首先附上github链接,里面其实有比较详细的安装教程了,不过完全照做会有些小坑

GitHub - visionml/pytracking: Visual tracking library based on PyTorch.

1. Create and activate a conda environment

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

2. Install PyTorch

Install PyTorch with cuda10.

pytracking框架 服务器端配置采坑(ubuntu18.04+cuda11.3)_第1张图片

 由于我使用的是RTX3060不支持cuda10,正好试一下cuda11的支持情况,在pytorch官网找命令

Start Locally | PyTorch

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

(注意,我使用pip安装下面会遇到坑,建议直接使用conda安装)

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

Note:

  • It is possible to use any PyTorch supported version of CUDA (not necessarily v10).
  • For more details about PyTorch installation, see Previous PyTorch Versions | PyTorch.

3. Install matplotlib, pandas, tqdm, opencv, scikit-image, visdom, tikzplotlib, gdown, and tensorboad

conda install matplotlib pandas tqdm
pip install opencv-python visdom tb-nightly scikit-image tikzplotlib gdown

Install the coco and lvis toolkits

conda install cython
pip install pycocotools
pip install lvis

Install ninja-build for Precise ROI pooling

To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling), you may additionally have to install ninja-build.

sudo apt-get install ninja-build

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

Install spatial-correlation-sampler (only required for KYS tracker)

pip install spatial-correlation-sampler

In case of issues, we refer to https://github.com/ClementPinard/Pytorch-Correlation-extension.

Install jpeg4py

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

sudo apt-get install libturbojpeg
pip install jpeg4py 

Note: The first step (sudo apt-get install libturbojpeg) can be optionally ignored, in which case OpenCV's imread() will be used to read the images. However the second step is a must.

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

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

这两部会创建用于配置路径的两个local.py,等下会提到

5. 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 can also download the networks using the gdown python package.

# Download the default network for DiMP-50 and DiMP-18
gdown https://drive.google.com/uc\?id\=1qgachgqks2UGjKx-GdO1qylBDdB1f9KN -O pytracking/networks/dimp50.pth
gdown https://drive.google.com/uc\?id\=1MAjrRJDCbL0DSjUKFyDkUuYS1-cYBNjk -O pytracking/networks/dimp18.pth

# Download the default network for ATOM
gdown https://drive.google.com/uc\?id\=1VNyr-Ds0khjM0zaq6lU-xfY74-iWxBvU -O pytracking/networks/atom_default.pth

# Download the default network for ECO
gdown https://drive.google.com/uc\?id\=1aWC4waLv_te-BULoy0k-n_zS-ONms21S -O pytracking/networks/resnet18_vggmconv1.pth

考虑到梯子问题,也可以自己下好,放到对应目录即可(对应位置同样可以查看local.py文件)

6.补全一些文件

我这边直接使用git的命令会缺失一些文件

github的issues里面有解决办法

git clone https://github.com/visionml/pytracking.git
cd pytracking
git submodule update --init

如果仍然报错,就需要挂梯子,或者手动下载,再加入目录里面

主要是这里的文件

7. 下载数据集并配置数据集位置

8.运行报错

Evaluating    1 trackers on     1 sequences
Tracker: atom default None ,  Sequence: Soccer
Setting up a new session...
../pytracking/features/featurebase.py:78: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  return TensorList([im_sz // s for s in self.stride()])
../pytracking/features/preprocessing.py:109: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  tl = posl - (szl - 1) // 2
../pytracking/features/preprocessing.py:110: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  br = posl + szl//2 + 1
/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  "See the documentation of nn.Upsample for details.".format(mode)
Using /home/admin312/.cache/torch_extensions/py37_cu113 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /home/admin312/.cache/torch_extensions/py37_cu113/_prroi_pooling/build.ninja...
Building extension module _prroi_pooling...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/3] :/usr/local/cuda-11.3/bin/nvcc  -DTORCH_EXTENSION_NAME=_prroi_pooling -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/TH -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.3/include -isystem /home/admin312/anaconda3/envs/pytracking/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/admin312/lzm_project/pytracking/pytracking/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu_impl.cu -o prroi_pooling_gpu_impl.cuda.o 
FAILED: prroi_pooling_gpu_impl.cuda.o 
:/usr/local/cuda-11.3/bin/nvcc  -DTORCH_EXTENSION_NAME=_prroi_pooling -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/TH -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.3/include -isystem /home/admin312/anaconda3/envs/pytracking/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/admin312/lzm_project/pytracking/pytracking/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu_impl.cu -o prroi_pooling_gpu_impl.cuda.o 
/bin/sh: 1: :/usr/local/cuda-11.3/bin/nvcc: not found
[2/3] c++ -MMD -MF prroi_pooling_gpu.o.d -DTORCH_EXTENSION_NAME=_prroi_pooling -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/TH -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.3/include -isystem /home/admin312/anaconda3/envs/pytracking/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /home/admin312/lzm_project/pytracking/pytracking/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu.c -o prroi_pooling_gpu.o 
FAILED: prroi_pooling_gpu.o 
c++ -MMD -MF prroi_pooling_gpu.o.d -DTORCH_EXTENSION_NAME=_prroi_pooling -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/TH -isystem /home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.3/include -isystem /home/admin312/anaconda3/envs/pytracking/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /home/admin312/lzm_project/pytracking/pytracking/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu.c -o prroi_pooling_gpu.o 
In file included from /home/admin312/lzm_project/pytracking/pytracking/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu.c:15:0:
/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:10: fatal error: cuda_runtime_api.h: 没有那个文件或目录
 #include 
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1723, in _run_ninja_build
    env=env)
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "run_tracker.py", line 65, in 
    main()
  File "run_tracker.py", line 61, in main
    args.threads, {'use_visdom': args.use_visdom, 'server': args.visdom_server, 'port': args.visdom_port})
  File "run_tracker.py", line 37, in run_tracker
    run_dataset(dataset, trackers, debug, threads, visdom_info=visdom_info)
  File "../pytracking/evaluation/running.py", line 199, in run_dataset
    run_sequence(seq, tracker_info, debug=debug, visdom_info=visdom_info)
  File "../pytracking/evaluation/running.py", line 148, in run_sequence
    output = tracker.run_sequence(seq, debug=debug, visdom_info=visdom_info)
  File "../pytracking/evaluation/tracker.py", line 148, in run_sequence
    output = self._track_sequence(tracker, seq, init_info)
  File "../pytracking/evaluation/tracker.py", line 186, in _track_sequence
    out = tracker.initialize(image, init_info)
  File "../pytracking/tracker/atom/atom.py", line 115, in initialize
    self.init_iou_net()
  File "../pytracking/tracker/atom/atom.py", line 694, in init_iou_net
    target_feat = self.iou_predictor.get_modulation(iou_backbone_features, target_boxes)
  File "../ltr/models/bbreg/atom_iou_net.py", line 157, in get_modulation
    roi3r = self.prroi_pool3r(c3_r, roi1)
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "../ltr/external/PreciseRoIPooling/pytorch/prroi_pool/prroi_pool.py", line 28, in forward
    return prroi_pool2d(features, rois, self.pooled_height, self.pooled_width, self.spatial_scale)
  File "../ltr/external/PreciseRoIPooling/pytorch/prroi_pool/functional.py", line 44, in forward
    _prroi_pooling = _import_prroi_pooling()
  File "../ltr/external/PreciseRoIPooling/pytorch/prroi_pool/functional.py", line 33, in _import_prroi_pooling
    verbose=True
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1136, in load
    keep_intermediates=keep_intermediates)
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1347, in _jit_compile
    is_standalone=is_standalone)
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1452, in _write_ninja_file_and_build_library
    error_prefix=f"Error building extension '{name}'")
  File "/home/admin312/anaconda3/envs/pytracking/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1733, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension '_prroi_pooling'

抓重点来看就是cuda的问题,cuda11真的万恶之源

我当时使用的是最新的cuda11.5,于是参照下面这篇帖子卸载重装了cuda11.4(因为之前11.3不行,pytorch1.10又只支持11.3以上)

  

9.torch需要降级

重装之后编译正常,但torch报错

pytracking框架 服务器端配置采坑(ubuntu18.04+cuda11.3)_第2张图片

由于这些是torch1.7中的写法,1.8以后不复存在,且网上搜了一通找不到替代品,在pytorch官网查了一下,1.7以上不不止rfft,1.7一下不支持cuda11,妙啊,夹缝中求生存

于是conda卸载重装pytorch1.7,cuda则安装cuda11.0与cuda11.4并存,这个教程很多了 

10.然后cuda11.0没办法编译PreciseRolPooling

就是那个  compute_86 的错误,之前指github issues里看到过这个错误,更到11.3版本后可解,很好,很好

好吧我暂时放弃了,过几天冷静了看看能不能手动改torch.rfft或者绕过去

参考链接

pytracking系列跟踪算法的配置(LWL, KYS, PrDiMP, DiMP and ATOM Trackers)(Ubuntu版本)_博博有个大大大的Dream-CSDN博客_pytracking训练

(5条消息) [Object Tracking][环境配置流程][Ubuntu16.04]ATOM【CVPR2019】pytracking_llzxz9628的博客-CSDN博客

Ubuntu之cuda11.4安装_月生的静心苑-CSDN博客

你可能感兴趣的:(单目标追踪,SOT,环境配置及基本操作,ubuntu,cuda,linux)