@ptrblck, thanks for the reply.
Following is the sample code that loads the pytorch code  “pytorch_inference.py”  and calls inference function inference_code(data_from_c++) from c++:
#include <Python>

//============Pytorch File loading=============================

    Py_Initialize();
    PyRun_SimpleString("import sys\nsys.path.append('./pytorch_dir')"); //path to dir where my pytorch code  pytorch_inference.py resides
    PyObject * pName_pytorch_file = PyUnicode_FromString("pytorch_inference"); //load pytorch_inference.py
    PyObject * pModule_pytorch_module = PyImport_Import(pName_pytorch_file);    
    if (pModule_pytorch_module != NULL) {
        PyObject * pFunc_pytorch_inference_pointer = PyObject_GetAttrString(pModule_pytorch_module, "inference_code"); //load the offset address of python function to be called from c++
		std::cout << "[Python Func]: offset set" << std::endl;       
    }
    else
    {
        std::cout << "Module failed to load " << std::endl;
        assert(0);
    }
//================call to specific function of python from c++====

if (pFunc_pytorch_inference_pointer && PyCallable_Check(pFunc_pytorch_inference_pointer)) {	
	pArgs_to_pytorch_func = PyTuple_New(1);
    PyObject* data= PyArray_SimpleNewFromData(1,dims, PyArray_USHORT, bufferOfData);
	PyTuple_SetItem (pArgs_to_pytorch_func, 0, data);
    PyObject *Dict  = PyObject_CallObject(pFunc_pytorch_inference_pointer, data);  //this calls the pytorrch function "inference_code" with some data
}


//====================================================================

And the pytorch code pytorch_inference.py:
//====================Python side pytorch_inference.py ==========

print("import --endered")
import os
import pickle as pkl
import sys
import warnings
import shutil
import cv2
from PIL import Image
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init
import torch.optim as optim
import torch.optim.lr_scheduler
import torch.utils.data as data
from torchvision.utils import save_image
import torchvision
print("import succedded-")
model_path = "./model_gpu.pth"

def inference_code(data_from_c++):
	dict_to_cpp = {}	
    torch.cuda.init()											#To test
    print("torch.cuda.is_available(): ",torch.cuda.is_available()) #To test: returned true
    print("torch.cuda.is_initialized(): ", torch.cuda.is_initialized())#To test: returned true
	torch.load(model_path,map_location="cuda:0")#----Hangs right here , but works for cpu models(for cpu I do not pass map_location="cuda:0")
	return dict
	
//===================================================================



How you’ve exported the model in Python?

I give the path to the model in the pytorch code itself:
model_path = "./model_gpu.pth"  #tried giving absolute path but still it hangs in torch.load
torch.load(model_path,map_location="cuda:0")