Thank you for sharing the instructions.
The conda conflict could be caused by that you installed conda for python3.
Currently, SINGA does not support python 3.
regards,
Wei
> Finally get the code to compile and run. Thanks a lot. Now I shall try to
> make training of a small network.
>
> (1) I tried using miniconda2 as suggested by you. But there is some
> conflict with my python3.6
> (2) So I get a fresh singa package from git hub, cmake and make, in
> between I needed a tweak :
>
> export CPLUS_INCLUDE_PATH=`/usr/bin/python -c "import numpy; print
>> numpy.get_include()"`:$CPLUS_INCLUDE_PATH
>>
> my numpy is accessible by python in /usr/bin/python
> (3) Step (2) will allow me to compile SINGA from source
> (4) Then I try to compile test.cc and modify the build.sh given by you to
> specify the -L paths according to where I put SINGA, I record my steps here.
>
> r-121-98-25-172:~ hweekuan$ conda config --add channels conda-forge
> r-121-98-25-172:~ hweekuan$ conda install -c nusdbsystem singa
> Fetching package metadata .............
> Solving package specifications: .
>
>
> UnsatisfiableError: The following specifications were found to be in
> conflict:
> - python 3.6*
> - singa -> protobuf 3.0.0 -> python 2.7*
> Use "conda info <package>" to see the dependencies for each package.
>
> =====================================
> # put glog here via brew
> brew install glog
> hweekuans-MacBook-Pro:my-test hweekuan$ ls /usr/local/lib/*glog*
> /usr/local/lib/libglog.0.dylib /usr/local/lib/libglog.a
> /usr/local/lib/libglog.dylib
> ======================================
> # edit the build.sh
> hweekuans-MacBook-Pro:my-test hweekuan$ more build.sh
> g++ test.cc -std=c++11 \
> -I/Users/hweekuan/incubator-singa20170320/build/include \
> -L/Users/hweekuan/incubator-singa20170320/build/lib \
> -L/usr/local/lib \
> -lsinga -lprotobuf -lglog -lopenblas -o test
> ==========================================
> # do this before running the executable
> export LD_LIBRARY_PATH=/Users/hweekuan/incubator-singa20170320/build/lib
> ======================================
> #compile
> ./build.sh
> ======================================
> # run test code test.cc as given by you, i added a line in the test.cc
> #int main(int argc, char** argv) {
> # testInt();
> # testFloat();
> # std::cout<<"hurray code runs "<<std::endl;
> # return 0;
> #}
> hweekuans-MacBook-Pro:my-test hweekuan$ ./test
> hurray code runs
> ===================================
>
>
>
>
> The error was caused by the compilation argument USE_GLOG.
> It was set to true when singa is compiled, but false when you compile the
> test program.
> I have updated the code to write it into the singa_config.h file, then you
> don't need to worry about its value.
> I tested the test program (https://gist.github.com/nudles/
> 6b0103abe2b539df1509ec3f52a379d7) on linux and macosx.
> singa should be installed via miniconda2 http://singa.apache.org/en/
> docs/installation.html#from-conda
>
> regards,
> Wei
>
>
>> You don't need to make install as long as all paths are set correctly.
>> I am working on it and would let you know my compilation scripts and
>> environment setting soon.
>> I have tried one simple test file (without GPU). It works.
>>
>>
>> On 14 Mar 2017, at 9:43 AM, Wang Wei <[email protected]> wrote:
>>
>> test_singa is now disabled by default as it slows down the compilation.
>> you can enable it via cmake -DENABLE_TEST=ON ..
>>
>> I will provide you an example of linking with libsinga later today.
>> Thanks.
>>
>> regards,
>> Wei
>>
>> On Tue, Mar 14, 2017 at 9:32 AM, Lee Hwee Kuan <[email protected]>
>> wrote:
>>
>>> i decided to do a clean re-install. now i face some new problems. please
>>> see log below. thanks.
>>>
>>>
>>> #uninstall the following:
>>>
>>> brew uninstall glog
>>> brew uninstall openblas
>>> brew uninstall protobuf
>>>
>>> # remove my old incubator-singa directory and recreate a new one using
>>> git
>>> #then make a clean reinstall and ask singa to get the openblas and
>>> protobuf for me
>>>
>>> git clone https://github.com/apache/incubator-singa.git
>>> cd incubator-singa/
>>>
>>> #try to see where is the numpy includes, first see where is my python
>>> hweekuans-MacBook-Pro:build hweekuan$ which python
>>> /usr/bin/python
>>>
>>> #hweekuans-MacBook-Pro:build hweekuan$ /usr/bin/python -c "import numpy;
>>> print numpy.get_include()"
>>> /System/Library/Frameworks/Python.framework/Versions/2.7/Ext
>>> ras/lib/python/numpy/core/include
>>>
>>> #then set the path
>>> export CPLUS_INCLUDE_PATH=`/usr/bin/python -c "import numpy; print
>>> numpy.get_include()"`:$CPLUS_INCLUDE_PATH
>>>
>>> $ mkdir build
>>> $ cd build
>>> $ cmake -DUSE_MODULES=ON ..
>>> $ make
>>>
>>> # compile message, looks like compile ok, no errors, only some warnings
>>> 6 warnings generated.
>>> [ 95%] Linking CXX shared library singa/_singa_wrap.dylib
>>> clang: warning: argument unused during compilation: '-pthread'
>>> clang: warning: argument unused during compilation: '-pthread'
>>> [ 99%] Built target _singa_wrap
>>> [100%] change .dylib to .so in mac system
>>> [100%] Built target change_suffix
>>>
>>> # but after that there is no test_singa in the bin directory
>>> hweekuans-MacBook-Pro:build hweekuan$ ls bin/
>>> protoc
>>>
>>>
>>>
>>> On 7 Mar 2017, at 8:14 PM, Wang Wei <[email protected]> wrote:
>>>
>>> Hi Zhongle,
>>>
>>> Did you ever encountered such error?
>>> How did you resolve it?
>>> Thanks.
>>>
>>> regards,
>>> Wei
>>>
>>>
>>>>
>>>> so i opt for option 2, link -lglog manually in my CMakeList.txt file.
>>>> delete build directory, reinvoke "cmake ../“ and then make. howevery i got
>>>> the same errors as before
>>>> —————————
>>>> 175 [100%] Linking CXX executable mytest
>>>> 176 Undefined symbols for architecture x86_64:
>>>> 177 "singa::logging::LogMessageFatal::LogMessageFatal(char const*,
>>>> int)", referenced from:
>>>> 178 singa::Block::data() const in mytest.cc.o
>>>> 179 "singa::logging::LogMessageFatal::~LogMessageFatal()",
>>>> referenced from:
>>>> 180 singa::Block::data() const in mytest.cc.o
>>>> 181 ld: symbol(s) not found for architecture x86_64
>>>> 182 clang: error: linker command failed with exit code 1 (use -v to
>>>> see invocation)
>>>> 183 make[2]: *** [mytest] Error 1
>>>> 184 make[1]: *** [CMakeFiles/mytest.dir/all] Error 2
>>>> 185 make: *** [all] Error 2
>>>>
>>>>
>>>> hk
>>>>
>>>>
>>>>>
>>>>> i managed to assign values to Tensor object and compile. when i wish
>>>>> to check if the values are correctly assigned, i found that i cannot link
>>>>> to implementation of LogMessageFatal class. i try to dig at where is the
>>>>> implementation and also change my CMakeLists.txt to manually link
>>>>> libraries
>>>>> but unable to get it to work. line 15 of the mytest.cc leads to
>>>>> error, try to call data() function and data() function calls block->data()
>>>>> which leads to linking errors. may i know in which library you put
>>>>> LogMessageFatal implementation at? I linked everything in
>>>>> incubator-singa/build/lib directory. thanks again.
>>>>>
>>>>> below is cut-and-paste code segments of LogMessageFatal, compile
>>>>> errors, mytest.cc and CMakeList.txt
>>>>>
>>>>> hk
>>>>>
>>>>>
>>>>> /Users/hweekuan/incubator-singa/src/utils/logging.cc
>>>>>
>>>>> 112 LogMessage::~LogMessage() { GenerateLogMessage(); }
>>>>> 113
>>>>> 114 LogMessageFatal::LogMessageFatal(const char* file, int line)
>>>>> 115 : LogMessage(file, line, FATAL) {}
>>>>> 116 LogMessageFatal::~LogMessageFatal() {
>>>>> 117 // abort() ensures we don't return
>>>>> 118 GenerateLogMessage();
>>>>> 119 abort();
>>>>> 120 }
>>>>>
>>>>> ====================
>>>>> hweekuans-MacBook-Pro:buid hweekuan$ make
>>>>> [ 50%] *Linking CXX executable mytest*
>>>>> Undefined symbols for architecture x86_64:
>>>>> "singa::logging::LogMessageFatal::LogMessageFatal(char const*,
>>>>> int)", referenced from:
>>>>> singa::Block::data() const in mytest.cc.o
>>>>> "singa::logging::LogMessageFatal::~LogMessageFatal()", referenced
>>>>> from:
>>>>> singa::Block::data() const in mytest.cc.o
>>>>> ld: symbol(s) not found for architecture x86_64
>>>>> clang: error: linker command failed with exit code 1 (use -v to see
>>>>> invocation)
>>>>> make[2]: *** [mytest] Error 1
>>>>> make[1]: *** [CMakeFiles/mytest.dir/all] Error 2
>>>>> make: *** [all] Error 2
>>>>>
>>>>> ========================
>>>>> 1 #include "singa/model/metric.h"
>>>>> 2
>>>>> 3 namespace singa {
>>>>> 4
>>>>> 5 void Train() {
>>>>> 6
>>>>> 7 const size_t train_size = 10;
>>>>> 8 Tensor train_x(Shape{train_size,1});
>>>>> 9 int tx[train_size];
>>>>> 10
>>>>> 11 for(unsigned int i=0;i<train_size;++i) { tx[i] = 1; }
>>>>> 12 train_x.CopyDataFromHostPtr(tx,train_size);
>>>>> 13
>>>>> 14 // read back and see if this is correct
>>>>> 15 const int * rx = train_x.data<int>(); // ## error generate from
>>>>> this line
>>>>> 16 // train_x.GetValue(rx,train_size);
>>>>> 17 }
>>>>> 18 } // namespace singa
>>>>> 19
>>>>> 20 int main(int argc, char **argv) { singa::Train(); }
>>>>>
>>>>> =============================================
>>>>> 19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
>>>>> 20
>>>>> 21 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
>>>>> 22
>>>>> 23 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
>>>>> 24 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
>>>>> 25 INCLUDE_DIRECTORIES(/Users/hweekuan/incubator-singa/include )
>>>>> 26 INCLUDE_DIRECTORIES(/Users/hweekuan/incubator-singa/build/include
>>>>> )
>>>>> 27
>>>>> 28 # mannually set library to link
>>>>> 29 SET( SINGA_LIB_PATH -L/Users/hweekuan/incubator-singa/build/lib/)
>>>>> 30 SET( SINGA_LIB -lgtest -lopenblas -lopenblas -
>>>>> lopenblas_haswellp-r0.2.16.dev
>>>>> 31 -lprotobuf-lite -lprotobuf -lprotoc -lsinga)
>>>>> 32
>>>>> 33 ADD_EXECUTABLE(mytest mytest.cc)
>>>>> 34 TARGET_LINK_LIBRARIES(mytest ${SINGA_LIB_PATH} ${SINGA_LIB} )
>>>>> 35
>>>>> 36 # ------ commented out lines here -------------------
>>>>> 37 #SET( PROJECT_LINK_LIBS singa )
>>>>> 38 #LINK_DIRECTORIES( /Users/hweekuan/incubator-singa/build/lib )
>>>>> 39 #ADD_DEPENDENCIES(mytest singa)
>>>>> 40 #TARGET_LINK_LIBRARIES(mytest singa)
>>>>>
>>>>> ===========================
>>>>>
>>>>
>>
>
>