Program hangs when I separate CUDA into the static library

Hi,
Has anybody faced with the issue when the program hangs in cudaMallocManaged() function if it is separated in the static library?
I’m using Visual Studio 2019 and Nvidia Toolkit v11.2.
So I have:

  1. cuda_opt project which generates static library (cuda_opt.lib)

    // cuda_opt.h
    extern “C” double vopt_tile_mean_8b_cuda(const uint8_t* pSrc, int srcStride, int srcSize);

    // cuda_opt.cu
    extern “C” double vopt_tile_mean_8b_cuda(const uint8_t* pSrc, int srcStride, int srcSize)
    {
    int* sum;
    cudaMallocManaged(&sum, sizeof(int))

    }

  2. opt_ut project with main() function.

    // main.cpp
    #include “cuda_opt.h”
    int main(int arg_c, char *arg_v)
    {
    uint8_t src[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
    double mean = vopt_tile_mean_8b_cuda(&src[0], 4, 4);
    return 0;
    }

When I debugged this program, I found it hangs after it stepped into cudaMallocManaged().
Maybe somebody knows what could be the problem?
Thank you.

Bets regards,
Alexander