DlibDotNet icon indicating copy to clipboard operation
DlibDotNet copied to clipboard

Can't get CUDA to work on .net framework

Open ipernjakovic opened this issue 4 years ago • 7 comments

Summary of your issue

I've tried every single advice i have found here in order to get CUDA to work with vb.net (or even C#), on .NET Framework. (not .NET Core)

Environment

win10, VS2019, i7-8700, GTX 2060

What did you do when you faced the problem?

First, i did install cuda 10.1 toolkit and cudnn 10.1, copied cdnn to cuda directory, everything where it should be, checked CUDA PATH, everything is in order.

Then Create new project, nuget Install-Package DlibDotNet.CUDA101 -Version 19.18.0.20200525 (i've tried all versions).

When i build that, it does NOT copy DlibDotNetNativeDnn.dll and DlibDotNetNative.dll to output folder (so i copy them manually from packages folder). But whatever i do, just one line (Cuda.TryGetDriverVersion) breaks with: DllNotFoundException: Unable to load DLL 'DlibDotNetNativeDnn': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Also, not directly related but if you install facerecognitiondotnet.cuda101 (or any cuda version) through NuGet, it will NOT install dlibdotnetcuda101 as a dependency, but plain, non-cuda dlibdotnet.

Did anyone actually manage to get CUDA to work with .NET Framework? Am i doing something wrong, or should i be doing anything else?

Thank you

best regards Ivan

ipernjakovic avatar Jun 23 '20 22:06 ipernjakovic

@ipernjakovic Did you install cudnn? Please check dll's dependencies by https://github.com/lucasg/Dependencies

takuya-takeuchi avatar Jun 23 '20 22:06 takuya-takeuchi

Thank you for super quick response!

Yes, i did install cudnn. I will try "Dependencies" and see if maybe something is missing.

ipernjakovic avatar Jun 23 '20 23:06 ipernjakovic

Ok, i found what was missing, it was one dll "cublas64_10.dll"... Finally its working, and it is a huge speed improvement.

BUT, there is still a bug of DlibDotNetNativeDnn.dll and DlibDotNetNative.dll not being copied to output folder, and also that facerecognitiondotnetCUDA installs dlibdotnet not CUDA.

But my problem is solved, thanks ! If anyone has a similar problem, feel free to contact me for help !

Thanks and keep up the good work !!!

ipernjakovic avatar Jun 23 '20 23:06 ipernjakovic

Hi all.

I don't seem to be able to correctly put DlibDotNet to work with CUDA, as it is only using CPU.

I am using CUDA 10.1, and the respective Dlib nuget. I also have installed the cudnn. when using the ProcessExplorer all NVIDEA dependencies are found.

The part that I am using from Dlib is the LossMetric and the ShapePredictor. I wonder if these parts would be affected by CUDA usage.

Thanks

jpsalada avatar Aug 26 '20 00:08 jpsalada

It is working now. I had two problems:

  • Mixture of DlibDotNet and DlibDotNet.Cuda in different projects so it would downgrade to DlibDotNet.
  • On the ProcessExplorer the dll dependencies would appear and would be matched giving the impression DlibDotNet.Cuda was being used. However since I am using EMGU,these dependencies were from EMGU.

jpsalada avatar Aug 26 '20 10:08 jpsalada

Hi all,

BUT, there is still a bug of DlibDotNetNativeDnn.dll and DlibDotNetNative.dll not being copied to output folder, and also that facerecognitiondotnetCUDA installs dlibdotnet not CUDA.

I found the following facts.

  • VS2015
    • Dlls are not copied to application directory. VS says This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\DlibDotNet.19.20.0.20200725\build\DlibDotNet.props
      • https://stackoverflow.com/questions/32254439/nuget-packages-are-missing
  • VS2017
    • For build for x64, no problem but AnyCPU occurs build error
  • VS2019
    • For build for x64, no problem but AnyCPU occurs build error

takuya-takeuchi avatar Aug 28 '20 16:08 takuya-takeuchi

Relate to #61

takuya-takeuchi avatar Aug 28 '20 16:08 takuya-takeuchi