Have to reopen, since I have some issues with this on PyTorch 0.4.1 and Cuda 9.2 / CuDNN 7.1.4. Previous I ran 0.4.0 with Cuda 9.0 and CuDNN 7.0.5.
Basically, flip is already supported in 0.4.1 so the code looks like the following:
import torch

def batch_stripe(a):
    b, i, j = a.size()
    assert i >= j
    b_s, k, l = a.stride()
    return torch.as_strided(a, (b, i-j, j), (b_s, k, k+l))

if __name__ == '__main__':
    a = torch.arange(24).view(2,4,3)
    print('original tensor:')
    print(a)
    print('inverse stripe:')
    flipped = torch.flip(a, [2])
    print(batch_stripe(flipped))

Unfortunately, I am getting the following error in my code:
RuntimeError: cuda runtime error (59) device-side assert triggered at /opt/.../THCTensorCopy.cpp:21
And it is pointing to the line that does the flip, when I use CUDA_LAUNCH_BLOCKING=0. If I use CUDA_LAUNCH_BLOCKING=1, then it points to some unrelated part in the code. I see that this only happens with CuDNN 7.1 and not CuDNN 7.0.
This works fine with the small code example above, but fails in my project. Any ideas? Maybe there is a better way of doing the batch_stripe in PyTorch 0.4.1?
I will try to provide an example that can reproduce the error, but the codebase is too big for that right now.