Skip to content

Commit 9f891d0

Browse files
soulslicergineshidalgo99
authored andcommitted
Mac 10.14 support for OpenCL (CMU-Perceptual-Computing-Lab#1083)
1 parent ea9bfe0 commit 9f891d0

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ if (UNIX OR APPLE)
690690
set(CAFFE_CPU_ONLY ON)
691691
set(USE_CUDNN OFF)
692692
elseif (${GPU_MODE} MATCHES "OPENCL")
693-
execute_process(COMMAND git checkout opencl WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
693+
execute_process(COMMAND git checkout fe2a1102 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
694694
set(USE_CUDNN OFF)
695695
endif (${GPU_MODE} MATCHES "CUDA")
696696

doc/installation.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ Also as a side note, if the default installation fails (i.e., the one explained
350350
3. `Caffe_LIBS` set to `/usr/local/lib/libcaffe.dylib`.
351351
4. Run `Configure` and `Generate` from CMake GUI.
352352

353+
You may also have to apply the following patch if you have the latest OSX 10.14. It can be done as follows:
354+
355+
`cd 3rdparty/caffe; git apply ../../scripts/osx/mac_opencl_patch.txt`
353356

354357

355358
#### 3D Reconstruction Module

scripts/osx/mac_opencl_patch.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/cmake/Modules/FindvecLib.cmake b/cmake/Modules/FindvecLib.cmake
2+
index 7459f623..9c5ee818 100644
3+
--- a/cmake/Modules/FindvecLib.cmake
4+
+++ b/cmake/Modules/FindvecLib.cmake
5+
@@ -12,13 +12,17 @@ endif()
6+
7+
set(__veclib_include_suffix "Frameworks/vecLib.framework/Versions/Current/Headers")
8+
9+
-find_path(vecLib_INCLUDE_DIR vecLibTypes.h
10+
+exec_program(xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
11+
+find_path(vecLib_INCLUDE_DIR vecLib.h
12+
DOC "vecLib include directory"
13+
PATHS /System/Library/Frameworks/Accelerate.framework/Versions/Current/${__veclib_include_suffix}
14+
/System/Library/${__veclib_include_suffix}
15+
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
16+
+ ${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
17+
NO_DEFAULT_PATH)
18+
19+
+
20+
+set(vecLib_INCLUDE_DIR "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/")
21+
+
22+
include(FindPackageHandleStandardArgs)
23+
find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR)
24+
25+
diff --git a/src/caffe/layers/malis_loss_layer.cpp b/src/caffe/layers/malis_loss_layer.cpp
26+
index dae3c7d1..68e8323a 100644
27+
--- a/src/caffe/layers/malis_loss_layer.cpp
28+
+++ b/src/caffe/layers/malis_loss_layer.cpp
29+
@@ -1,6 +1,6 @@
30+
#include <boost/pending/disjoint_sets.hpp>
31+
-#include <opencv2/highgui/highgui.hpp>
32+
-#include <opencv2/imgproc/imgproc.hpp>
33+
+//#include <opencv2/highgui/highgui.hpp>
34+
+//#include <opencv2/imgproc/imgproc.hpp>
35+
36+
#include <algorithm>
37+
#include <cfloat>

src/openpose/core/arrayCpuGpu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ namespace op
583583
{
584584
try
585585
{
586-
#if defined(USE_CAFFE) && defined(USE_CUDA)
586+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
587587
return spImpl->pCaffeBlobT->gpu_shape();
588588
#else
589589
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
@@ -602,7 +602,7 @@ namespace op
602602
{
603603
try
604604
{
605-
#if defined(USE_CAFFE) && defined(USE_CUDA)
605+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
606606
return spImpl->pCaffeBlobT->gpu_data();
607607
#else
608608
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
@@ -621,7 +621,7 @@ namespace op
621621
{
622622
try
623623
{
624-
#if defined(USE_CAFFE) && defined(USE_CUDA)
624+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
625625
spImpl->pCaffeBlobT->set_gpu_data(data);
626626
#else
627627
UNUSED(data);
@@ -657,7 +657,7 @@ namespace op
657657
{
658658
try
659659
{
660-
#if defined(USE_CAFFE) && defined(USE_CUDA)
660+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
661661
return spImpl->pCaffeBlobT->gpu_diff();
662662
#else
663663
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
@@ -694,7 +694,7 @@ namespace op
694694
{
695695
try
696696
{
697-
#if defined(USE_CAFFE) && defined(USE_CUDA)
697+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
698698
return spImpl->pCaffeBlobT->mutable_gpu_data();
699699
#else
700700
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);
@@ -731,7 +731,7 @@ namespace op
731731
{
732732
try
733733
{
734-
#if defined(USE_CAFFE) && defined(USE_CUDA)
734+
#if defined(USE_CAFFE) && (defined(USE_CUDA) || defined(USE_OPENCL))
735735
return spImpl->pCaffeBlobT->mutable_gpu_diff();
736736
#else
737737
error("Required `USE_CAFFE` and `USE_CUDA` flags enabled.", __LINE__, __FUNCTION__, __FILE__);

0 commit comments

Comments
 (0)