How to Install Caffe (Deep Learning Framework)?

Hello,

I'm trying to build Caffe from it's github source (This is the OpenCL version of Caffe):

Getting the following error after doing:

cmake -DBLAS=open -DUSE_OPENCL=ON -DUSE_CLGEMM=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TIMER=ON -DCMAKE_INSTALL_PREFIX=debug -DclBLAS_INCLUDE_DIR=/usr/
local/include/ -DclBLAS_LIB=/usr/local/lib/libclBLAS.so ..


Here is the error from terminal:

Code:
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at cmake/Misc.cmake:32 (set):
  implicitly converting 'BOOLEAN' to 'STRING' type.
Call Stack (most recent call first):
  CMakeLists.txt:25 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:8 (find_package)
  CMakeLists.txt:49 (include)


CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:8 (find_package)
  CMakeLists.txt:49 (include)


CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:8 (find_package)
  CMakeLists.txt:49 (include)


CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:8 (find_package)
  CMakeLists.txt:49 (include)


CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:8 (find_package)
  CMakeLists.txt:49 (include)


-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found Boost: /usr/local/include (found suitable version "1.80.0", minimum required is "1.54") found components: system thread filesystem chrono atomic
-- Found GFlags: /usr/local/include
-- Found gflags  (include: /usr/local/include, library: /usr/local/lib/libgflags.so)
-- Found Glog: /usr/local/include
-- Found glog    (include: /usr/local/include, library: /usr/local/lib/libglog.so)
-- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.20.1")
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Found HDF5: hdf5-shared;hdf5_cpp-shared (found version "1.12.2") found components: HL
-- Found LMDB: /usr/local/include
-- Found lmdb    (include: /usr/local/include, library: /usr/local/lib/liblmdb.so)
-- Found LevelDB: /usr/local/include
-- Found LevelDB (include: /usr/local/include, library: /usr/local/lib/libleveldb.so)
-- Found Snappy: /usr/local/include
-- Found Snappy  (include: /usr/local/include, library: /usr/local/lib/libsnappy.so)
-- -- CUDA is disabled. Building without it...
-- OpenCV found (/usr/local/lib/cmake/opencv4)
-- Found OpenBLAS libraries: /usr/local/lib/libopenblas.so
-- Found OpenBLAS include: /usr/local/include
-- Found PythonInterp: /usr/local/bin/python (found suitable version "3.9.13", minimum required is "2.7")
-- Found PythonLibs: /usr/local/lib/libpython3.9.so (found suitable version "3.9.13", minimum required is "2.7")
-- Found NumPy: /usr/local/lib/python3.9/site-packages/numpy/core/include (found suitable version "1.22.4", minimum required is "1.7.1")
-- NumPy ver. 1.22.4 found (include: /usr/local/lib/python3.9/site-packages/numpy/core/include)
CMake Warning at /usr/local/share/cmake/Modules/FindBoost.cmake:1390 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindBoost.cmake:1513 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/local/share/cmake/Modules/FindBoost.cmake:2124 (_Boost_MISSING_DEPENDENCIES)
  cmake/Dependencies.cmake:180 (find_package)
  CMakeLists.txt:49 (include)


-- Could NOT find Boost (missing: python) (found suitable version "1.80.0", minimum required is "1.46")
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Python interface is disabled or not all required dependencies found. Building without it...
-- Found Git: /usr/local/bin/git (found version "2.37.1")
--
-- ******************* Caffe Configuration Summary *******************
-- General:
--   Version           :   1.0.0
--   Git               :   1.0-136-g9b891540-dirty
--   System            :   FreeBSD
--   C++ compiler      :   /usr/bin/c++
--   Release CXX flags :   -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Debug CXX flags   :   -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Build type        :   Debug
--
--   BUILD_SHARED_LIBS :   ON
--   BUILD_python      :   ON
--   BUILD_matlab      :   OFF
--   BUILD_docs        :   ON
--   CPU_ONLY          :   ON
--   USE_OPENCV        :   ON
--   USE_LEVELDB       :   ON
--   USE_LMDB          :   ON
--   USE_NCCL          :   OFF
--   ALLOW_LMDB_NOLOCK :   OFF
--   USE_HDF5          :   ON
--
-- Dependencies:
--   BLAS              :   Yes (open)
--   Boost             :   Yes (ver. 1.80)
--   glog              :   Yes
--   gflags            :   Yes
--   protobuf          :   Yes (ver. ..)
--   lmdb              :   Yes (ver. 0.9.29)
--   LevelDB           :   Yes (ver. 1.23)
--   Snappy            :   Yes (ver. 1.1.9)
--   OpenCV            :   Yes (ver. 4.6.0)
--   CUDA              :   No
--
-- Documentaion:
--   Doxygen           :   No
--   config_file       :  
--
-- Install:
--   Install path      :   /usr/home/user/caffe/build/debug
--
-- Configuring done
CMake Error at CMakeLists.txt:107 (add_dependencies):
  The dependency target "pycaffe" of target "pytest" does not exist.


-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    USE_CLGEMM
    USE_OPENCL
    USE_TIMER
    clBLAS_INCLUDE_DIR
    clBLAS_LIB


CMake Generate step failed.  Build files cannot be regenerated correctly.

Here is the cmake error log file:

Code:
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /usr/home/user/caffe/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/gmake -f Makefile cmTC_ff720/fast && /usr/local/bin/gmake  -f CMakeFiles/cmTC_ff720.dir/build.make CMakeFiles/cmTC_ff720.dir/build
gmake[1]: Entering directory '/usr/home/user/caffe/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_ff720.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD   -MD -MT CMakeFiles/cmTC_ff720.dir/src.c.o -MF CMakeFiles/cmTC_ff720.dir/src.c.o.d -o CMakeFiles/cmTC_ff720.dir/src.c.o -c /usr/home/user/caffe/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_ff720
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ff720.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_ff720.dir/src.c.o -o cmTC_ff720
ld: error: undefined symbol: pthread_create
>>> referenced by src.c
>>>               CMakeFiles/cmTC_ff720.dir/src.c.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_ff720.dir/build.make:100: cmTC_ff720] Error 1
gmake[1]: Leaving directory '/usr/home/user/caffe/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_ff720/fast] Error 2


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /usr/home/user/caffe/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/gmake -f Makefile cmTC_d6901/fast && /usr/local/bin/gmake  -f CMakeFiles/cmTC_d6901.dir/build.make CMakeFiles/cmTC_d6901.dir/build
gmake[1]: Entering directory '/usr/home/user/caffe/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d6901.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -MD -MT CMakeFiles/cmTC_d6901.dir/CheckFunctionExists.c.o -MF CMakeFiles/cmTC_d6901.dir/CheckFunctionExists.c.o.d -o CMakeFiles/cmTC_d6901.dir/CheckFunctionExists.c.o -c /usr/local/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTC_d6901
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d6901.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_d6901.dir/CheckFunctionExists.c.o -o cmTC_d6901  -lpthreads
ld: error: unable to find library -lpthreads
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_d6901.dir/build.make:100: cmTC_d6901] Error 1
gmake[1]: Leaving directory '/usr/home/user/caffe/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_d6901/fast] Error 2


The FreeBSD Ports for Caffe is deprecated:

Any advice will be appreciated,

Thanks.
 
Thanks

Edit:

Alright, I wasn't able to install Caffe from the old ports tree.

However, I was able to install Caffe from it's GitHub. I spoke with some "C++ General" group from IRC channel.
It was best to simply not focus on getting python to work. Caffe fully compiles on FreeBSD 13.1 with C++ (as expected), it was tricky to get it to work.

I'll post the details later what I did to make Caffe to build install from source on FreeBSD, but it's only without Python.

We also determined that using FreeBSD Jails, building Caffe with installing deprecated versions of python should work perfectly. I haven't tried this.

I also messaged maintainers about the Caffe port being deleted, one of the maintainers might resurrect it.
 
Last edited:
Back
Top