machinelearning icon indicating copy to clipboard operation
machinelearning copied to clipboard

System.MissingMethodException: 'Method not found: 'Tensorflow.Tensor Tensorflow.tensorflow.truncated_normal'

Open Sinfulelf opened this issue 6 years ago • 7 comments

System information

  • OS version/distro: Window 10 build-17134
  • .NET Version (eg., dotnet --info): NetCore 3.1

Issue

Method not found: 'Tensorflow.Tensor Tensorflow.tensorflow.truncated_normal(Int32[], Single, Single, Tensorflow.TF_DataType, System.Nullable`1, System.String)'.


        static void Main(string[] args)
        {
            var workspaceRelativePath = @"C:\Test_dev\ML_Main_Test\workspace";
            var assetsRelativePath = @"C:\Test_dev\ML_Main_Test\assets";

            MLContext mlContext = new MLContext();

            IEnumerable<ImageData> images = LoadImagesFromDirectory(folder: assetsRelativePath, useFolderNameAsLabel: true);

            var test = images.First();

            IDataView imageData = mlContext.Data.LoadFromEnumerable(images);

            IDataView shuffledData = mlContext.Data.ShuffleRows(imageData);

            var preprocessingPipeline = mlContext.Transforms.Conversion.MapValueToKey(
                                    inputColumnName: "Label",
                                    outputColumnName: "LabelAsKey")
                                .Append(mlContext.Transforms.LoadRawImageBytes(
                                    outputColumnName: "Image",
                                    imageFolder: assetsRelativePath,
                                    inputColumnName: "ImagePath"));

            IDataView preProcessedData = preprocessingPipeline.Fit(shuffledData)
                                            .Transform(shuffledData);

            TrainTestData trainSplit = mlContext.Data.TrainTestSplit(data: preProcessedData, testFraction: 0.2);
            TrainTestData validationTestSplit = mlContext.Data.TrainTestSplit(trainSplit.TestSet);

            IDataView trainSet = trainSplit.TrainSet;
            IDataView validationSet = validationTestSplit.TrainSet;
            IDataView testSet = validationTestSplit.TestSet;

            var classifierOptions = new ImageClassificationTrainer.Options()
            {
                FeatureColumnName = "Image",
                LabelColumnName = "LabelAsKey",
                ValidationSet = validationSet,
                Arch = ImageClassificationTrainer.Architecture.ResnetV2101,
                MetricsCallback = Console.WriteLine,
                TestOnTrainSet = false,
                ReuseTrainSetBottleneckCachedValues = true,
                ReuseValidationSetBottleneckCachedValues = true,
                WorkspacePath = workspaceRelativePath
            };
            var trainingPipeline = mlContext.MulticlassClassification.Trainers.ImageClassification(classifierOptions)
                                    .Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

            ITransformer trainedModel = trainingPipeline.Fit(trainSet);

            mlContext.Model.Save(trainedModel, preProcessedData.Schema, "model.zip");

            ClassifySingleImage(mlContext, testSet, trainedModel);
        }

Sinfulelf avatar Jan 20 '20 14:01 Sinfulelf

Hi @Sinfulelf , Which version of the ML.NET nugets were you using?

yaeldekel avatar Jan 21 '20 10:01 yaeldekel

Hi @Sinfulelf , Which version of the ML.NET nugets were you using?

<PackageReference Include="Microsoft.ML" Version="1.4.0" />

<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.4.0" />

<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="1.4.0" />

<PackageReference Include="Microsoft.ML.TensorFlow" Version="1.4.0" />

<PackageReference Include="Microsoft.ML.Vision" Version="1.4.0" />

<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.15.0" />

<PackageReference Include="TensorFlow.NET" Version="0.14.0" />`

Sinfulelf avatar Jan 21 '20 13:01 Sinfulelf

Thanks @Sinfulelf . I am not sure yet what is causing your issue. I've noticed though that the version you mentioned of TensorFlow.NET is not the version that is installed by Microsoft.ML.TensorFlow - that package has a dependency on TensorFlow.NET version 0.11.8.1. Could this be causing the problem? Please try using version 0.11.8.1 and report the results. (also, the SciSharp.TensorFlow.Redist version used by ML.NET is 1.14.0, so you could try changing that as well).

yaeldekel avatar Jan 22 '20 11:01 yaeldekel

Thanks @Sinfulelf . I am not sure yet what is causing your issue. I've noticed though that the version you mentioned of TensorFlow.NET is not the version that is installed by Microsoft.ML.TensorFlow - that package has a dependency on TensorFlow.NET version 0.11.8.1. Could this be causing the problem? Please try using version 0.11.8.1 and report the results. (also, the SciSharp.TensorFlow.Redist version used by ML.NET is 1.14.0, so you could try changing that as well).

Ty @yaeldekel . Will inform you asap.

Sinfulelf avatar Jan 22 '20 17:01 Sinfulelf

@Sinfulelf what were the results of changing TensorFlow.NET version 0.11.8.1? Did you still encounter the error?

najeeb-kazmi avatar Mar 25 '20 23:03 najeeb-kazmi

@Sinfulelf I have verified that this error is indeed due to using TensorFlow.NET version 0.14.0. In fact, you do not need to explicitly install TensorFlow.NET at all, since the correct dependency (i.e. v 0.11.8.1) will be installed when you install Microsoft.ML.Vision.

I'm closing this issue. Please feel free to reopen if something remains unanswered.

najeeb-kazmi avatar Mar 28 '20 00:03 najeeb-kazmi

ML.NET support CUDA 11 Loading model from: F:\V2Sorter\DataSet\03.01.2021\imageClassifier_2.zip 2021-04-16 16:06:33.457209: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:03:00.0 name: GeForce RTX 3080 computeCapability: 8.6 coreClock: 1.905GHz coreCount: 68 deviceMemorySize: 10.00GiB deviceMemoryBandwidth: 707.88GiB/s 2021-04-16 16:06:33.458465: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-04-16 16:06:33.459114: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-04-16 16:06:33.459639: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-04-16 16:06:33.460164: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-04-16 16:06:33.460705: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-04-16 16:06:33.461270: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-04-16 16:06:33.461946: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-04-16 16:06:33.462589: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-04-16 16:06:33.463409: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-04-16 16:06:33.464111: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-04-16 16:06:33.464830: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0 2021-04-16 16:06:33.465221: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N 2021-04-16 16:06:33.465788: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7745 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3080, pci bus id: 0000:03:00.0, compute capability: 8.6) Exception thrown: 'System.EntryPointNotFoundException' in Microsoft.ML.Vision.dll device is disconnected Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll The thread 0x2f80 has exited with code 0 (0x0).

I'm using "SciSharp.TensorFlow.Redist-Windows-GPU" with CUDA 2.4.0 support but get the exception "Exception thrown: 'System.EntryPointNotFoundException' in Microsoft.ML.Vision.dll" what could be the problem?

uzfm avatar Apr 21 '21 08:04 uzfm