Esempio n. 1
0
        private EnvironmentReport GetEnvironmentReport()
        {
            var report = new EnvironmentReport();

            ////https://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed/34209692#34209692
            //using (var registryKey = Registry.ClassesRoot.OpenSubKey(@"Installer\Dependencies\,,amd64,14.0,bundle", false))
            //{
            //    var displayName = registryKey.GetValue("DisplayName") as string;
            //    if (displayName.StartsWith("Microsoft Visual C++ 2017 Redistributable (x64)", StringComparison.OrdinalIgnoreCase))
            //    {
            //        report.MicrosoftVisualCPlusPlus2017RedistributableExists = true;
            //    }
            //}

            if (File.Exists(@"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\cudnn64_7.dll"))
            {
                report.CudnnExists = true;
            }

            var envirormentVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);

            //if (envirormentVariables.Contains("cudnn"))
            //{
            //    //["CUDA_PATH"] = "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.2"
            //}

            if (envirormentVariables.Contains("CUDA_PATH"))
            {
                //var cudaVersion = envirormentVariables["CUDA_PATH"];
                report.CudaExists = true;
            }

            return(report);
        }
Esempio n. 2
0
        private EnvironmentReport GetEnvironmentReport()
        {
            var report = new EnvironmentReport
            {
                MicrosoftVisualCPlusPlusRedistributableExists = this.IsMicrosoftVisualCPlusPlus2017Available()
            };

            if (File.Exists(@"x64\cudnn64_7.dll"))
            {
                report.CudnnExists = true;
            }

            var envirormentVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);

            if (envirormentVariables.Contains("CUDA_PATH"))
            {
                if (!File.Exists(Path.Combine(Environment.SystemDirectory, "NVCUDA.DLL")))
                {
                    //throw new DllNotFoundException("NVCUDA.DLL wasn't found in the windows system directory, " +"is CUDA and your Nvidia graphics driver correctly installed?");
                    report.CudaExists = false;
                }
                else
                {
                    report.CudaExists = true;
                }
            }
            if (envirormentVariables.Contains("CUDA_PATH_V10_1"))
            {
                report.CudaExists = true;
            }

            return(report);
        }
Esempio n. 3
0
        private EnvironmentReport GetEnvironmentReport()
        {
            var report = new EnvironmentReport
            {
                MicrosoftVisualCPlusPlusRedistributableExists = this.IsMicrosoftVisualCPlusPlus2017Available()
            };

            if (File.Exists(@"x64\cudnn64_7.dll"))
            {
                report.CudnnExists = true;
            }

            var envirormentVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);

            if (envirormentVariables.Contains("CUDA_PATH"))
            {
                report.CudaExists = true;
            }
            if (envirormentVariables.Contains("CUDA_PATH_V10_1"))
            {
                report.CudaExists = true;
            }

            return(report);
        }
Esempio n. 4
0
        private void Initialize(string configurationFilename, string weightsFilename, string namesFilename, int gpu = 0, bool ignoreGpu = false)
        {
            if (IntPtr.Size != 8)
            {
                throw new NotSupportedException("Only 64-bit processes are supported");
            }

            this.EnvironmentReport = this.GetEnvironmentReport();

            /*   if (!this.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists)
             * {
             *     throw new DllNotFoundException("Microsoft Visual C++ 2017 Redistributable (x64)");
             * }*/

            this.DetectionSystem = DetectionSystem.CPU;
            if (!ignoreGpu && this.EnvironmentReport.CudaExists && this.EnvironmentReport.CudnnExists)
            {
                this.DetectionSystem = DetectionSystem.GPU;
            }

            switch (this.DetectionSystem)
            {
            case DetectionSystem.CPU:
                InitializeYoloCpu(configurationFilename, weightsFilename, 0);
                break;

            case DetectionSystem.GPU:
                var deviceCount = GetDeviceCount();
                if (deviceCount == 0)
                {
                    throw new NotSupportedException("No graphic device is available");
                }

                if (gpu > (deviceCount - 1))
                {
                    throw new IndexOutOfRangeException("Graphic device index is out of range");
                }

                var deviceName = new StringBuilder();     //allocate memory for string
                GetDeviceName(gpu, deviceName);
                this.EnvironmentReport.GraphicDeviceName = deviceName.ToString();

                InitializeYoloGpu(configurationFilename, weightsFilename, gpu);
                break;
            }

            var lines = File.ReadAllLines(namesFilename);

            for (var i = 0; i < lines.Length; i++)
            {
                this._objectType.Add(i, lines[i]);
            }
        }
Esempio n. 5
0
        private void Initialize(string configurationFilename, string weightsFilename, string namesFilename, int gpu = 0)
        {
            if (IntPtr.Size != 8)
            {
                throw new NotSupportedException("Only 64-bit process are supported");
            }

            this.EnvironmentReport = this.GetEnvironmentReport();
            //if (!this.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists)
            //{
            //    throw new DllNotFoundException("Microsoft Visual C++ 2017 Redistributable (x64)");
            //}

            this.DetectionSystem = DetectionSystem.CPU;
            if (this.EnvironmentReport.CudaExists && this.EnvironmentReport.CudnnExists)
            {
                this.DetectionSystem = DetectionSystem.GPU;
            }

            int           deviceCount;
            StringBuilder deviceName;

            switch (this.DetectionSystem)
            {
            case DetectionSystem.CPU:
                InitializeYoloCpu(configurationFilename, weightsFilename, 0);
                break;

            case DetectionSystem.GPU:
                switch (this.DnnMode)
                {
                case DNNMode.Frame:
                case DNNMode.LT:
                    deviceCount = GetDeviceCountLt();
                    if (gpu > (deviceCount - 1))
                    {
                        throw new IndexOutOfRangeException("Graphic device index is out of range");
                    }

                    deviceName = new StringBuilder();         //allocate memory for string
                    GetDeviceNameLt(gpu, deviceName);
                    this.EnvironmentReport.GraphicDeviceName = deviceName.ToString();

                    InitializeYoloGpuLt(configurationFilename, weightsFilename, gpu);
                    break;

                case DNNMode.CC:
                    deviceCount = GetDeviceCountCc();
                    if (gpu > (deviceCount - 1))
                    {
                        throw new IndexOutOfRangeException("Graphic device index is out of range");
                    }

                    deviceName = new StringBuilder();         //allocate memory for string
                    GetDeviceNameCc(gpu, deviceName);
                    this.EnvironmentReport.GraphicDeviceName = deviceName.ToString();

                    InitializeYoloGpuCc(configurationFilename, weightsFilename, gpu);
                    break;
                }
                break;
            }

            var lines = File.ReadAllLines(namesFilename);

            for (var i = 0; i < lines.Length; i++)
            {
                this._objectType.Add(i, lines[i]);
            }
        }