diff --git a/build/darknet/yolo_cpp_dll_no_gpu.sln b/build/darknet/yolo_cpp_dll_no_gpu.sln new file mode 100644 index 00000000..ab54154a --- /dev/null +++ b/build/darknet/yolo_cpp_dll_no_gpu.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yolo_cpp_dll_no_gpu", "yolo_cpp_dll_no_gpu.vcxproj", "{4CF5694F-12A5-4012-8D94-9A0915E9FEB5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Debug|x64.ActiveCfg = Debug|x64 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Debug|x64.Build.0 = Debug|x64 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Debug|x86.ActiveCfg = Debug|Win32 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Debug|x86.Build.0 = Debug|Win32 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Release|x64.ActiveCfg = Release|x64 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Release|x64.Build.0 = Release|x64 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Release|x86.ActiveCfg = Release|Win32 + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/darknet/yolo_cpp_dll_no_gpu.vcxproj b/build/darknet/yolo_cpp_dll_no_gpu.vcxproj new file mode 100644 index 00000000..34d96d27 --- /dev/null +++ b/build/darknet/yolo_cpp_dll_no_gpu.vcxproj @@ -0,0 +1,270 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4CF5694F-12A5-4012-8D94-9A0915E9FEB5} + darknet + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + DynamicLibrary + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Platform)\ + + + $(SolutionDir)$(Platform)\ + yolo_cpp_dll + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + ..\..\3rdparty\include;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir);$(cudnn)\include + _MBCS;YOLODLL_EXPORTS;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;GPU;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + CUDNN + true + + + true + $(CUDA_PATH)lib\$(PlatformName);$(cudnn)\lib\x64;%(AdditionalLibraryDirectories) + $(OutDir)\$(TargetName)$(TargetExt) + ..\..\3rdparty\lib\x64\pthreadVC2.lib;cublas.lib;curand.lib;cudart.lib;%(AdditionalDependencies) + true + + + compute_30,sm_30;compute_52,sm_52 + 64 + + + + + Level3 + MaxSpeed + true + true + true + C:\opencv_2.4.9\opencv\build\include;..\..\3rdparty\include;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir);$(cudnn)\include + YOLODLL_EXPORTS;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;GPU;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + + + true + true + true + C:\opencv_2.4.9\opencv\build\x86\vc14\lib;C:\opencv_2.4.9\opencv\build\x86\vc12\lib;$(CUDA_PATH)lib\$(PlatformName);$(cudnn)\lib\x64;%(AdditionalLibraryDirectories) + ..\..\3rdparty\lib\x86\pthreadVC2.lib;cudart.lib;cublas.lib;curand.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + ..\..\3rdparty\include;%(AdditionalIncludeDirectories) + YOLODLL_EXPORTS;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + c11 + c++1y + CompileAsCpp + Default + + + true + + + true + true + true + %(AdditionalLibraryDirectories) + ..\..\3rdparty\lib\x64\pthreadVC2.lib;%(AdditionalDependencies) + $(OutDir)\$(TargetName)$(TargetExt) + + + 64 + compute_30,sm_30;compute_52,sm_52 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/yolo_v2_class.cpp b/src/yolo_v2_class.cpp index d79021a1..31f623cf 100644 --- a/src/yolo_v2_class.cpp +++ b/src/yolo_v2_class.cpp @@ -35,12 +35,16 @@ struct detector_gpu_t{ YOLODLL_API Detector::Detector(std::string cfg_filename, std::string weight_filename, int gpu_id) { int old_gpu_index; +#ifdef GPU cudaGetDevice(&old_gpu_index); +#endif detector_gpu_ptr = std::make_shared(); detector_gpu_t &detector_gpu = *reinterpret_cast(detector_gpu_ptr.get()); +#ifdef GPU cudaSetDevice(gpu_id); +#endif network &net = detector_gpu.net; net.gpu_index = gpu_id; //gpu_index = i; @@ -66,7 +70,9 @@ YOLODLL_API Detector::Detector(std::string cfg_filename, std::string weight_file detector_gpu.probs = (float **)calloc(l.w*l.h*l.n, sizeof(float *)); for (j = 0; j < l.w*l.h*l.n; ++j) detector_gpu.probs[j] = (float *)calloc(l.classes, sizeof(float)); +#ifdef GPU cudaSetDevice(old_gpu_index); +#endif } @@ -84,12 +90,16 @@ YOLODLL_API Detector::~Detector() free(detector_gpu.probs); int old_gpu_index; +#ifdef GPU cudaGetDevice(&old_gpu_index); cudaSetDevice(detector_gpu.net.gpu_index); +#endif free_network(detector_gpu.net); +#ifdef GPU cudaSetDevice(old_gpu_index); +#endif } @@ -150,8 +160,10 @@ YOLODLL_API std::vector Detector::detect(image_t img, float thresh) detector_gpu_t &detector_gpu = *reinterpret_cast(detector_gpu_ptr.get()); network &net = detector_gpu.net; int old_gpu_index; +#ifdef GPU cudaGetDevice(&old_gpu_index); cudaSetDevice(net.gpu_index); +#endif //std::cout << "net.gpu_index = " << net.gpu_index << std::endl; //float nms = .4; @@ -198,7 +210,9 @@ YOLODLL_API std::vector Detector::detect(image_t img, float thresh) if(sized.data) free(sized.data); +#ifdef GPU cudaSetDevice(old_gpu_index); +#endif return bbox_vec; }