THCState_getCurrentStream in torch1.5

as754770178: <p>I refer to <code>https://github.com/xingyizhou/CenterNet/blob/master/src/lib/models/networks/DCNv2/src/dcn_v2_cuda.c</code>.</p>
<pre><code class="lang-auto">....
    const int block = 128;
    const int grid = (batch + block - 1) / block;

    createBatchGemmBuffer&lt;&lt;&lt;grid, block, 0, THCState_getCurrentStream(state)&gt;&gt;&gt;(
        input_b, output_b,
        columns_b, ones_b,
        weight_b, bias_b,
        input.data&lt;scalar_t&gt;(),
        output.data&lt;scalar_t&gt;(),
        columns.data&lt;scalar_t&gt;(),
        ones.data&lt;scalar_t&gt;(),
        weight.data&lt;scalar_t&gt;(),
        bias.data&lt;scalar_t&gt;(),
        channels * width * height,
        channels_out * width_out * height_out,
        channels * kernel_h * kernel_w * height_out * width_out,
        height_out * width_out,
        batch);

    long m_ = channels_out;
    long n_ = height_out * width_out;
    long k_ = 1;
    THCudaBlas_SgemmBatched(state,
                            't',
                            'n',
                            n_,
                            m_,
                            k_,
                            1.0f,
                            ones_b, k_,
                            bias_b, k_,
                            0.0f,
                            output_b, n_,
                            batch);

    modulated_deformable_im2col_cuda(THCState_getCurrentStream(state),
                                     input.data&lt;scalar_t&gt;(),
                                     offset.data&lt;scalar_t&gt;(),
                                     mask.data&lt;scalar_t&gt;(),
                                     batch, channels, height, width,
                                     height_out, width_out, kernel_h, kernel_w,
                                     pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w,
                                     deformable_group,
                                     columns.data&lt;scalar_t&gt;());

    long m = channels_out;
    long n = height_out * width_out;
.... 
</code></pre>
<p>I can compile in torch1.2, but failed in torch1.5.</p>
<p>I refer to <code>https://github.com/pytorch/pytorch/issues/36132</code>, change <code>THCState_getCurrentStream</code> to <code>c10::cuda::getCurrentCUDAStream</code>, <code>cuda::getCurrentCUDAStream</code> and <code>at::cuda::getCurrentCUDAStream</code>. These all failed.</p>

ptrblck: <p>In newer versions, this should work:</p>
<pre><code class="lang-python">cudaStream_t   stream = at::cuda::getCurrentCUDAStream().stream();
</code></pre>
<p>Could you post the error message you are getting using this method?</p>

as754770178: <p>orginal error:</p>
<pre><code class="lang-auto">/ops/deformable_convolution/src/cuda/dcn_v2_cuda.cu(107): error: identifier "THCState_getCurrentStream" is undefined

/ops/deformable_convolution/src/cuda/dcn_v2_cuda.cu(279): error: identifier "THCState_getCurrentStream" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_0000125b_00000000-6_dcn_v2_cuda.cpp1.ii".
</code></pre>
<p>I change</p>
<pre><code class="lang-auto">  createBatchGemmBuffer&lt;&lt;&lt;grid, block, 0, THCState_getCurrentStream(state)&gt;&gt;&gt;(
... ... 
  modulated_deformable_im2col_cuda(THCState_getCurrentStream(state),
... ...
</code></pre>
<p>to</p>
<pre><code class="lang-auto">  createBatchGemmBuffer&lt;&lt;&lt;grid, block, 0, at::cuda::getCurrentCUDAStream().stream()&gt;&gt;&gt;(
... ... 
  modulated_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream().stream(),
... ...
</code></pre>
<p>The issue fixed.</p>