caffe
- 注意点
1.git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git和直接网页下载区别,其中caffe-fast-rcnn @ 0dcd397是caffe源码
2 拷贝caffe源码里的Makefile.config.example,修改为Makefile.config,如果使用CPU计算,将CPU_ONLY := 1,WITH_PYTHON_LAYER := 1注释去掉,如果WITH_PYTHON_LAYER := 1注释,会报roi_pooling_param不能解析错误,另外caffe需要hdf5的支持,系统如果安装hdf5,但未配置头文件和库文件路径,可以在Makefile.config中添加如下:
(1)INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
(2)LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
3.进入源码目录 make -j8 && make pycaffe
4.进入py-fasrter-rcnn目录下的lib目录,执行python setup.py build_ext --inplace
5.下载训练好的模型,根据说明存放数据文件
6.需要protobuf3.0.0以下版本,否则draw_net.py运行出错.
7 .cmake . -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" -DUSE_CUDNN=OFF
tf-faster-rcnn
1.make.sh 需要tensorflow-gpu版本
#!/usr/bin/env bash
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
echo $TF_INC
CUDA_PATH=/usr/local/cuda/
cd roi_pooling_layer
#g++ -std=c++11 -shared -o roi_pooling.so roi_pooling_op.cc -D_GLIBCXX_USE_CXX11_ABI=0 \
#roi_pooling_op.cu.o -I $TF_INC -L $TF_LIB -ltensorflow_framework -D GOOGLE_CUDA=1 \
#-fPIC $CXXFLAGS -lcudart -L $CUDA_PATH/lib64
nvcc -std=c++11 -c -o roi_pooling_op.cu.o roi_pooling_op_gpu.cu.cc -D_GLIBCXX_USE_CXX11_ABI=0\
-I $TF_INC -L $TF_LIB -ltensorflow_framework -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -arch=sm_52
## if you install tf using already-built binary, or gcc version 4.x, uncomment the two lines below
#g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=0 -o roi_pooling.so roi_pooling_op.cc \
# roi_pooling_op.cu.o -I $TF_INC -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64
# for gcc5-built tf
g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=0 -o roi_pooling.so roi_pooling_op.cc \
roi_pooling_op.cu.o -I $TF_INC -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64
cd ..
# add building psroi_pooling layer
cd psroi_pooling_layer
nvcc -std=c++11 -c -o psroi_pooling_op.cu.o psroi_pooling_op_gpu.cu.cc\
-I $TF_INC -L $TF_LIB -ltensorflow_framework -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -arch=sm_52
g++ -std=c++11 -shared -o psroi_pooling.so psroi_pooling_op.cc -D_GLIBCXX_USE_CXX11_ABI=0 \
psroi_pooling_op.cu.o -I $TF_INC -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64
## if you install tf using already-built binary, or gcc version 4.x, uncomment the two lines below
#g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=0 -o psroi_pooling.so psroi_pooling_op.cc \
# psroi_pooling_op.cu.o -I $TF_INC -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64
cd ..