Skip to content

Commit

Permalink
Mac 10.14 support for OpenCL (CMU-Perceptual-Computing-Lab#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulslicer authored and gineshidalgo99 committed Feb 11, 2019
1 parent ea9bfe0 commit 9f891d0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ if (UNIX OR APPLE)
set(CAFFE_CPU_ONLY ON)
set(USE_CUDNN OFF)
elseif (${GPU_MODE} MATCHES "OPENCL")
execute_process(COMMAND git checkout opencl WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
execute_process(COMMAND git checkout fe2a1102 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
set(USE_CUDNN OFF)
endif (${GPU_MODE} MATCHES "CUDA")

Expand Down
3 changes: 3 additions & 0 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ Also as a side note, if the default installation fails (i.e., the one explained
3. `Caffe_LIBS` set to `/usr/local/lib/libcaffe.dylib`.
4. Run `Configure` and `Generate` from CMake GUI.

You may also have to apply the following patch if you have the latest OSX 10.14. It can be done as follows:

`cd 3rdparty/caffe; git apply ../../scripts/osx/mac_opencl_patch.txt`


#### 3D Reconstruction Module
Expand Down
37 changes: 37 additions & 0 deletions scripts/osx/mac_opencl_patch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/cmake/Modules/FindvecLib.cmake b/cmake/Modules/FindvecLib.cmake
index 7459f623..9c5ee818 100644
--- a/cmake/Modules/FindvecLib.cmake
+++ b/cmake/Modules/FindvecLib.cmake
@@ -12,13 +12,17 @@ endif()

set(__veclib_include_suffix "Frameworks/vecLib.framework/Versions/Current/Headers")

-find_path(vecLib_INCLUDE_DIR vecLibTypes.h
+exec_program(xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
+find_path(vecLib_INCLUDE_DIR vecLib.h
DOC "vecLib include directory"
PATHS /System/Library/Frameworks/Accelerate.framework/Versions/Current/${__veclib_include_suffix}
/System/Library/${__veclib_include_suffix}
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
+ ${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
NO_DEFAULT_PATH)

+
+set(vecLib_INCLUDE_DIR "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/")
+
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR)

diff --git a/src/caffe/layers/malis_loss_layer.cpp b/src/caffe/layers/malis_loss_layer.cpp
index dae3c7d1..68e8323a 100644
--- a/src/caffe/layers/malis_loss_layer.cpp
+++ b/src/caffe/layers/malis_loss_layer.cpp
@@ -1,6 +1,6 @@
#include <boost/pending/disjoint_sets.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
+//#include <opencv2/highgui/highgui.hpp>
+//#include <opencv2/imgproc/imgproc.hpp>

#include <algorithm>
#include <cfloat>
12 changes: 6 additions & 6 deletions src/openpose/core/arrayCpuGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
return spImpl->pCaffeBlobT->gpu_shape();
#else
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
Expand All @@ -602,7 +602,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
return spImpl->pCaffeBlobT->gpu_data();
#else
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
Expand All @@ -621,7 +621,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
spImpl->pCaffeBlobT->set_gpu_data(data);
#else
UNUSED(data);
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
return spImpl->pCaffeBlobT->gpu_diff();
#else
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
Expand Down Expand Up @@ -694,7 +694,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
return spImpl->pCaffeBlobT->mutable_gpu_data();
#else
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
Expand Down Expand Up @@ -731,7 +731,7 @@ namespace op
{
try
{
#if defined(USE_CAFFE) && defined(USE_CUDA)
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
return spImpl->pCaffeBlobT->mutable_gpu_diff();
#else
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
Expand Down

0 comments on commit 9f891d0

Please sign in to comment.