how to install py-faster-rcnn on Jetson TX1? - caffe

I want to install py-faster-rcnn on TX1,and I followed https://devtalk.nvidia.com/default/topic/974063/jetson-tx1/caffe-failed-with-py-faster-rcnn-demo-py-on-tx1/ ,modify the /caffe-fast-rcnn/Makefile and /caffe-fast-rcnn/Makefile.config, but when I try to make it,the problem appears:
ubuntu#tegra-ubuntu:~/py-faster-rcnn/caffe-fast-rcnn$ make
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/layer_factory.cpp
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layer.hpp:8,
from src/caffe/layer_factory.cpp:8:
./include/caffe/util/cudnn.hpp: In function ‘void
caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**,
caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int,
int, int, int, int)’:
./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to
function ‘cudnnStatus_t
cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t,
cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int,
int)’
pad_h, pad_w, stride_h, stride_w));
^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro
‘CUDNN_CHECK’
cudnnStatus_t status = condition; \
^
In file included from ./include/caffe/util/cudnn.hpp:5:0,
from ./include/caffe/util/device_alternate.hpp:40,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layer.hpp:8,
from src/caffe/layer_factory.cpp:8:
/usr/include/cudnn.h:803:27: note: declared here
cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetTanHLayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:237:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetTanHLayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:237:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetSoftmaxLayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:214:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetSoftmaxLayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:214:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetSigmoidLayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:191:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetSigmoidLayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:191:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetReLULayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:168:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetReLULayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:168:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetLRNLayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:145:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetLRNLayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:145:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetPoolingLayer(const
caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layer_factory.cpp:108:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::GetPoolingLayer(const
caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layer_factory.cpp:108:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> >
caffe::GetConvolutionLayer(const caffe::LayerParameter&) [with Dtype =
double]’:
src/caffe/layer_factory.cpp:71:1: warning: control reaches end of non-
void function [-Wreturn-type]
}
^
src/caffe/layer_factory.cpp: In function
‘boost::shared_ptr<caffe::Layer<Dtype> >
caffe::GetConvolutionLayer(const caffe::LayerParameter&) [with Dtype =
float]’:
src/caffe/layer_factory.cpp:71:1: warning: control reaches end of non-
void function [-Wreturn-type]
}
^
Makefile:564: recipe for target
'.build_release/src/caffe/layer_factory.o' failed
make: *** [.build_release/src/caffe/layer_factory.o] Error 1
how to solve this?
thanks

I solved it,maybe the original py-faster-rcnn don't support cudnnv5 very well,so i copy the following files from /caffe to /py-faster-rcnn/caffe-fast-rcnn:
include/caffe/util/:cudnn.hpp
src/caffe/layers/:cudnn_conv_layer.cu
cudnn_relu_layer.cpp
cudnn_relu_layer.cu
cudnn_sigmoid_layer.cpp
cudnn_sigmoid_layer.cu
cudnn_tanh_layer.cpp
cudnn_tanh_layer.cu
include/caffe/layers/:cudnn_relu_layer.hpp
cudnn_sigmoid_layer.hpp
cudnn_tanh_layer.hpp
and it works.

Here is a solution that worked for me.
Merge caffe master branch into caffe-fast-rcnn.
cd caffe-fast-rcnn
git remote add caffe https://github.com/BVLC/caffe.git
git fetch caffe
git merge -X theirs caffe/master
Remove self_.attr("phase") = static_cast<int>(this->phase_); from include/caffe/layers/python_layer.hpp after merging.
I got it from here.

Related

Unable to call Device function in Cuda Fortran

I am trying to create a Linked list in Cuda Fortran, but when I am trying to call device functions from the kernel, I get a compilation error. Could someone please explain to me why …?
Sample code calling function InsertList is pasted below.
file :p5.f95
MODULE ListModule
IMPLICIT NONE
TYPE ListElem
REAL :: value;
TYPE(ListElem), POINTER :: next;
END TYPE ListElem
CONTAINS
ATTRIBUTES(DEVICE) FUNCTION InsertList(head, elem)
IMPLICIT NONE
type( ListElem ), pointer :: head, elem
type( ListElem ), pointer :: InsertList
elem%next => head
InsertList => elem
END FUNCTION InsertList
END MODULE
MODULE Test
CONTAINS
ATTRIBUTES(GLOBAL) SUBROUTINE KERNEL()
USE ListModule
IMPLICIT NONE
type( ListElem ), pointer :: head
type( ListElem ), pointer :: newElem, h
integer :: i,N = 4
INTEGER(KIND=4),ALLOCATABLE::ND(:)
nullify( head )
allocate( newElem )
newElem%value=1
PRINT*,newElem%value
head => InsertList(head, newElem)
END SUBROUTINE
END MODULE Test
PROGRAM LinkedList
USE TEST
USE CUDAFOR
integer :: N
CALL KERNEL<<<1,1>>>()
N=cudaDeviceSynchronize()
END PROGRAM LinkedList
compilation command:pgf95 -cuda -gpu=rdc p5.f95
Error:
nvvmCompileProgram error 9: NVVM_ERROR_COMPILATION.
Error: /tmp/pgcudaforNnQ1wgcS2LZ.gpu (27, 26): parse use of undefined value '%sym_insertlist_p_356'
ptxas /tmp/pgcudaforxnQf5cb9zEu.ptx, line 1; fatal : Missing .version directive at start of file '/tmp/pgcudaforxnQf5cb9zEu.ptx'
ptxas fatal : Ptx assembly aborted due to errors
NVFORTRAN-F-0155-Compiler failed to translate accelerator region (see -Minfo messages): Device compiler exited with error status code (p5.f95: 1)
NVFORTRAN/x86-64 Linux 21.7-0: compilation aborted

fortran cudamalloc and cublassetmatrix wrapper problem

I maybe a problem, either with "cudamalloc" or "cublassetmatrix" not appropriately called from fortran:
module cuda
interface
integer (C_INT) function cudaMallocHost(buffer, size) bind(C,name="cudaMallocHost")
use iso_c_binding
implicit none
type (C_PTR) :: buffer
integer (C_SIZE_T), value :: size
end function cudaMallocHost
integer (C_INT) function cudaFreeHost(buffer) bind(C,name="cudaFreeHost")
use iso_c_binding
implicit none
type (C_PTR), value :: buffer
end function cudaFreeHost
integer (C_INT) function cudaMalloc(buffer, size) bind(C,name="cudaMalloc")
use iso_c_binding
implicit none
type (C_PTR) :: buffer
integer (C_SIZE_T), value :: size
end function cudaMalloc
integer (C_INT) function cudaFree(buffer) bind(C,name="cudaFree")
use iso_c_binding
implicit none
type (C_PTR), value :: buffer
end function cudaFree
integer (C_INT) function cublassetmatrix(M,N,size,A_host,lda_h&
&,A_dev,lda_d) bind(C,name="cublasSetMatrix")
use iso_c_binding
implicit none
type (C_PTR) :: A_dev
type(c_ptr) :: A_host
integer (C_SIZE_T), value :: size
integer(C_Int) :: M,N,lda_h,lda_d
end function cublassetmatrix
Type(c_ptr) function cudaGetErrorString(err) bind(C,name="cudaGetErrorString")
use iso_c_binding
implicit none
integer (C_SIZE_T), value :: err
end function cudaGetErrorString
integer (C_INT) function cublasCreate(handle) bind(C,name="cublasCreate_v2")
use iso_c_binding
implicit none
Type(C_Ptr) :: handle
end function cublasCreate
end interface
end module cuda
program test
use iso_c_binding
use cuda
implicit none
integer, parameter :: fp_kind = kind(0.0)
type(C_PTR) :: cptr_A, cptr_A_D
real (fp_kind), dimension(:,:), pointer :: A=>null()
real :: time_start,time_end
integer:: i,j, res, m1
integer(c_int) :: x
type(c_ptr) :: handle
logical:: lsexit
CHARACTER(len=50), POINTER :: errchar
m1=500
res=cublasCreate(handle)
if(res/=0) Then
write(*,*) "ERROR 1 ",res;
end if
res = cudaMallocHost ( cptr_A, m1*m1*sizeof(fp_kind) )
if(res/=0) Then
write(*,*) "ERROR 2 ",res;
end if
call c_f_pointer ( cptr_A, A, (/ m1, m1 /) )
A=1._fp_kind
res = cudaMalloc ( cptr_A_D, m1*m1*sizeof(fp_kind) )
if(res/=0) Then
write(*,*) "ERROR 3 ",res;
end if
res=cublasSetMatrix (m1,m1,sizeof(fp_kind),cptr_A,m1,cptr_A_D,m1)
if(res/=0) Then
write(*,*) "ERROR 4 ",res,sizeof(fp_kind)
call c_f_pointer ( cudageterrorstring(int(res,kind=8)),&
& errchar, [ len(errchar) ] )
write(*,*) trim(adjustl(errchar))
end if
end program test
The make command is:
tmp:
ifort -O3 -o tmp $(FFLAGS) tmp.f90 -L/opt/cuda/lib64 -lcublas -lcudart
clean:
rm tmp cuda.mod
Although "cudamallochost" expects "void ** ptr" it seems to work as the fortran pointer is usable, and when put in a loop with "cudafree" does not produce memory leaks.
The code fails at "cublassetmatrix" function either with error code 7 ("too many resources") or 11 ("invalid argument").
Any idea?

Clang-tidy false positive with boost::variant

When running clang-tidy on this minimal example posted below I get the (imho) false positive error from clang-tidy (full error trace at the end)
Value assigned to field 'id' in implicit constructor is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
The code does nothing but assign a boost::variant to one of the two values. The error is gone if I replace the copy constructor by Size(const Size& sz) = default;. However, I cannot do this, since the Size is a cv::Size in the real code.
Even though it might not be as elegant as possible, I don't see any error with this. Can somebody point me into the direction if I am mistaken, clang-tidy or boost.
#include <boost/variant.hpp>
class Size
{
public:
Size() = default;
Size(const Size &sz) : width(sz.width) {}
int width{0};
};
struct B {
Size size;
};
struct A {
Size size;
uint32_t id{0};
};
int main() {
using T = boost::variant<A, B>;
T config = B();
}
I am running:
clang-tools-extra commit 50fe75789f08b96284d2c14cb6583b3783c74460
llvm commit afb8c1fed21eb4848d86f2d28e9cb3afcfbb2656
boost 1.67
Full error dump:
test_variant.cc:15:8: warning: Value assigned to field 'id' in implicit constructor is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
struct A {
^
test_variant.cc:22:5: note: Calling move constructor for 'variant'
T config = B();
^
libraries/boost/include/boost/variant/variant.hpp:1880:9: note: Calling 'variant::internal_apply_visitor'
operand.internal_apply_visitor(visitor);
^
libraries/boost/include/boost/variant/variant.hpp:2466:16: note: Calling 'variant::internal_apply_visitor_impl'
return internal_apply_visitor_impl(
^
libraries/boost/include/boost/variant/variant.hpp:2452:16: note: Calling 'visitation_impl'
return detail::variant::visitation_impl(
^
libraries/boost/include/boost/variant/detail/visitation_impl.hpp:225:5: note: Control jumps to 'case 0:' at line 238
switch (logical_which)
^
libraries/boost/include/boost/variant/detail/visitation_impl.hpp:240:11: note: Calling 'visitation_impl_invoke'
, BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE
^
libraries/boost/include/boost/preprocessor/repetition/repeat.hpp:29:26: note: expanded from macro 'BOOST_PP_REPEAT'
# define BOOST_PP_REPEAT BOOST_PP_CAT(BOOST_PP_REPEAT_, BOOST_PP_AUTO_REC(BOOST_PP_REPEAT_P, 4))
^
libraries/boost/include/boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT'
# define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b)
^
libraries/boost/include/boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I'
# define BOOST_PP_CAT_I(a, b) a ## b
^
note: (skipping 21 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
libraries/boost/include/boost/preprocessor/repetition/repeat.hpp:53:56: note: expanded from macro 'BOOST_PP_REPEAT_1_2'
# define BOOST_PP_REPEAT_1_2(m, d) BOOST_PP_REPEAT_1_1(m, d) m(2, 1, d)
^
libraries/boost/include/boost/preprocessor/repetition/repeat.hpp:52:36: note: expanded from macro 'BOOST_PP_REPEAT_1_1'
# define BOOST_PP_REPEAT_1_1(m, d) m(2, 0, d)
^
libraries/boost/include/boost/variant/detail/visitation_impl.hpp:231:16: note: expanded from macro 'BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE'
return (visitation_impl_invoke)( \
^
libraries/boost/include/boost/variant/detail/visitation_impl.hpp:154:12: note: Calling 'visitation_impl_invoke_impl'
return (visitation_impl_invoke_impl)(
^
libraries/boost/include/boost/variant/detail/visitation_impl.hpp:112:12: note: Calling 'move_into::internal_visit'
return visitor.internal_visit(
^
libraries/boost/include/boost/variant/variant.hpp:507:23: note: Calling implicit move constructor for 'A'
new(storage_) T(::boost::detail::variant::move(operand));
^
test_variant.cc:15:8: note: Value assigned to field 'id' in implicit constructor is garbage or undefined
struct A {

GNU Octave print_usage usage

If I define this function in a file
function retval = my_fact (N)
if nargin ~= 1
print_usage ()
endif
retval = factorial (N)
endfunction
and call it from an interactive session, I get
>> my_fact ()
error: print_usage: 'my_fact' not found
My question is: Where should I write a "docstring" for factorial or the string I want octave to display?

build gcc4.9 under suse10 some vars was not declared

I build gcc4.9 with the following step
wget ftp://mirrors.kernel.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
tar -zxvf gcc-4.9.0.tar.gz
cd gcc-4.9.0
./contrib/download_prerequisites
cd ..
mkdir gcc-build-4.9.0
cd gcc-build-4.9.0
../gcc-4.9.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j4
it show the error message:
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:232:27: error: ‘PTRACE_GETSIGINFO’ was not declared in this scope
int ptrace_getsiginfo = PTRACE_GETSIGINFO;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:233:27: error: ‘PTRACE_SETSIGINFO’ was not declared in this scope
int ptrace_setsiginfo = PTRACE_SETSIGINFO;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:390:30: error: ‘EVIOCGREP’ was not declared in this scope
unsigned IOCTL_EVIOCGREP = EVIOCGREP;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:399:30: error: ‘EVIOCSREP’ was not declared in this scope
unsigned IOCTL_EVIOCSREP = EVIOCSREP;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:682:36: error: ‘FS_IOC_GETFLAGS’ was not declared in this scope
unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:683:38: error: ‘FS_IOC_GETVERSION’ was not declared in this scope
unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:684:36: error: ‘FS_IOC_SETFLAGS’ was not declared in this scope
unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
^
../../../../gcc-4.9.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:685:38: error: ‘FS_IOC_SETVERSION’ was not declared in this scope
unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
^
make[4]: *** [sanitizer_platform_limits_posix.lo] Error 1
I try to rebuild, but it show the error again.