josephjaspers / blackcat_tensors

Matrix-Vector Library Designed for Neural Network Construction. cuda (gpu) support, openmp (multithreaded cpu) support, partial support of BLAS, expression template based implementation PTX code generation identical to hand written kernels, and support for auto-differentiation
12 stars 4 forks source link

linux makefile error! #20

Closed xinsuinizhuan closed 5 years ago

xinsuinizhuan commented 5 years ago

When i compile the project under linux, some errors(what should i do,what dependences are missing?) : MNIST_Test.h:113:2: note: suggested alternatives: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/5/cwchar:44, from /usr/include/c++/5/bits/postypes.h:40, from /usr/include/c++/5/iosfwd:40, from /usr/include/c++/5/ios:38, from /usr/include/c++/5/ostream:38, from /usr/include/c++/5/iostream:39, from ../include/BlackCat_Common.h:95, from ../include/BlackCat_Tensors.h:9, from MNIST_Test.cpp:11: /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:216:23: note: ‘size_t’ typedef SIZE_TYPE size_t; ^ In file included from /usr/include/c++/5/iostream:38:0, from ../include/BlackCat_Common.h:95, from ../include/BlackCat_Tensors.h:9, from MNIST_Test.cpp:11: /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:196:26: note: ‘std::size_t’ typedef SIZE_TYPE size_t; ^ /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:196:26: note: ‘std::size_t’ In file included from MNIST_Test.cpp:12:0: MNIST_Test.h:114:7: error: expected ‘;’ before ‘img’ cube img = cube(reshape(inputs[0])(28,28, BATCH_SIZE)); ^ MNIST_Test.h:115:2: error: ‘mat’ was not declared in this scope mat hyps = mat(network.forward_propagation(inputs[0])); ^ MNIST_Test.h:117:22: error: ‘test_images’ was not declared in this scope for (int i = 0; i < test_images; ++i) { ^ MNIST_Test.h:118:3: error: ‘img’ was not declared in this scope img[i].printSparse(3); ^ MNIST_Test.h:119:3: error: ‘hyps’ was not declared in this scope hyps[i].print(); ^ In file included from ../include/BlackCat_Stream.h:10:0, from ../include/BlackCat_Tensors.h:12, from MNIST_Test.cpp:11: ../include/BlackCat_Memory.h: In instantiation of ‘int BC::memory::atomic_shared_ptr::operator->() [with ValueType = BC::streams::Stream::Contents]’: ../include/streams/Host.h:44:23: required from here ../include/BlackCat_Memory.h:89:40: error: cannot convert ‘BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>::wrapper’ to ‘int’ in return auto operator ->() { return this->get(); } ^ ../include/BlackCat_Memory.h: In instantiation of ‘bool BC::memory::atomic_shared_ptr::operator==(const BC::memory::atomic_shared_ptr&) [with ValueType = BC::streams::Stream::Contents]’: ../include/streams/Host.h:61:45: required from here ../include/BlackCat_Memory.h:93:20: error: ‘const class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘m_ptr’ return ptr.m_ptr == this->m_ptr; ^ ../include/BlackCat_Memory.h:93:20: error: ‘class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘m_ptr’ ../include/BlackCat_Memory.h: In instantiation of ‘BC::memory::atomic_shared_ptr& BC::memory::atomic_shared_ptr::operator=(const BC::memory::atomic_shared_ptr&) [with ValueType = BC::streams::Stream::Contents]’: ../include/streams/Host.h:65:14: required from here ../include/BlackCat_Memory.h:100:35: error: ‘class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘locker’ std::lock_guard lck1(this->locker); ^ ../include/BlackCat_Memory.h:100:35: error: ‘lck1’ was not declared in this scope ../include/BlackCat_Memory.h:101:35: error: ‘const class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘locker’ std::lock_guard lck2(ptr.locker); ^ ../include/BlackCat_Memory.h:101:35: error: ‘lck2’ was not declared in this scope ../include/BlackCat_Memory.h:102:15: error: ‘class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘m_ptr’ this->m_ptr = ptr.m_ptr; ^ ../include/BlackCat_Memory.h:102:15: error: ‘const class BC::memory::atomic_shared_ptr<BC::streams::Stream::Contents>’ has no member named ‘m_ptr’ Makefile:14: recipe for target 'all' failed make: *** [all] Error 1

josephjaspers commented 5 years ago

Based upon /usr/include/c++/5/ It seems you are using GCC-5? The oldest compiler I have tested on is 7.4.

(Check "Tested Compilers") https://github.com/josephjaspers/BlackCat_Tensors/blob/master/README.md

Let me know if this solves your problem


Also, I've updated the makefile. You must add to your path 'cblas.h' and the correct 'cblas' library. If cblas.h and -l cblas are already on your path, you should not need to make any changes.

CXXFLAGS = -O3 -o mnist_test_exec
CUFLAGS = -O3 -o mnist_test_exec_cu  -gencode arch=compute_52,code=sm_52

CXXFILES = MNIST_Test.cpp
CUFILES  = MNIST_Test.cu

LIBS = -lcblas
ATLASLIBS = -lcblas -latlas -lf77blas
CULIBS = -lcublas

INCLUDE = ../include/ 

#LIBINCLUDE = <PATH TO YOUR BLAS DIRECTORY> 
LIBINCLUDE = /usr/libs/

#LIBATLASINCLUDE = <PATH TO YOUR ATLAS LIB, ONLY REQUIRED IF USING ATLAS-BLAS>
LIBATLASINCLUDE = /home/joseph/Library_Sources/ATLAS/Build/lib 
all:
    $(CXX) $(CXXFILES) $(LIBS) $(CXXFLAGS) -I $(INCLUDE) -L $(LIBINCLUDE)

atlas:
    $(CXX) $(CXXFILES) $(ATLASLIBS) $(CXXFLAGS) -I $(INCLUDE) -L $(LIBATLASINCLUDE)

cuda:
    nvcc $(CUFILES) $(CULIBS) $(CXXFLAGS) -I $(INCLUDE) -L $(LIBINCLUDE)

clean:
    rm -f prog *.o; rm mnist_test_exec; rm mnist_test_exec_cu;
xinsuinizhuan commented 5 years ago

thank you !Perhaps i do not set cblas include file and lib file, and do not have cuda, becasue i run it in my virtual machine.I still look forward to your visual studio 2015 support!

xinsuinizhuan commented 5 years ago

When i use the code current to compile, then many errors is appear, under ubuntu16.04.04, i have install openblas.

josephjaspers commented 5 years ago

Hi, I have made sure that my examples/tests now compile with 3 different compilers so I believe it should be very stable at this point.

Can you try...

sudo apt-get install gcc-7 #Install new GCC sudo update-alternatives --config gcc #select newest version sudo update-alternatives --config g++ #select newest version

.../blackcat_tensors-master/examples/mnist_test/ > make default

xinsuinizhuan commented 5 years ago

I excute the next commond: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-7 sudo apt-get install g++-7 sudo update-alternatives --config gcc #select newest version but the errors is still exist! I user VMware Workstation Pro ubuntu16.04.04 1564455132(1)

but the vmware workstation have no cuda

xinsuinizhuan commented 5 years ago

what is your execution environment and compiler?

josephjaspers commented 5 years ago

Tested Compilers: NVCC: 10, 10.1 GCC: 7.4, 8.0 MSVC: VS2019 (_MSC_VER=1921) //CPU-only Cling: 0.6 //CPU-only

I used Ubuntu 16.04 though I have also tested with Windows 10.

xinsuinizhuan commented 5 years ago

I send you my VS2015 project, i can compile normally? Can you Git your VS2019 project xx.sln?let me hava a try?