Custom implementation of Corrleation Module

Overview

PyPI

Pytorch Correlation module

this is a custom C++/Cuda implementation of Correlation module, used e.g. in FlowNetC

This tutorial was used as a basis for implementation, as well as NVIDIA's cuda code

  • Build and Install C++ and CUDA extensions by executing python setup.py install,
  • Benchmark C++ vs. CUDA by running python benchmark.py {cpu, cuda},
  • Run gradient checks on the code by running python grad_check.py --backend {cpu, cuda}.

Requirements

This module is expected to compile for Pytorch 1.6.

Installation

this module is available on pip

pip install spatial-correlation-sampler

For a cpu-only version, you can install from source with

python setup_cpu.py install

Known Problems

This module needs compatible gcc version and CUDA to be compiled. Namely, CUDA 9.1 and below will need gcc5, while CUDA 9.2 and 10.0 will need gcc7 See this issue for more information

Usage

API has a few difference with NVIDIA's module

  • output is now a 5D tensor, which reflects the shifts horizontal and vertical.
input (B x C x H x W) -> output (B x PatchH x PatchW x oH x oW)
  • Output sizes oH and oW are no longer dependant of patch size, but only of kernel size and padding
  • Patch size patch_size is now the whole patch, and not only the radii.
  • stride1 is now stride andstride2 is dilation_patch, which behave like dilated convolutions
  • equivalent max_displacement is then dilation_patch * (patch_size - 1) / 2.
  • dilation is a new parameter, it acts the same way as dilated convolution regarding the correlation kernel
  • to get the right parameters for FlowNetC, you would have
kernel_size=1
patch_size=21,
stride=1,
padding=0,
dilation=1
dilation_patch=2

Example

import torch
from spatial_correlation_sampler import SpatialCorrelationSampler, 

device = "cuda"
batch_size = 1
channel = 1
H = 10
W = 10
dtype = torch.float32

input1 = torch.randint(1, 4, (batch_size, channel, H, W), dtype=dtype, device=device, requires_grad=True)
input2 = torch.randint_like(input1, 1, 4).requires_grad_(True)

#You can either use the function or the module. Note that the module doesn't contain any parameter tensor.

#function

out = spatial_correlation_sample(input1,
	                         input2,
                                 kernel_size=3,
                                 patch_size=1,
                                 stride=2,
                                 padding=0,
                                 dilation=2,
                                 dilation_patch=1)

#module

correlation_sampler = SpatialCorrelationSampler(
    kernel_size=3,
    patch_size=1,
    stride=2,
    padding=0,
    dilation=2,
    dilation_patch=1)
out = correlation_sampler(input1, input2)

Benchmark

  • default parameters are from benchmark.py, FlowNetC parameters are same as use in FlowNetC with a batch size of 4, described in this paper, implemented here and here.
  • Feel free to file an issue to add entries to this with your hardware !

CUDA Benchmark

  • See here for a benchmark script working with NVIDIA's code, and Pytorch.
  • Benchmark are launched with environment variable CUDA_LAUNCH_BLOCKING set to 1.
  • Only float32 is benchmarked.
  • FlowNetC correlation parameters where launched with the following command:
CUDA_LAUNCH_BLOCKING=1 python benchmark.py --scale ms -k1 --patch 21 -s1 -p0 --patch_dilation 2 -b4 --height 48 --width 64 -c256 cuda -d float

CUDA_LAUNCH_BLOCKING=1 python NV_correlation_benchmark.py --scale ms -k1 --patch 21 -s1 -p0 --patch_dilation 2 -b4 --height 48 --width 64 -c256
implementation Correlation parameters device pass min time avg time
ours default 980 GTX forward 5.745 ms 5.851 ms
ours default 980 GTX backward 77.694 ms 77.957 ms
NVIDIA default 980 GTX forward 13.779 ms 13.853 ms
NVIDIA default 980 GTX backward 73.383 ms 73.708 ms
ours FlowNetC 980 GTX forward 26.102 ms 26.179 ms
ours FlowNetC 980 GTX backward 208.091 ms 208.510 ms
NVIDIA FlowNetC 980 GTX forward 35.363 ms 35.550 ms
NVIDIA FlowNetC 980 GTX backward 283.748 ms 284.346 ms

Notes

  • The overhead of our implementation regarding kernel_size > 1 during backward needs some investigation, feel free to dive in the code to improve it !
  • The backward pass of NVIDIA is not entirely correct when stride1 > 1 and kernel_size > 1, because not everything is computed, see here.

CPU Benchmark

  • No other implementation is avalaible on CPU.
  • It is obviously not recommended to run it on CPU if you have a GPU.
Correlation parameters device pass min time avg time
default E5-2630 v3 @ 2.40GHz forward 159.616 ms 188.727 ms
default E5-2630 v3 @ 2.40GHz backward 282.641 ms 294.194 ms
FlowNetC E5-2630 v3 @ 2.40GHz forward 2.138 s 2.144 s
FlowNetC E5-2630 v3 @ 2.40GHz backward 7.006 s 7.075 s
Comments
  • Error running module on GPU

    Error running module on GPU

    Hi Clement, I have been using your spatial-correlation-sampler. When I run python grad_check cpu it returns 'ok' but with backend option set as cuda, I get the following error:

    Traceback (most recent call last): File "grad_check.py", line 41, in if gradcheck(correlation_sampler, [input1, input2]): File "/home/bowen/anaconda3/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 190, in gradcheck output = _differentiable_outputs(func(inputs)) File "/home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler/spatial_correlation_sampler.py", line 73, in forward dH, dW) RuntimeError: sizes must be non-negative (THCTensor_resizeNd at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCTensor.cpp:108) frame #0: THCudaDoubleTensor_newWithStorage + 0xfa (0x7fe7c042c9aa in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so) frame #1: at::CUDADoubleType::th_tensor(at::ArrayRef) const + 0xa5 (0x7fe7c02cf4e5 in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so) frame #2: at::native::tensor(at::Type const&, at::ArrayRef) + 0x3a (0x7fe7e34c37da in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/lib/libcaffe2.so) frame #3: at::Type::tensor(at::ArrayRef) const + 0x9 (0x7fe7e36b1b69 in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/lib/libcaffe2.so) frame #4: torch::autograd::VariableType::tensor(at::ArrayRef) const + 0x44 (0x7fe7e5333d04 in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so) frame #5: at::native::zeros(at::ArrayRef, at::TensorOptions const&) + 0x31 (0x7fe7e351a651 in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/lib/libcaffe2.so) frame #6: + 0x231f9 (0x7fe7bca6e1f9 in /home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so) frame #7: correlation_cuda_forward(at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int) + 0x167 (0x7fe7bca6f204 in /home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so) frame #8: correlation_sample_forward(at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int) + 0x1b4 (0x7fe7bca60ed4 in /home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so) frame #9: + 0x217b9 (0x7fe7bca6c7b9 in /home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so) frame #10: + 0x1fc2d (0x7fe7bca6ac2d in /home/bowen/anaconda3/lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so) frame #18: THPFunction_do_forward(THPFunction, _object*) + 0x2ad (0x7fe7e5310fbd in /home/bowen/anaconda3/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so) frame #35: __libc_start_main + 0xf5 (0x7fe7f9c8af45 in /lib/x86_64-linux-gnu/libc.so.6)

    I also tried to pass some tensors into the module in the console. Calling forward and backward seems to be fine as long as computation is on cpu. The module crashes once I put the same tensor on GPU.

    Code is running on Ubuntu 14.04. I am using anaconda python 3.6.5. My pytorch version is 0.4.1. And I am using CUDA 9.0.

    It is worth mentioning that I had trouble installing the code, as I later discovered that nvcc is using gcc-6.0 which is incompatible with my CUDA 9.0 and I redirected the softlink to gcc-4.9. By doing this I am able to compile and install. Not sure if it is related to this crash.

    Please let me know what you think. Thank you!

    bug help wanted 
    opened by BK1024 23
  • install with CUDA11

    install with CUDA11

    Hello, I wonder if there is a way to install "spatial-correlation-sampler" with CUDA11. Because the 3090/3080 GPUs only support CUDA11. Thank you!

    opened by PinxueGuo 14
  • Building wheel for spatial-correlation-sampler (setup.py) ... error

    Building wheel for spatial-correlation-sampler (setup.py) ... error

    Hello

    I have problem with:

    Building wheel for spatial-correlation-sampler (setup.py) ... error

    I need whl file for spatial-correlation-sampler package. I have win 10, python 3.7.3, CUDA 9.2 and GCC 7.4

    Please help?

    The whole error message:

    (base) C:\WINDOWS\system32>pip install spatial-correlation-sampler Collecting spatial-correlation-sampler Using cached https://files.pythonhosted.org/packages/a6/d1/aa0a71739ce998f655286d966c0ad7aff765648431c054c34db7d58b811b/spatial_correlation_sampler-0.1.0.tar.gz Requirement already satisfied: torch>=1.0.1 in c:\anaconda3\lib\site-packages (from spatial-correlation-sampler) (1.1.0) Requirement already satisfied: numpy in c:\anaconda3\lib\site-packages (from spatial-correlation-sampler) (1.16.2) Building wheels for collected packages: spatial-correlation-sampler Building wheel for spatial-correlation-sampler (setup.py) ... error Complete output from command C:\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Boris\AppData\Local\Temp\pip-install-f4ekhfs9\spatial-correlation-sampler\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\Boris\AppData\Local\Temp\pip-wheel-qrk0s874 --python-tag cp37: running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler\spatial_correlation_sampler.py -> build\lib.win-amd64-3.7\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler_init_.py -> build\lib.win-amd64-3.7\spatial_correlation_sampler running build_ext building 'spatial_correlation_sampler_backend' extension creating build\temp.win-amd64-3.7 creating build\temp.win-amd64-3.7\Release creating build\temp.win-amd64-3.7\Release\Correlation_Module C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Anaconda3\lib\site-packages\torch\include -IC:\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Anaconda3\lib\site-packages\torch\include\TH -IC:\Anaconda3\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include" -IC:\Anaconda3\include -IC:\Anaconda3\include /EHsc /TpCorrelation_Module\correlation.cpp /Fobuild\temp.win-amd64-3.7\Release\Correlation_Module\correlation.obj -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 /MD cl : Command line warning D9002 : ignoring unknown option '-fopenmp' correlation.cpp C:\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include\torch/cuda.h(5): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' failed with exit status 2


    Failed building wheel for spatial-correlation-sampler Running setup.py clean for spatial-correlation-sampler Failed to build spatial-correlation-sampler Installing collected packages: spatial-correlation-sampler Running setup.py install for spatial-correlation-sampler ... error Complete output from command C:\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Boris\AppData\Local\Temp\pip-install-f4ekhfs9\spatial-correlation-sampler\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Boris\AppData\Local\Temp\pip-record-j38ydtlr\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler\spatial_correlation_sampler.py -> build\lib.win-amd64-3.7\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler_init_.py -> build\lib.win-amd64-3.7\spatial_correlation_sampler running build_ext building 'spatial_correlation_sampler_backend' extension creating build\temp.win-amd64-3.7 creating build\temp.win-amd64-3.7\Release creating build\temp.win-amd64-3.7\Release\Correlation_Module C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Anaconda3\lib\site-packages\torch\include -IC:\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Anaconda3\lib\site-packages\torch\include\TH -IC:\Anaconda3\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include" -IC:\Anaconda3\include -IC:\Anaconda3\include /EHsc /TpCorrelation_Module\correlation.cpp /Fobuild\temp.win-amd64-3.7\Release\Correlation_Module\correlation.obj -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 /MD cl : Command line warning D9002 : ignoring unknown option '-fopenmp' correlation.cpp C:\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include\torch/cuda.h(5): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' failed with exit status 2

    ----------------------------------------
    

    Command "C:\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Boris\AppData\Local\Temp\pip-install-f4ekhfs9\spatial-correlation-sampler\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Boris\AppData\Local\Temp\pip-record-j38ydtlr\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Boris\AppData\Local\Temp\pip-install-f4ekhfs9\spatial-correlation-sampler\

    (base) C:\WINDOWS\system32>$ conda install -c https://conda.anaconda.org/conda-forge spatial-correlation-sampler '$' is not recognized as an internal or external command, operable program or batch file.

    (base) C:\WINDOWS\system32>conda install -c https://conda.anaconda.org/conda-forge spatial-correlation-sampler WARNING conda.base.context:use_only_tar_bz2(632): Conda is constrained to only using the old .tar.bz2 file format because you have conda-build installed, and it is <3.18.3. Update or remove conda-build to get smaller downloads and faster extractions. Collecting package metadata (repodata.json): done Solving environment: failed

    PackagesNotFoundError: The following packages are not available from current channels:

    • spatial-correlation-sampler

    Current channels:

    • https://conda.anaconda.org/conda-forge/win-64
    • https://conda.anaconda.org/conda-forge/noarch
    • https://repo.anaconda.com/pkgs/main/win-64
    • https://repo.anaconda.com/pkgs/main/noarch
    • https://repo.anaconda.com/pkgs/r/win-64
    • https://repo.anaconda.com/pkgs/r/noarch
    • https://repo.anaconda.com/pkgs/msys2/win-64
    • https://repo.anaconda.com/pkgs/msys2/noarch

    To search for alternate channels that may provide the conda package you're looking for, navigate to

    https://anaconda.org
    

    and use the search bar at the top of the page.

    (base) C:\WINDOWS\system32>

    opened by BobYa1 12
  • Can I use pytorch==1.1 to install?

    Can I use pytorch==1.1 to install?

    Hello,because of my cuda driver is not suit for pytorch1.2, and I can not update the service cuda driver version. So, if I use pytorch1.1, shall I modify some code? I have test 1.1 version, and there is some unkown error.

    opened by CXMANDTXW 11
  • python benchmark.py try to allocate  cuda memory 9177984325.83 GiB

    python benchmark.py try to allocate cuda memory 9177984325.83 GiB

    when I try to run benchmark.py, it raise an error says that RuntimeError: CUDA out of memory. Tried to allocate 9177984325.83 GiB (GPU 0; 5.93 GiB total capacity; 78.25 MiB already allocated; 4.44 GiB free; 0 bytes cached) (malloc at /pytorch/aten/src/THC/THCCachingAllocator.cpp:231)

    here is my environments: pytorch 1.0 cuda9.0

    Is something wrong? thanks a lot.

    opened by hailsham 11
  • Having problem in installing

    Having problem in installing "spatial-correlation-sampler"

    Dear friend, I have met problem during installing "spatial-correlation-sampler" when I used "pip install spatial-correlation-sampler". My environment is : python==3.6.8; cuda==9.0; pytorch=1.0.1(but it has been updated to 1.8.1 automatically during installing) gcc=5.4.0. Could you help me with the installation please? Here is the Error infomation: (MotionSqueeze) lj@1080ti:~/Examples$ CC=gcc-5 CXX=g++-5 pip install spatial-correlation-sampler Collecting spatial-correlation-sampler Using cached https://files.pythonhosted.org/packages/73/99/fbfcb914944c390e59aefd29c17fba2dd7d647a8b58385ca39ed0a32765f/spatial_correlation_sampler-0.3.0.tar.gz Requirement already satisfied: torch>=1.1 in /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages (from spatial-correlation-sampler) (1.8.1) Requirement already satisfied: numpy in /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages (from spatial-correlation-sampler) (1.17.2) Requirement already satisfied: dataclasses; python_version < "3.7" in /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages (from torch>=1.1->spatial-correlation-sampler) (0.8) Requirement already satisfied: typing-extensions in /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages (from torch>=1.1->spatial-correlation-sampler) (3.7.4.3) Building wheels for collected packages: spatial-correlation-sampler Building wheel for spatial-correlation-sampler (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/lj/software/anaconda3/envs/MotionSqueeze/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"'; file='"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-967jjy22 --python-tag cp36 cwd: /tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/ Complete output (55 lines): /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:109.) return torch._C._cuda_getDeviceCount() > 0 No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-9.0' running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/spatial_correlation_sampler copying Correlation_Module/spatial_correlation_sampler/init.py -> build/lib.linux-x86_64-3.6/spatial_correlation_sampler copying Correlation_Module/spatial_correlation_sampler/spatial_correlation_sampler.py -> build/lib.linux-x86_64-3.6/spatial_correlation_sampler running build_ext Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py", line 57, in launch_setup() File "/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py", line 52, in launch_setup "Topic :: Scientific/Engineering :: Artificial Intelligence" File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/setuptools/init.py", line 145, in setup return distutils.core.setup(**attrs) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/core.py", line 148, in setup dist.run_commands() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 192, in run self.run_command('build') File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 84, in run _build_ext.run(self) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/command/build_ext.py", line 339, in run self.build_extensions() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 378, in build_extensions self._check_abi() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 734, in _check_abi check_compiler_abi_compatibility(compiler) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 282, in check_compiler_abi_compatibility if not check_compiler_ok_for_platform(compiler): File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 242, in check_compiler_ok_for_platform which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['which', 'g++-5']' returned non-zero exit status 1.

    ERROR: Failed building wheel for spatial-correlation-sampler Running setup.py clean for spatial-correlation-sampler Failed to build spatial-correlation-sampler Installing collected packages: spatial-correlation-sampler Running setup.py install for spatial-correlation-sampler ... error ERROR: Command errored out with exit status 1: command: /home/lj/software/anaconda3/envs/MotionSqueeze/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"'; file='"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-0z5c3sl4/install-record.txt --single-version-externally-managed --compile cwd: /tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/ Complete output (57 lines): /home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:109.) return torch._C._cuda_getDeviceCount() > 0 No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-9.0' running install running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/spatial_correlation_sampler copying Correlation_Module/spatial_correlation_sampler/init.py -> build/lib.linux-x86_64-3.6/spatial_correlation_sampler copying Correlation_Module/spatial_correlation_sampler/spatial_correlation_sampler.py -> build/lib.linux-x86_64-3.6/spatial_correlation_sampler running build_ext Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py", line 57, in launch_setup() File "/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py", line 52, in launch_setup "Topic :: Scientific/Engineering :: Artificial Intelligence" File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/setuptools/init.py", line 145, in setup return distutils.core.setup(**attrs) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/core.py", line 148, in setup dist.run_commands() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run return orig.install.run(self) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/command/install.py", line 545, in run self.run_command('build') File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 84, in run _build_ext.run(self) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/distutils/command/build_ext.py", line 339, in run self.build_extensions() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 378, in build_extensions self._check_abi() File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 734, in _check_abi check_compiler_abi_compatibility(compiler) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 282, in check_compiler_abi_compatibility if not check_compiler_ok_for_platform(compiler): File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 242, in check_compiler_ok_for_platform which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT) File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/home/lj/software/anaconda3/envs/MotionSqueeze/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['which', 'g++-5']' returned non-zero exit status 1. ---------------------------------------- ERROR: Command errored out with exit status 1: /home/lj/software/anaconda3/envs/MotionSqueeze/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"'; file='"'"'/tmp/pip-install-3kl5fqr4/spatial-correlation-sampler/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-0z5c3sl4/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

    opened by XiaoXueHou 10
  • undefined symbol: _ZTIN3c1021Auto

    undefined symbol: _ZTIN3c1021Auto

    Hey, I got This error when I want to run: import spatial_correlation_sampler_backend as correlation

    "pip install spatial-correlation-sampler", passes. And then, when I import it in python,

    from spatial_correlation_sampler import spatial_correlation_sample

    lib/python3.6/site-packages/spatial_correlation_sampler_backend.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

    pytorch 1.0.1.post2 gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) Cuda compilation tools, release 10.0, V10.0.130

    opened by babahaji 10
  • Build error when using pytorch 1.7

    Build error when using pytorch 1.7

    When I upgraded to a RTX 3090 graphics card, I had to use cuda11 and the latest official version of PyTorch 1.7.

    System Info: I9 9900K RTX3090 NVIDIA-Linux-x86_64-455.23.04.run cuda_11.1.1_455.32.00_linux.run cudnn-11.1-linux-x64-v8.0.4.30.tgz Python 3.8 (Anaconda3-2020.07-Linux-x86_64.sh) Pytorch 1.7

    The following error (is too long, there is only the last part) occurred while reinstalling this library from pip:

    pip install spatial_correlation_sampler==0.3.0
    
    ....
    /tmp/tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected ‘)’ before ‘float’
        tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:1:28: error: reference to ‘_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e’ is ambiguous
        Correlation_Module/correlation_cuda_kernel.cu:20:11: note: candidates are: namespace _GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e { }
         namespace {
                   ^
        /home1/user/anaconda3/lib/python3.8/site-packages/torch/include/ATen/Functions.h:1518:11: note:                 namespace at::_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e { }
         namespace {
                   ^
        In file included from /tmp/tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:8:0,
                         from tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:1:
        /tmp/tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected primary-expression before ‘double’
         static void __nv_cudaEntityRegisterCallback(void **__T672){__nv_dummy_param_ref(__T672);__nv_save_fatbinhandle_for_managed_rt(__T672);__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIN3c104HalfELm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input2IN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS3_17RestrictPtrTraitsEiEENS4_IS5_Lm4ES6_iEES8_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIN3c104HalfELm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input1IN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS3_17RestrictPtrTraitsEiEENS4_IS5_Lm4ES6_iEES8_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIfLm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2<float> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input2IfEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIfLm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1<float> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input1IfEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIdLm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2<double> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input2IdEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIdLm5ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1<double> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e39correlation_cuda_backward_kernel_input1IdEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIN3c104HalfELm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIN3c104HalfELm5ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e31correlation_cuda_forward_kernelIN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS3_17RestrictPtrTraitsEiEES7_NS4_IS5_Lm5ES6_iEEiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIfLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIfLm5ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel<float> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e31correlation_cuda_forward_kernelIfEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS1_17RestrictPtrTraitsEiEES5_NS2_IS3_Lm5ES4_iEEiiiiiiiiii, (-1));__cudaRegisterEntry(__T672, ((void ( *)(const _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, const _ZN2at20PackedTensorAccessorIdLm4ENS_17RestrictPtrTraitsEiEE, _ZN2at20PackedTensorAccessorIdLm5ENS_17RestrictPtrTraitsEiEE, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel<double> ), _ZN82_GLOBAL__N__58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e31correlation_cuda_forward_kernelIdEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS1_17RestrictPtrTraitsEiEES5_NS2_IS3_Lm5ES4_iEEiiiiiiiiii, (-1));__cudaRegisterVariable(__T672, __shadow_var(_ZN80_INTERNAL_58_tmpxft_00004720_00000000_7_correlation_cuda_kernel_cpp1_ii_90c2133e6thrust6system6detail10sequential3seqE,::thrust::system::detail::sequential::seq), 0, 1UL, 0, 0);}
    /tmp/tmpxft_00004720_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected ‘)’ before ‘double’
        error: command '/usr/local/cuda-11.1/bin/nvcc' failed with exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /home1/user/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ytagkuw8/spatial-correlation-sampler/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ytagkuw8/spatial-correlation-sampler/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-41m2pf99/install-record.txt --single-version-externally-managed --compile --install-headers /home1/user/anaconda3/include/python3.8/spatial-correlation-sampler Check the logs for full command output.
    

    I also tested installing 0.2.1 and 0.2.0 using pip and returned the same error.

    In addition, I try to install through source code compilation following the README.

    python setup.py install
    
    /tmp/tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected ‘)’ before ‘float’
    tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:1:28: error: reference to ‘_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c’ is ambiguous
    Correlation_Module/correlation_cuda_kernel.cu:20:11: note: candidates are: namespace _GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c { }
     namespace {
               ^                                                                                 
    /home1/user/anaconda3/lib/python3.8/site-packages/torch/include/ATen/Functions.h:1518:11: note:                 namespace at::_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c { }
     namespace {
               ^                                                                                 
    In file included from /tmp/tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:8:0,
                     from tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:1:
    /tmp/tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected primary-expression before ‘double’
     static void __nv_cudaEntityRegisterCallback(void **__T684){__nv_dummy_param_ref(__T684);__nv_save_fatbinhandle_for_managed_rt(__T684);__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IN3c104HalfELm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input2IN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS3_17RestrictPtrTraitsEiEENS4_IS5_Lm4ES6_iEES8_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IN3c104HalfELm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input1IN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS3_17RestrictPtrTraitsEiEENS4_IS5_Lm4ES6_iEES8_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IfLm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2<float> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input2IfEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IfLm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1<float> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input1IfEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IdLm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input2<double> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input2IdEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IdLm5ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int, const int))_NV_ANON_NAMESPACE::correlation_cuda_backward_kernel_input1<double> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c39correlation_cuda_backward_kernel_input1IdEEvN2at27GenericPackedTensorAccessorIT_Lm5ENS1_17RestrictPtrTraitsEiEENS2_IS3_Lm4ES4_iEES6_iiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IN3c104HalfELm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IN3c104HalfELm5ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel< ::c10::Half> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c31correlation_cuda_forward_kernelIN3c104HalfEEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS3_17RestrictPtrTraitsEiEES7_NS4_IS5_Lm5ES6_iEEiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IfLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IfLm5ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel<float> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c31correlation_cuda_forward_kernelIfEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS1_17RestrictPtrTraitsEiEES5_NS2_IS3_Lm5ES4_iEEiiiiiiiiiiii, (-1));__cudaRegisterEntry(__T684, ((void ( *)(const _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, const _ZN2at22PackedTensorAccessor32IdLm4ENS_17RestrictPtrTraitsEEE, _ZN2at22PackedTensorAccessor32IdLm5ENS_17RestrictPtrTraitsEEE, int, int, int, int, int, int, int, int, int, int, int, int))_NV_ANON_NAMESPACE::correlation_cuda_forward_kernel<double> ), _ZN82_GLOBAL__N__58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c31correlation_cuda_forward_kernelIdEEvN2at27GenericPackedTensorAccessorIT_Lm4ENS1_17RestrictPtrTraitsEiEES5_NS2_IS3_Lm5ES4_iEEiiiiiiiiiiii, (-1));__cudaRegisterVariable(__T684, __shadow_var(_ZN80_INTERNAL_58_tmpxft_00003dbc_00000000_7_correlation_cuda_kernel_cpp1_ii_04f3d18c6thrust6system6detail10sequential3seqE,::thrust::system::detail::sequential::seq), 0, 1UL, 0, 0);}
     
    /tmp/tmpxft_00003dbc_00000000-6_correlation_cuda_kernel.cudafe1.stub.c:55:0: error: expected ‘)’ before ‘double’
    error: command '/usr/local/cuda-11.1/bin/nvcc' failed with exit status 1
    

    It looks like the same error as pip.

    In order to determine where the problem is, I tried to install Pytorch 1.7 on a 2080ti computer, and the same error occurred when compiling this library. It uses cuda10.0 and python 3.8. However, using Pytorch 1.6 can install this library normally. My guess is that this error was introduced in the latest version of Pytorch 1.7.

    I hope I can get your help, Thanks!

    opened by danqu130 8
  • Compilation error on Windows

    Compilation error on Windows

    Hello, I'm trying to install this python library on Windows (I know, support is not guaranteed). I'm having a problem related to CUDA, here is the error message:

    1 error detected in the compilation of "C:/Users/root/AppData/Local/Temp/tmpxft_0000a540_00000000-10_correlation_cuda_kernel.cpp1.ii".
    correlation_cuda_kernel.cu
    error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.0\\bin\\nvcc.exe' failed with exit status 1
    

    I don't understand why it keeps trying to use CUDA 10.0. In my path environment variable, the CUDA 9.2 is listed before CUDA 10.0 and my pytorch has been installed with CUDA 9.0 (because it won't install for CUDA 9.2, I don't know if this may cause a problem). I've read in other discussions that the CUDA version must be compatible with the gcc version, but I don't know mine and I don't know how to find it.

    What should I do?

    opened by RaphaelRoyerRivard 8
  • error python setup.py install

    error python setup.py install

    Hi, My torch version 1.0.1. When I run python setup.py install, there are some outputs:

    torch-version 1.0.1.post2 running install running bdist_egg running egg_info writing Correlation_Module/spatial_correlation_sampler.egg-info/PKG-INFO writing dependency_links to Correlation_Module/spatial_correlation_sampler.egg-info/dependency_links.txt writing requirements to Correlation_Module/spatial_correlation_sampler.egg-info/requires.txt writing top-level names to Correlation_Module/spatial_correlation_sampler.egg-info/top_level.txt reading manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' writing manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py running build_ext building 'spatial_correlation_sampler_backend' extension gcc -pthread -B /media/data2/xly/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/torch/csrc/api/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/TH -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/media/data2/xly/anaconda3/include/python3.7m -c Correlation_Module/correlation.cpp -o build/temp.linux-x86_64-3.7/Correlation_Module/correlation.o -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ gcc -pthread -B /media/data2/xly/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/torch/csrc/api/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/TH -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/media/data2/xly/anaconda3/include/python3.7m -c Correlation_Module/correlation_sampler.cpp -o build/temp.linux-x86_64-3.7/Correlation_Module/correlation_sampler.o -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ /usr/local/cuda/bin/nvcc -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/torch/csrc/api/include -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/TH -I/media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/media/data2/xly/anaconda3/include/python3.7m -c Correlation_Module/correlation_cuda_kernel.cu -o build/temp.linux-x86_64-3.7/Correlation_Module/correlation_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --compiler-options '-fPIC' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning). /media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/torch/csrc/jit/argument_spec.h(59): error: static assertion failed with "ArgumentInfo is to be a POD struct"

    /media/data2/xly/anaconda3/lib/python3.7/site-packages/torch/lib/include/pybind11/cast.h(1877): warning: nonstandard use of "auto" to both deduce the type from an initializer and to announce a trailing return type

    1 error detected in the compilation of "/tmp/tmpxft_00004282_00000000-7_correlation_cuda_kernel.cpp1.ii". error: command '/usr/local/cuda/bin/nvcc' failed with exit status 2

    opened by xuleyoung 8
  • clang: error: unsupported option '-fopenmp'

    clang: error: unsupported option '-fopenmp'

    Thanks for your valuable work! And I got this error when I find python setup_cpu.py install on my MacBook pro without Cuda. Does it need Cuda installed when I just want to use it on CPU?(I have installed GCC)

    opened by shankyle 7
  • failed to python setup.py install

    failed to python setup.py install

    hi, there are something went wrong and i can't figure it out.

    python setup.py install running install running bdist_egg running egg_info writing Correlation_Module/spatial_correlation_sampler.egg-info/PKG-INFO writing dependency_links to Correlation_Module/spatial_correlation_sampler.egg-info/dependency_links.txt writing requirements to Correlation_Module/spatial_correlation_sampler.egg-info/requires.txt writing top-level names to Correlation_Module/spatial_correlation_sampler.egg-info/top_level.txt reading manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' adding license file 'LICENSE' writing manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py running build_ext building 'spatial_correlation_sampler_backend' extension gcc -pthread -B /home/gx115/SoftWares/anaconda3/envs/MS/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_CUDA -I/home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include -I/home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include -I/home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/TH -I/home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/gx115/SoftWares/anaconda3/envs/MS/include/python3.6m -c Correlation_Module/correlation.cpp -o build/temp.linux-x86_64-3.6/Correlation_Module/correlation.o -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:9:0, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/torch/extension.h:4, from Correlation_Module/correlation.cpp:1: Correlation_Module/correlation.cpp: In lambda function: Correlation_Module/correlation.cpp:102:56: error: invalid initialization of reference of type ‘const at::Type&’ from expression of type ‘c10::ScalarType’ AT_DISPATCH_FLOATING_TYPES(input1.scalar_type(), "correlation_forward_cpp", ([&] { ~~~~~~~~~~~~~~~~~~^~ /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/ATen/Dispatch.h:15:32: note: in definition of macro ‘AT_DISPATCH_FLOATING_TYPES’ const at::Type& the_type = TYPE;
    ^~~~ Correlation_Module/correlation.cpp: In lambda function: Correlation_Module/correlation.cpp:150:52: error: invalid initialization of reference of type ‘const at::Type&’ from expression of type ‘c10::ScalarType’ AT_DISPATCH_FLOATING_TYPES(input1.scalar_type(), "correlation_backward_cpp", ([&] { ~~~~~~~~~~~~~~~~~~^~ /home/gx115/SoftWares/anaconda3/envs/MS/lib/python3.6/site-packages/torch/lib/include/ATen/Dispatch.h:15:32: note: in definition of macro ‘AT_DISPATCH_FLOATING_TYPES’ const at::Type& the_type = TYPE;
    ^~~~ error: command 'gcc' failed with exit status 1

    opened by ChuLinTang 0
  • Compile once and run on other GPU(different computational capacities)

    Compile once and run on other GPU(different computational capacities)

    Hi,

    Thanks for this nice implementation, it brings convenient to our project.

    I have slightly modify the setup.py script to compile for multiple GPU_CCs. And I belief it would benefit for someone. In our case, we develop the prototype on local computer with desktop GPU, e.g. GTX1060, with small batch size. Then for tuning the model, we switch to datacenter where leverages Containers for fast deploy, and they offent suggest users not to compile code in the container since security issues. Using the original setup.py script, we have to re-compile for different GPU CCs. The following is my modification, I have tested for RTX 2070(CC=7.5), GTX1080(CC=6.1), V100(CC=7.0). And last, I provide my Dockerfile for quick reproduce.

    from setuptools import setup
    from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
    from os.path import join
    
    CPU_ONLY = False
    project_root = 'Correlation_Module'
    
    source_files = ['correlation.cpp', 'correlation_sampler.cpp']
    
    cxx_args = ['-std=c++14', '-fopenmp']
    nvcc_args = [
        '-gencode', 'arch=compute_50,code=sm_50',
        '-gencode', 'arch=compute_52,code=sm_52',
        '-gencode', 'arch=compute_60,code=sm_60',
        '-gencode', 'arch=compute_61,code=sm_61',
        '-gencode', 'arch=compute_70,code=sm_70',
        '-gencode', 'arch=compute_70,code=compute_70',
        '-gencode', 'arch=compute_75,code=compute_75',
        '-gencode', 'arch=compute_75,code=sm_75'
    ]
    
    with open("README.md", "r") as fh:
        long_description = fh.read()
    
    
    def launch_setup():
        if CPU_ONLY:
            Extension = CppExtension
            macro = []
        else:
            Extension = CUDAExtension
            source_files.append('correlation_cuda_kernel.cu')
            macro = [("USE_CUDA", None)]
    
        sources = [join(project_root, file) for file in source_files]
    
        setup(
            name='spatial_correlation_sampler',
            version="0.3.0",
            author="Clément Pinard",
            author_email="[email protected]",
            description="Correlation module for pytorch",
            long_description=long_description,
            long_description_content_type="text/markdown",
            url="https://github.com/ClementPinard/Pytorch-Correlation-extension",
            install_requires=['torch>=1.1', 'numpy'],
            ext_modules=[
                Extension('spatial_correlation_sampler_backend',
                          sources,
                          define_macros=macro,
                          extra_compile_args={'cxx': ['-fopenmp'], 'nvcc':nvcc_args},
                          extra_link_args=['-lgomp'])
            ],
            package_dir={'': project_root},
            packages=['spatial_correlation_sampler'],
            cmdclass={
                'build_ext': BuildExtension
            },
            classifiers=[
                "Programming Language :: Python :: 3",
                "License :: OSI Approved :: MIT License",
                "Operating System :: POSIX :: Linux",
                "Intended Audience :: Science/Research",
                "Topic :: Scientific/Engineering :: Artificial Intelligence"
            ])
    
    
    if __name__ == '__main__':
        launch_setup()
    

    Dockerfile

    FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
    
    RUN apt update -y
    
    # install python
    RUN apt-get install software-properties-common -y && \
        add-apt-repository ppa:deadsnakes/ppa -y && \
        apt-get update && \
        apt-get install python3.6 -y && \
        ln -s /usr/bin/python3 /usr/bin/python 
    
    # install pip
    RUN apt install python3-pip -y && \
        ln -s /usr/bin/pip3 /usr/bin/pip && \
        python -m pip install -U --force-reinstall pip
    
    # install dependencies
    RUN python -m pip install requests tqdm && \
        pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html && \
        apt install git vim -y
    
    # install spatial correlation sampler
    RUN git clone https://github.com/JiaMingLin/Pytorch-Correlation-extension.git && \
        cd Pytorch-Correlation-extension && \
        python setup.py install && \
        cd ..
    
    opened by JiaMingLin 1
  • Get slower after using correlation extension

    Get slower after using correlation extension

    Hello, I find it get slower after using SpatialCorrelationSampler (from 0.647 to 0.832 to run a iteration). Do you know then possible problems? Maybe it is the cuda(11.4) or cudnn(8.2.4) problem?

    opened by RongchangLi 1
  • Parameters for correlation

    Parameters for correlation

    Hello,

    I'm trying to make the following code work on Collab:https://github.com/ZhenboSong/mono_velocity/blob/master/train_crop_velocity.py But since I can't install their Correlation function. self.corr = Correlation(pad_size=md, kernel_size=1, max_displacement=md, stride1=1, stride2=1, corr_multiply=1)

    I found myself using your SpatialCorrelationSampler. I need help figuring which parameter values to use to make the output of the correlation between two tensors of shape [8, 196, 6, 7] to be of size [128,81,3,3]. Now using the following definition for the correlation: self.corr = SpatialCorrelationSampler(kernel_size=1, patch_size=2*md+1, stride=1, padding=0, dilation_patch=1) I get an output with shape: torch.Size([8, 9, 9, 6, 7])

    Do you have any clue to what's happening?

    Thank you for your time,

    opened by marcbo12 1
  • System requirements to install spatial-correlation-sampler

    System requirements to install spatial-correlation-sampler

    I can't install the spatial-correlation-sampler on my remote gpu server. I have the following constraints:

    • Nvidia driver >= 460.27.03
    • OS: Fedora release >= 32

    Has someone successfully installed the sampler with these specs? If yes, which Python, torch, cuda, gcc and g++ versions are you using? I have tried (not working) with:

    • Python 3.9.7
    • torch 1.9.0
    • cuda 10.2
    • gcc: 10.3.1
    • g++: 10.3.1
    opened by phil-slz 0
  • Faile to install spatial-correlation-sampler

    Faile to install spatial-correlation-sampler

    Hi, my env is: python 3.8 pytorch 1.8.0 cudatoolkit 11.4 torchvision 0.9.0 gcc 9.3.0

    I tried commands: pip install spatial-correlation-sampler The result is:

    (torch18) rongchang@BETA:~/extent_tools/Pytorch-Correlation-extension-master$ pip install spatial-correlation-sampler
    Defaulting to user installation because normal site-packages is not writeable
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    WARNING: Keyring is skipped due to an exception: Failed to unlock the collection!
    Collecting spatial-correlation-sampler
      Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/99/fbfcb914944c390e59aefd29c17fba2dd7d647a8b58385ca39ed0a32765f/spatial_correlation_sampler-0.3.0.tar.gz (8.6 kB)
    Requirement already satisfied: torch>=1.1 in /data/Disk_A/rongchang/.local/lib/python3.8/site-packages (from spatial-correlation-sampler) (1.8.0+cu111)
    Requirement already satisfied: numpy in /usr/local/anaconda3/lib/python3.8/site-packages (from spatial-correlation-sampler) (1.20.1)
    Requirement already satisfied: typing-extensions in /usr/local/anaconda3/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (3.7.4.3)
    Building wheels for collected packages: spatial-correlation-sampler
      Building wheel for spatial-correlation-sampler (setup.py) ... error
      ERROR: Command errored out with exit status 1:
       command: /usr/local/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-_np2padi
           cwd: /tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/
      Complete output (54 lines):
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/spatial_correlation_sampler
      copying Correlation_Module/spatial_correlation_sampler/spatial_correlation_sampler.py -> build/lib.linux-x86_64-3.8/spatial_correlation_sampler
      copying Correlation_Module/spatial_correlation_sampler/__init__.py -> build/lib.linux-x86_64-3.8/spatial_correlation_sampler
      running build_ext
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py", line 57, in <module>
          launch_setup()
        File "/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py", line 25, in launch_setup
          setup(
        File "/usr/local/anaconda3/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/local/anaconda3/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/usr/local/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/local/anaconda3/lib/python3.8/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/usr/local/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/local/anaconda3/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/usr/local/anaconda3/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
          _build_ext.build_ext.run(self)
        File "/usr/local/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 340, in run
          self.build_extensions()
        File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 378, in build_extensions
          self._check_abi()
        File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 734, in _check_abi
          check_compiler_abi_compatibility(compiler)
        File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 282, in check_compiler_abi_compatibility
          if not check_compiler_ok_for_platform(compiler):
        File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 242, in check_compiler_ok_for_platform
          which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
        File "/usr/local/anaconda3/lib/python3.8/subprocess.py", line 415, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        File "/usr/local/anaconda3/lib/python3.8/subprocess.py", line 516, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1.
      ----------------------------------------
      ERROR: Failed building wheel for spatial-correlation-sampler
      Running setup.py clean for spatial-correlation-sampler
    Failed to build spatial-correlation-sampler
    Installing collected packages: spatial-correlation-sampler
        Running setup.py install for spatial-correlation-sampler ... error
        ERROR: Command errored out with exit status 1:
         command: /usr/local/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-bcf1fyrc/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /data/Disk_A/rongchang/.local/include/python3.8/spatial-correlation-sampler
             cwd: /tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/
        Complete output (56 lines):
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-3.8
        creating build/lib.linux-x86_64-3.8/spatial_correlation_sampler
        copying Correlation_Module/spatial_correlation_sampler/spatial_correlation_sampler.py -> build/lib.linux-x86_64-3.8/spatial_correlation_sampler
        copying Correlation_Module/spatial_correlation_sampler/__init__.py -> build/lib.linux-x86_64-3.8/spatial_correlation_sampler
        running build_ext
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py", line 57, in <module>
            launch_setup()
          File "/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py", line 25, in launch_setup
            setup(
          File "/usr/local/anaconda3/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/local/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
            self.run_command(cmd)
          File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
            return orig.install.run(self)
          File "/usr/local/anaconda3/lib/python3.8/distutils/command/install.py", line 545, in run
            self.run_command('build')
          File "/usr/local/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/anaconda3/lib/python3.8/distutils/command/build.py", line 135, in run
            self.run_command(cmd_name)
          File "/usr/local/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/anaconda3/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
            _build_ext.run(self)
          File "/usr/local/anaconda3/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
            _build_ext.build_ext.run(self)
          File "/usr/local/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 340, in run
            self.build_extensions()
          File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 378, in build_extensions
            self._check_abi()
          File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 734, in _check_abi
            check_compiler_abi_compatibility(compiler)
          File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 282, in check_compiler_abi_compatibility
            if not check_compiler_ok_for_platform(compiler):
          File "/data/Disk_A/rongchang/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 242, in check_compiler_ok_for_platform
            which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
          File "/usr/local/anaconda3/lib/python3.8/subprocess.py", line 415, in check_output
            return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
          File "/usr/local/anaconda3/lib/python3.8/subprocess.py", line 516, in run
            raise CalledProcessError(retcode, process.args,
        subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1.
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/local/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kcuopbgm/spatial-correlation-sampler_05a3547364fc43d4b8a1811af12f5d9f/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-bcf1fyrc/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /data/Disk_A/rongchang/.local/include/python3.8/spatial-correlation-sampler Check the logs for full command output.
    
    

    I hope to use the caculation tool in my recent project. Can you please give some help ?Thanks!

    opened by RongchangLi 2
Owner
Clément Pinard
PhD ENSTA Paris, Deep Learning Engineer @ ContentSquare
Clément Pinard
计算机视觉中用到的注意力模块和其他即插即用模块PyTorch Implementation Collection of Attention Module and Plug&Play Module

PyTorch实现多种计算机视觉中网络设计中用到的Attention机制,还收集了一些即插即用模块。由于能力有限精力有限,可能很多模块并没有包括进来,有任何的建议或者改进,可以提交issue或者进行PR。

PJDong 599 Dec 23, 2022
Implementation of Invariant Point Attention, used for coordinate refinement in the structure module of Alphafold2, as a standalone Pytorch module

Invariant Point Attention - Pytorch Implementation of Invariant Point Attention as a standalone module, which was used in the structure module of Alph

Phil Wang 113 Jan 5, 2023
This is a custom made virus code in python, using tkinter module.

skeleterrorBetaV0.1-Virus-code This is a custom made virus code in python, using tkinter module. This virus is not harmful to the computer, it only ma

AR 0 Nov 21, 2022
custom pytorch implementation of MoCo v3

MoCov3-pytorch custom implementation of MoCov3 [arxiv]. I made minor modifications based on the official MoCo repository [github]. No ViT part code an

null 39 Nov 14, 2022
Custom Implementation of Non-Deep Networks

ParNet Custom Implementation of Non-deep Networks arXiv:2110.07641 Ankit Goyal, Alexey Bochkovskiy, Jia Deng, Vladlen Koltun Official Repository https

Pritama Kumar Nayak 20 May 27, 2022
PyTorch implementation of a Real-ESRGAN model trained on custom dataset

Real-ESRGAN PyTorch implementation of a Real-ESRGAN model trained on custom dataset. This model shows better results on faces compared to the original

Sber AI 160 Jan 4, 2023
A Pytorch implementation of CVPR 2021 paper "RSG: A Simple but Effective Module for Learning Imbalanced Datasets"

RSG: A Simple but Effective Module for Learning Imbalanced Datasets (CVPR 2021) A Pytorch implementation of our CVPR 2021 paper "RSG: A Simple but Eff

null 120 Dec 12, 2022
Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or columns of a 2d feature map, as a standalone package for Pytorch

Triangle Multiplicative Module - Pytorch Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or c

Phil Wang 22 Oct 28, 2022
Simple torch.nn.module implementation of Alias-Free-GAN style filter and resample

Alias-Free-Torch Simple torch module implementation of Alias-Free GAN. This repository including Alias-Free GAN style lowpass sinc filter @filter.py A

이준혁(Junhyeok Lee) 64 Dec 22, 2022
A PyTorch implementation of a Factorization Machine module in cython.

fmpytorch A library for factorization machines in pytorch. A factorization machine is like a linear model, except multiplicative interaction terms bet

Jack Hessel 167 Jul 6, 2022
Pytorch implementation of "A simple neural network module for relational reasoning" (Relational Networks)

Pytorch implementation of Relational Networks - A simple neural network module for relational reasoning Implemented & tested on Sort-of-CLEVR task. So

Kim Heecheol 800 Dec 5, 2022
This codebase is the official implementation of Test-Time Classifier Adjustment Module for Model-Agnostic Domain Generalization (NeurIPS2021, Spotlight)

Test-Time Classifier Adjustment Module for Model-Agnostic Domain Generalization This codebase is the official implementation of Test-Time Classifier A

null 47 Dec 28, 2022
Implementation of the Chamfer Distance as a module for pyTorch

Chamfer Distance for pyTorch This is an implementation of the Chamfer Distance as a module for pyTorch. It is written as a custom C++/CUDA extension.

Christian Diller 205 Jan 5, 2023
PyTorch implementation for the visual prior component (i.e. perception module) of the Visually Grounded Physics Learner [Li et al., 2020].

VGPL-Visual-Prior PyTorch implementation for the visual prior component (i.e. perception module) of the Visually Grounded Physics Learner (VGPL). Give

Toru 8 Dec 29, 2022
Quickly and easily create / train a custom DeepDream model

Dream-Creator This project aims to simplify the process of creating a custom DeepDream model by using pretrained GoogleNet models and custom image dat

null 55 Dec 27, 2022
Turi Create simplifies the development of custom machine learning models.

Quick Links: Installation | Documentation | WWDC 2019 | WWDC 2018 Turi Create Check out our talks at WWDC 2019 and at WWDC 2018! Turi Create simplifie

Apple 10.9k Jan 1, 2023
FedJAX is a library for developing custom Federated Learning (FL) algorithms in JAX.

FedJAX: Federated learning with JAX What is FedJAX? FedJAX is a library for developing custom Federated Learning (FL) algorithms in JAX. FedJAX priori

Google 208 Dec 14, 2022
Turi Create simplifies the development of custom machine learning models.

Quick Links: Installation | Documentation | WWDC 2019 | WWDC 2018 Turi Create Check out our talks at WWDC 2019 and at WWDC 2018! Turi Create simplifie

Apple 10.1k Feb 12, 2021