I have written following code (for reference to future visitors) and it seems to be running fine.
m.def("my_func_with_gpu_pointers", [](const long i_ptr, const long j_ptr, const long edge_costs_ptr, const long sol_out_ptr, const int num_edges, const int gpuDeviceID) 
{
  cudaSetDevice(gpuDeviceID);
  const int* const i = reinterpret_cast<const int* const>(i_ptr);
  const int* const j = reinterpret_cast<const int* const>(j_ptr);
  const float* const edge_costs = reinterpret_cast<const float* const>(edge_costs_ptr);
  int* const sol_out_ptr_int = reinterpret_cast<int* const>(sol_out_ptr);
  thrust::device_vector<int> i_thrust(i, i + num_edges);
  thrust::device_vector<int> j_thrust(j, j + num_edges);
  thrust::device_vector<float> costs_thrust(edge_costs, edge_costs + num_edges);
  thrust::device_vector<int> sol;
  sol = my_func(std::move(i_thrust), std::move(j_thrust), std::move(costs_thrust)); 
  thrust::copy(sol.begin(), sol .end(), sol_out_ptr_int);
}