Git Product home page Git Product logo

softpool's Introduction

Refining activation downsampling with SoftPool

supported versions Library GitHub license


Update 10/2021:

We have extended this work with in our paper: AdaPool: Exponential Adaptive Pooling for Information-Retaining Downsampling. Info, code and resources are available at alexandrosstergiou/adaPool

Abstract

Convolutional Neural Networks (CNNs) use pooling to decrease the size of activation maps. This process is crucial to increase the receptive fields and to reduce computational requirements of subsequent convolutions. An important feature of the pooling operation is the minimization of information loss, with respect to the initial activation maps, without a significant impact on the computation and memory overhead. To meet these requirements, we propose SoftPool: a fast and efficient method for exponentially weighted activation downsampling. Through experiments across a range of architectures and pooling methods, we demonstrate that SoftPool can retain more information in the reduced activation maps. This refined downsampling leads to improvements in a CNN's classification accuracy. Experiments with pooling layer substitutions on ImageNet1K show an increase in accuracy over both original architectures and other pooling methods. We also test SoftPool on video datasets for action recognition. Again, through the direct replacement of pooling layers, we observe consistent performance improvements while computational loads and memory requirements remain limited.


To appear in IEEE International Conference on Computer Vision (ICCV) 2021

[arXiv preprint]     [CVF open access]     [video presentation]

Image based pooling. Images are sub-sampled in both height and width by half.

Original
Soft Pool

Video based pooling. Videos are sub-sampled in time, height and width by half.

Original
Soft Pool

Dependencies

All parts of the code assume that torch is of version 1.4 or higher. There might be instability issues on previous versions.

! Disclaimer: This repository is heavily structurally influenced on Ziteng Gao's LIP repo https://github.com/sebgao/LIP

Installation

You can build the repo through the following commands:

$ git clone https://github.com/alexandrosstergiou/SoftPool.git
$ cd SoftPool-master/pytorch
$ make install
--- (optional) ---
$ make test

Usage

You can load any of the 1D, 2D or 3D variants after the installation with:

import softpool_cuda
from SoftPool import soft_pool1d, SoftPool1d
from SoftPool import soft_pool2d, SoftPool2d
from SoftPool import soft_pool3d, SoftPool3d
  • soft_poolxd: Is a functional interface for SoftPool.
  • SoftPoolxd: Is the class-based version which created an object that can be referenced later in the code.

ImageNet models

ImageNet weight can be downloaded from the following links:

Network link
ResNet-18 link
ResNet-34 link
ResNet-50 link
ResNet-101 link
ResNet-152 link
DenseNet-121 link
DenseNet-161 link
DenseNet-169 link
ResNeXt-50_32x4d link
ResNeXt-101_32x4d link
wide-ResNet50 link

Citation

@inproceedings{stergiou2021refining,
  title={Refining activation downsampling with SoftPool},
  author={Stergiou, Alexandros, Poppe, Ronald and Kalliatakis Grigorios},
  booktitle={International Conference on Computer Vision (ICCV)},
  year={2021},
  pages={10357-10366},
  organization={IEEE}
}

Licence

MIT

Additional resources

A great project is Ren Tianhe's pytorh-pooling repo for overviewing different pooling strategies.

softpool's People

Contributors

alexandrosstergiou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

softpool's Issues

识别精度

在图像识别任务上,把最后分类池化层换为softpool时,识别精度由之前的90%降低到几乎为0,这有可能是什么原因造成的呢?

Inconsistent behavior when stride is used

First of all, great work with SoftPool!

When I was adapting some code to test SoftPool for the first time, I left a stride=1 on the SoftPool2d constructor and noticed this inconsistent behavior on CPU (PyTorch implementation) vs GPU (CUDA implementation).

The shape of the output is different on the two implementations. With kernel 2 and stride 1 over a 3x3 input, I expected a 2x2 output, but the CUDA implementation gives 3x3. The example below illustrates well the difference.

In [1]: import torch

In [2]: from SoftPool import SoftPool2d

In [3]: x = torch.tensor([[[[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]]])

In [4]: x
Out[4]: 
tensor([[[[1., 2., 3.],
          [4., 5., 6.],
          [7., 8., 9.]]]])

In [5]: SoftPool2d(kernel_size=2, stride=1)(x.cpu())
Out[5]: 
tensor([[[[4.5888, 5.5888],
          [7.5888, 8.5888]]]])

In [6]: SoftPool2d(kernel_size=2, stride=1)(x.cuda())
Out[6]: 
tensor([[[[1.0000, 1.7311, 2.7311],
          [3.8577, 4.5888, 5.5888],
          [6.8577, 7.5888, 8.5888]]]], device='cuda:0')

It looks to me that this is a bug on the way the CUDA path handles the output shape. On CUDA_SOFTPOOL2d, it does something like oH = H // stride[0] while it should do something like oH = (H - kernel_height) // stride[0] + 1. Of course some other parts of the code would need to be adapted as well.

softpool_cuda issue !

Hello,

i was remain unsuccessful to install via following commonds:

$ git clone https://github.com/alexandrosstergiou/SoftPool.git
$ cd SoftPool-master/pytorch
$ make install

So, i have created and directly call SoftPool.py file. and it works fine. However, by commenting softpool_cuda.forward_2d(input.contiguous(), kernel, stride, output)

Because this library not properly installed, so i am unable to "import softpool_cuda", is there any trick to directly call these CUDA, and .cpp files in Python import? So, i can make softpool_cuda function work?

Waiting for reply...

about dim Ceil_Mode =True

The original pool operation can set the parameter Ceil_Mode =True, then how can the soft pool achieve the same effect, because there is a dimension mismatch problem in my replacement

Have some trouble in "make install"

Hi,I have trouble in "make install". The detail:FAILED: /pytorch/build/temp.linux-x86_64-3.6/CUDA/softpool_cuda_kernel.o
#pragma omp parallel for if ((end - begin) >= grain_size)
^
ninja: build stopped: subcommand failed.
python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
RuntimeError: Error compiling objects for extension
Makefile:2: recipe for target 'install' failed
make: *** [install] Error 1
Could you please help me?

softpool_cuda.forward_2d(input.contiguous(), kernel, stride, output)

Hi,thanks for your great idea!

I have a question in " softpool_cuda.forward_2d(input.contiguous(), kernel, stride, output) ",I just don't know what this line of code means ?What do you want to do with this line of code?

class CUDA_SOFTPOOL2d(Function):
    @staticmethod
    @torch.cuda.amp.custom_fwd(cast_inputs=torch.float32)
    def forward(ctx, input, kernel=2, stride=None):
        # Create contiguous tensor (if tensor is not contiguous)
        no_batch = False
        if len(input.size()) == 3:
            no_batch = True
            input.unsqueeze_(0)
        B, C, H, W = input.size()
        kernel = _pair(kernel)
        if stride is None:
            stride = kernel
        else:
            stride = _pair(stride)
        oH = (H - kernel[0]) // stride[0] + 1
        oW = (W - kernel[1]) // stride[1] + 1
        output = input.new_zeros((B, C, oH, oW))
        softpool_cuda.forward_2d(input.contiguous(), kernel, stride, output)   #### what does this line mean ?####
        ctx.save_for_backward(input)
        ctx.kernel = kernel
        ctx.stride = stride
        if no_batch:
            return output.squeeze_(0)
        return output

Looking forward to your reply,thanks!

Failed to install

Thanks for your work!

There're some errors when installing.

`rm -rf *.egg-info
rm -rf build dist
python setup.py install
running install
running bdist_egg
running egg_info
creating SoftPool.egg-info
writing SoftPool.egg-info/PKG-INFO
writing dependency_links to SoftPool.egg-info/dependency_links.txt
writing top-level names to SoftPool.egg-info/top_level.txt
writing manifest file 'SoftPool.egg-info/SOURCES.txt'
writing manifest file 'SoftPool.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/SoftPool
copying SoftPool/idea.py -> build/lib.linux-x86_64-3.8/SoftPool
copying SoftPool/init.py -> build/lib.linux-x86_64-3.8/SoftPool
running build_ext
building 'softpool_cuda' extension
creating /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8
creating /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA
Emitting ninja build file /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/2] :/usr/local/cuda-11.1:/usr/local/cuda-11.1/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o.d -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/TH -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.1:/usr/local/cuda-11.1/include -I/home/n504/anaconda3/envs/pytorch17/include/python3.8 -c -c /home/n504/Downloads/SoftPool/pytorch/CUDA/softpool_cuda_kernel.cu -o /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
FAILED: /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o
:/usr/local/cuda-11.1:/usr/local/cuda-11.1/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o.d -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/TH -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.1:/usr/local/cuda-11.1/include -I/home/n504/anaconda3/envs/pytorch17/include/python3.8 -c -c /home/n504/Downloads/SoftPool/pytorch/CUDA/softpool_cuda_kernel.cu -o /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS
-D__CUDA_NO_HALF_CONVERSIONS
_ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
/bin/sh: 1: :/usr/local/cuda-11.1:/usr/local/cuda-11.1/bin/nvcc: not found
[2/2] c++ -MMD -MF /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda.o.d -pthread -B /home/n504/anaconda3/envs/pytorch17/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/TH -I/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.1:/usr/local/cuda-11.1/include -I/home/n504/anaconda3/envs/pytorch17/include/python3.8 -c -c /home/n504/Downloads/SoftPool/pytorch/CUDA/softpool_cuda.cpp -o /home/n504/Downloads/SoftPool/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/ATen/Parallel.h:140:0,
from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/utils.h:3,
from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:5,
from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/nn.h:3,
from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:13,
from /home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
from /home/n504/Downloads/SoftPool/pytorch/CUDA/softpool_cuda.cpp:1:
/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/include/ATen/ParallelOpenMP.h:83:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
#pragma omp parallel for if ((end - begin) >= grain_size)

ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1667, in _run_ninja_build
subprocess.run(
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
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 "setup.py", line 4, in
setup(
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/bdist_egg.py", line 167, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/bdist_egg.py", line 153, in call_command
self.run_command(cmdname)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/command/install_lib.py", line 107, in build
self.run_command('build_ext')
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
_build_ext.run(self)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 708, in build_extensions
build_ext.build_extensions(self)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 196, in build_extension
_build_ext.build_extension(self, ext)
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 529, in unix_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1354, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "/home/n504/anaconda3/envs/pytorch17/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1683, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension
Makefile:2: recipe for target 'install' failed
make: *** [install] Error 1`

And I'm sure that I've cuda installed and added it into path.
output of command $nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2020 NVIDIA Corporation Built on Mon_Oct_12_20:09:46_PDT_2020 Cuda compilation tools, release 11.1, V11.1.105 Build cuda_11.1.TC455_06.29190527_0
output of command $echo $PATH:
/home/n504/anaconda3/envs/pytorch17/bin:/home/n504/anaconda3/condabin:/usr/local/cuda-11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-11.1/bin

cudaCheckError() failed : invalid device function

hi, ‘make install’ is succeed,but running ‘make test’ occurs some errors.
`cd test-files && python test.py
--- Initial checks for forward ---

Checking 1D CPU ...
PASSED
Checking 1D GPU ...
cudaCheckError() failed : invalid device function
Segmentation fault (core dumped)
Makefile:9: recipe for target 'test' failed
make: *** [test] Error 139
`

pytorch inplace operation issue

hello
This is my mistake!
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 256, 40, 40]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

The error ends here!
grad_input = torch.zeros_like(ctx.saved_tensors[0])
May I ask what caused the problem
thank you!

make install

Hello, when I run make install, I get the following error:
image
image
thank you

Is it possible to use SoftPool on Colab?

Hi,
I installed the package on Colab with the commands you provide. The installation process seemed successful, but when I tried to import soft_pool2d, I got the following error message:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-89f2a448160d> in <module>()
----> 1 from SoftPool import soft_pool2d, SoftPool2d

1 frames
/content/SoftPool/pytorch/SoftPool/idea.py in <module>()
      5 from torch.nn.modules.utils import _triple, _pair, _single
      6 
----> 7 import softpool_cuda
      8 
      9 

ModuleNotFoundError: No module named 'softpool_cuda'

Is there any way to use SoftPool on Colab? Thanks in advance.

100+ errors detected in the compilation of softpool_cuda_kernel.cu

Hey. I am getting a few errors during the installation process.
Into the SoftPool/pytorch folder, I run make install as explained in the README file, and during the process, three errors show up in the console repeatedly:

CUDA/softpool_cuda_kernel.cu(252): error: type name is not allowed
CUDA/softpool_cuda_kernel.cu(252): error: expected an expression
CUDA/softpool_cuda_kernel.cu(252): error: a pointer to a bound function may only be used to call the function

And then:

Error limit reached.
100 errors detected in the compilation of "CUDA/softpool_cuda_kernel.cu".
Compilation terminated.
error: command '/usr/local/cuda-11.3/bin/nvcc' failed with exit status 1
Makefile:2: recipe for target 'install' failed
make: *** [install] Error 1

For quick inspection, here are the lines that are causing the error (at least the first 100 of them). It looks like the issue is with AT_DISPATCH_FLOATING_TYPES_AND_HALF:

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
input.scalar_type(), "SoftPool1dLauncherForward", ([&] {
const scalar_t *bottom_input = input.data_ptr<scalar_t>();
scalar_t *output_data = output.data_ptr<scalar_t>();
SoftPool1dForward<scalar_t>
<<<GET_BLOCKS(output_size), THREADS_PER_BLOCK>>>(
output_size, bottom_input,
batches, channels,
dim, kernel_d,
stride_d, output_data);
})
);

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
input.scalar_type(), "SoftPool2dLauncherForward", ([&] {
const scalar_t *bottom_input = input.data_ptr<scalar_t>();
scalar_t *output_data = output.data_ptr<scalar_t>();
SoftPool2dForward<scalar_t>
<<<GET_BLOCKS(output_size), THREADS_PER_BLOCK>>>(
output_size, bottom_input,
batches, channels,
height, width,
kernel_h, kernel_w,
stride_h, stride_w,
output_data);
})
);

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
input.scalar_type(), "SoftPool3dLauncherForward", ([&] {
const scalar_t *bottom_input = input.data_ptr<scalar_t>();
scalar_t *output_data = output.data_ptr<scalar_t>();
SoftPool3dForward<scalar_t>
<<<GET_BLOCKS(output_size), THREADS_PER_BLOCK>>>(
output_size, bottom_input,
batches, channels,
depth, height,
width, kernel_d,
kernel_h, kernel_w,
stride_d, stride_h,
stride_w, output_data);
})
);

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
input.scalar_type(), "SoftPool1dLauncherBackward", ([&] {
scalar_t *diff_input = input_grad.data_ptr<scalar_t>();
const scalar_t *diff_output = output_grad.data_ptr<scalar_t>();
const scalar_t *data_input = input.data_ptr<scalar_t>();
SoftPool1dBackward<scalar_t>
<<<GET_BLOCKS(output_size), THREADS_PER_BLOCK>>>(
output_size, diff_output,
data_input, batches,
channels, dim,
kernel_d, stride_d,
diff_input);
}
)
);

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
input.scalar_type(), "SoftPool2dLauncherBackward", ([&] {
scalar_t *diff_input = input_grad.data_ptr<scalar_t>();
const scalar_t *diff_output = output_grad.data_ptr<scalar_t>();
const scalar_t *data_input = input.data_ptr<scalar_t>();
SoftPool2dBackward<scalar_t>
<<<GET_BLOCKS(output_size), THREADS_PER_BLOCK>>>(
output_size, diff_output,
data_input, batches,
channels, height,
width, kernel_h,
kernel_w, stride_h,
stride_w, diff_input);
}
)
);

I have tried different CUDA versions (9.0, 10.2, 11.3) and different GCC/G++ versions (5, 8 and 9), but no success. I am using Ubuntu 16.04 with an RTX 2080 Ti.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-23ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-oatUX7/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-23ubuntu1~16.04)

Thanks!

sfotpool instead of convolution in YOLO

I want to use sfotpool instead of convolution in YOLO to complete image downsampling, but I don’t know whether to use 1D, 2D or 3D. Can you give me some suggestions?

Hello, I find a bug when i use softpool2d.

RuntimeError: input.is_contiguous() INTERNAL ASSERT FAILED at "/export/w/SoftPool/pytorch/CUDA/softpool_cuda.cpp":120, please report a bug to PyTorch. input must be a contiguous tensor

global soft pooling?

Can soft pool be used as global soft pooling which can replace global average pooling?

about some implementation issues

Thank you for your sharing~
However I have some doubts,

  1. this code represents the weight value is calculation by using channel dimension on the same spatial position, rather than applying spatial region?

    e_x = torch.sum(torch.exp(x),dim=1,keepdim=True)

  2. for the last pooling layer, global avg pooling is better than softpool?

Looking forward to your reply

How to load your pre-trained model?

when I load your pre-trained model, it seems to have some error.

"state_dict = load_state_dict_from_url(model_urls[arch], progress=progress)"
"load_state_dict_from_url" does not define.

I download the model resnet-50_best.pth, and load it but error occurs.
Error(s) in loading state_dict for ResNet:
Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", "layer1.0.conv1.weight", "layer1.0.bn1.weight", "layer1.0.bn1.bias", "layer1.0.bn1.running_mean", "layer1.0.bn1.running_var", ..........

Can give me some advice to load your pre-trained model. It would be nice if you could provide detailed code. Thanks.

Why there is no 'padding' in softpool function?

I wonder why there is no parameter 'padding' in softpool function. When the kernel size can not be divided by input size, what will you do? And what should I modify so that i can use padding.

CUDA error

Hi, If I set force_inplace to False, CUDA will report an error:
RuntimeError: CUDA error: an illegal memory access was encountered.
cudaCheckError() failed : an illegal memory access was encountered.
Could you tell me why please?

SoftPool-master/pytorch/CUDA/softpool_cuda.cpp":119, please report a bug to PyTorch. output_grad must be a contiguous tensor

I have successfully installed the SoftPool in my computer, I have tested your train.py code on Resnet50 and it is normal without errors.
But when I use the softpool2d in my own code , I want to use the softpool on a bs×C×125×160 tensor to get a bs×C×1×20 tensor, so I set the kernel=(125,8), stride=(125,8)(i.e.,self.pool=SoftPool2d(kernel_size=(125,8),stride=(125,8))). In backward step, I meet the error:
'SoftPool-master/pytorch/CUDA/softpool_cuda.cpp":119, please report a bug to PyTorch. output_grad must be a contiguous tensor'.
Could you help to solve my problem? My pytorch version is 1.6.

about

It's OK to change “nn.MaxPool2d(2)“ to “out = soft_pool2d(out, 2)”, but changing ”nn.MaxPool2d((2, 1))” to ”out = soft_pool2d(out, (2,1)) “ or "out = soft_pool2d(out, 2,1)"will result in wrong dimension. What's the reason?

about padding

i want to add a parameter about "padding",i wonder if it is oK to do that ?

About padding

Excuse me, I am a frashman,
I find that "softpool" no padding, and when i do softpool, it is wrong, can you explain it?
Sorry about my ENG! Hope you can understand my means ^-^ Thank you!

RuntimeError: CUDA error: an illegal memory access was encountered

Traceback (most recent call last):
File "/media/mm/62f65e0e-b396-44ac-b1aa-b2fb260e70d1/mm/experiment/DE-Resnet18/main.py", line 251, in
main(args, logger)
File "/media/mm/62f65e0e-b396-44ac-b1aa-b2fb260e70d1/mm/experiment/DE-Resnet18/main.py", line 171, in main
train(model, train_loader, optimizer, criterion, epoch, args, logger)
File "/media/mm/62f65e0e-b396-44ac-b1aa-b2fb260e70d1/mm/experiment/DE-Resnet18/main.py", line 61, in train
loss.backward()
File "/home/mm/anaconda3/lib/python3.7/site-packages/torch/tensor.py", line 221, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/mm/anaconda3/lib/python3.7/site-packages/torch/autograd/init.py", line 132, in backward
allow_unreachable=True) # allow_unreachable flag
File "/home/mm/anaconda3/lib/python3.7/site-packages/torch/autograd/function.py", line 89, in apply
return self._forward_cls.backward(self, *args) # type: ignore
File "/media/mm/62f65e0e-b396-44ac-b1aa-b2fb260e70d1/mm/experiment/DE-Resnet18/softpool.py", line 45, in backward
saved[-1][torch.isnan(saved[-1])] = 0

My environment info is:
GPU: Titan
CUDA: 10.1.243
cuDNN: 7.6.5
PyTorch: 1.7.1

Question for installation

Hi Alex,

I just got a problem for installation. The error is: 'RuntimeError: Error compiling objects for extension'. I am using pytorch 1,7 and cuda 10.1. I do not know if it is related to my Pytorch or CUDA version. Do you have any advice?

Best wishes,
Qing

There was an error when I used softpool on the AlexNet during classification task training.

File "/home/csu/anaconda3/envs/wsy/lib/python3.6/site-packages/SoftPool-1.1-py3.6-linux-x86_64.egg/SoftPool/idea.py", line 192, in soft_pool2d
if torch.isnan(x).any():
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

The changes in my model are as follows:
def init(self, num_classes: int = 1000) -> None:
super(AlexNet, self).init()
self.conv1 = nn.Sequential(
......
)

self.conv2 = nn.Sequential(
    nn.Conv2d(64, 192, kernel_size=5, padding=2),
    nn.ReLU(inplace=True),
    SoftPool2d(kernel_size=3, stride=2), # This is where I changed
)

When I replace the softpool of the self.conv1 structure, no error occurs at runtime. However, an error occurred while replacing the self.conv2 structure.
The GPU I use is RTX 3090. The version of pytorch I use is 1.9.0.

A Problem : CUDA/limits.cuh(119): error: identifier "inf" is undefined

hi, I have some trouble when i install softpool. The detail is that im follow "Installation" and use "make install",then im encountered the mistake:

(mos3d) root@LUCAS-DEV-01a694:~/MotionSeg3D/SoftPool/pytorch# make install
rm -rf *.egg-info
rm -rf build dist
python setup.py install
running install
/usr/local/envs/mos3d/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
/usr/local/envs/mos3d/lib/python3.7/site-packages/setuptools/command/easy_install.py:147: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
EasyInstallDeprecationWarning,
running bdist_egg
running egg_info
creating SoftPool.egg-info
writing SoftPool.egg-info/PKG-INFO
writing dependency_links to SoftPool.egg-info/dependency_links.txt
writing top-level names to SoftPool.egg-info/top_level.txt
writing manifest file 'SoftPool.egg-info/SOURCES.txt'
reading manifest file 'SoftPool.egg-info/SOURCES.txt'
writing manifest file 'SoftPool.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/SoftPool
copying SoftPool/init.py -> build/lib.linux-x86_64-3.7/SoftPool
copying SoftPool/idea.py -> build/lib.linux-x86_64-3.7/SoftPool
running build_ext
building 'softpool_cuda' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/CUDA
gcc -pthread -B /usr/local/envs/mos3d/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/TH -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/usr/local/envs/mos3d/include/python3.7m -c CUDA/softpool_cuda.cpp -o build/temp.linux-x86_64-3.7/CUDA/softpool_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
/usr/local/cuda-10.2/bin/nvcc -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/TH -I/usr/local/envs/mos3d/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/usr/local/envs/mos3d/include/python3.7m -c CUDA/softpool_cuda_kernel.cu -o build/temp.linux-x86_64-3.7/CUDA/softpool_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS_ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_70,code=compute_70 -gencode=arch=compute_70,code=sm_70 -std=c++14
CUDA/limits.cuh(119): error: identifier "inf" is undefined

CUDA/limits.cuh(120): error: identifier "inf" is undefined

CUDA/limits.cuh(128): error: identifier "inf" is undefined

CUDA/limits.cuh(129): error: identifier "inf" is undefined

4 errors detected in the compilation of "/tmp/tmpxft_00280a89_00000000-6_softpool_cuda_kernel.cpp1.ii".
error: command '/usr/local/cuda-10.2/bin/nvcc' failed with exit code 1
Makefile:2: recipe for target 'install' failed
make: *** [install] Error 1

my environment :
pytorch:1.11.0
cuda:10.2
gcc:7.5

error: macro "AT_ASSERT" passed 2 arguments, but takes just 1

The project could not compile successfully with cuda-9.0, what should I do to change the code cuda/softpool_cuda.h?

#define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") #define CHECK_CONTIGUOUS(x) AT_ASSERT(x.is_contiguous(), #x " must be a contiguous tensor");

I already tried TORCH_INTERNAL_ASSERT, it did not work. Thanks alot.

The log is as follows:

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ CUDA/softpool_cuda.cpp:53:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:53:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:54:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output); ^ CUDA/softpool_cuda.cpp:54:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:73:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output_grad); ^ CUDA/softpool_cuda.cpp:73:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:74:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:74:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:75:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input_grad); ^ CUDA/softpool_cuda.cpp:75:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:95:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:95:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:96:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output); ^ CUDA/softpool_cuda.cpp:96:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:119:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output_grad); ^ CUDA/softpool_cuda.cpp:119:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:120:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:120:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:121:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input_grad); ^ CUDA/softpool_cuda.cpp:121:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:146:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:146:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:147:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output); ^ CUDA/softpool_cuda.cpp:147:23: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:175:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(output_grad); ^ CUDA/softpool_cuda.cpp:175:28: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:176:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp:176:22: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp:177:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CHECK_INPUT(input_grad); ^ CUDA/softpool_cuda.cpp:177:27: error: macro "AT_ASSERT" passed 2 arguments, but takes just 1 CUDA/softpool_cuda.cpp: In function ‘int softpool1d_forward_cuda(at::Tensor, std::tuple<int>, std::tuple<int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:53:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp: In function ‘int softpool1d_backward_cuda(at::Tensor, at::Tensor, std::tuple<int>, std::tuple<int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:73:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(output_grad); ^ CUDA/softpool_cuda.cpp: In function ‘int softpool2d_forward_cuda(at::Tensor, std::tuple<int, int>, std::tuple<int, int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:95:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp: In function ‘int softpool2d_backward_cuda(at::Tensor, at::Tensor, std::tuple<int, int>, std::tuple<int, int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:119:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(output_grad); ^ CUDA/softpool_cuda.cpp: In function ‘int softpool3d_forward_cuda(at::Tensor, std::tuple<int, int, int>, std::tuple<int, int, int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:146:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(input); ^ CUDA/softpool_cuda.cpp: In function ‘int softpool3d_backward_cuda(at::Tensor, at::Tensor, std::tuple<int, int, int>, std::tuple<int, int, int>, at::Tensor)’: CUDA/softpool_cuda.cpp:47:23: error: ‘AT_ASSERT’ was not declared in this scope #define CHECK_CUDA(x) AT_ASSERT(x.is_cuda(), #x " must be a CUDA tensor") ^ CUDA/softpool_cuda.cpp:49:24: note: in expansion of macro ‘CHECK_CUDA’ #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); ^ CUDA/softpool_cuda.cpp:175:5: note: in expansion of macro ‘CHECK_INPUT’ CHECK_INPUT(output_grad); ^ error: command 'gcc' failed with exit status 1 Makefile:2: recipe for target 'install' failed make: *** [install] Error 1

The speed between sum and average

I found an interesting result in your paper. The speed of sum operation is slower compared with the average operation by a huge margin. Could you please explain the reason for this phenomenon? Thank you!

gpu and cpu get different result

Thank you for your excellent work. But I have a question.
I trained the model with GPU, and the SoftPool2d parameter force_inplace was set to the default value False.
But the results I measured using GPU and CPU in the test are different, and the mAP of CPU is much lower than that of GPU. And if I change the force_inplace=True in the test, the mAP of the GPU is equal to that of the CPU, which is much lower than the previous GPU(force_inplace=False)

A problem of install error

(base) cx@amax:~/CL/HashNet-master/SoftPool-master/pytorch$ make install
rm -rf *.egg-info
rm -rf build dist
python setup.py install
Traceback (most recent call last):
File "setup.py", line 2, in
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
ModuleNotFoundError: No module named 'torch'
Makefile:2: recipe for target 'install' failed
make: *** [install] Error 1

what's matter with that ?

nvcc fatal : Unsupported gpu architecture 'compute_86'

Hello, I reported the following error when installing the 3090 graphics card
FAILED: /data/home/lwl/GaitSet_experiment/SoftPool-master/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o /usr/local/cuda/bin/nvcc -I/data/home/lwl/anaconda3/envs/exp38/lib/python3.8/site-packages/torch/include -I/data/home/lwl/anaconda3/envs/exp38/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/data/home/lwl/anaconda3/envs/exp38/lib/python3.8/site-packages/torch/include/TH -I/data/home/lwl/anaconda3/envs/exp38/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda/include -I/data/home/lwl/anaconda3/envs/exp38/include/python3.8 -c -c /data/home/lwl/GaitSet_experiment/SoftPool-master/pytorch/CUDA/softpool_cuda_kernel.cu -o /data/home/lwl/GaitSet_experiment/SoftPool-master/pytorch/build/temp.linux-x86_64-3.8/CUDA/softpool_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=softpool_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=sm_86 -std=c++14 nvcc fatal : Unsupported gpu architecture 'compute_86'

install

hello,I am a novice,how to install windows system without make

Have you ever implemented your method in efficientnet network?

Hi, thank you for your great idea. It's very interesting.

Because efficientnet get a lot of great results in Imagenet.
I just want to know have you ever implemented your idea in efficientnet before?
(Because efficientnet get a lot of great results in Imagenet.)

If you had done it before, What's the result?

Thank you again for everything you've done.

padding

Hi, how to solve the image padding operation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.