dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.05k stars 1.89k forks source link

DllNotFoundException: Unable to load DLL 'tensorflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E) #4712

Closed yasir9624 closed 4 years ago

yasir9624 commented 4 years ago

I am trying to Consume the ML.NET model to predict the results via following code

public static ModelOutput Predict(ModelInput input) {

        // Create new MLContext
        MLContext mlContext = new MLContext();
        ModelOutput result = new ModelOutput();
        try
        {

            Load model &create prediction engine
            string modelPath = AppDomain.CurrentDomain.BaseDirectory + "MLModel.zip";
            ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema);
            var predEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);

            Use model to make prediction on input dataDllNotFoundException: Unable to load DLL 'tensorflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

            result = predEngine.Predict(input);
            Console.WriteLine(result);

        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        return result;
    }

I am having tensorflow.dll error while it is installed and present in respective folder too.

mstfbl commented 4 years ago

Hi @yasir9624 , are you importing the TensorFlow libraries by adding using Microsoft.ML.TensorFlow before you declare your namespace?

mstfbl commented 4 years ago

Closing this issue as no response was received.