一、[libprotobuf FATAL google/protobuf/stubs/common.cc:61]
This program requires version 3.3.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1.
应该是安装完 caffe 后又安装 tensorflow 导致 protocol 的 C++ /Python版本之间的不兼容。其实 protocol 就是完成 .prototxt 的配置与底层代码之间的映射。。
solution:
- sudo pip2 uninstall protobuf
- sudo pip install -Iv protobuf==3.0a3
关于 protocol 详细理解:clink
二、Blob
blob( blob.hpp 和 blob.cpp )是一个使用 SyncedMemory 类(独立于 CPU / GPU )来管理内存的包装器,并且有一些处理类似 Python 中的数组函数,用于数据和梯度计算(diff)的数组包含在 blob 中。
初始化 blob:
Blob(const vector<int>& shape)
blob 中的函数 :
shape()
、shape_string()
返回 shape, orshape(i)
获取第 i 维, orshapeEquals()
比较shape 是否相同Reshape(const vector<int>& shape)
orreshapeLike(const Blob& other)
count()
元素总数 (shape(0)*shape(1)*...
)offset()
获取 array 中 的 c++ 索引CopyFrom()
拷贝 blobdata_at()
anddiff_at()
asum_data()
andasum_diff()
L1 normsumsq_data()
andsumsq_diff()
L1 normscale_data()
andscale_diff()
data 乘以一个 factorUpdate()
根据diff
数组更新data
array
在 CPU 模式下访问 Blob 中的 data :
const Dtype* cpu_data();
Dtype* mutable_cpu_data();
const Dtype* cpu_diff();
Dtype* mutable_cpu_diff();
GPU code :
const Dtype* gpu_data();
Dtype* mutable_gpu_data();
const Dtype* gpu_diff();
Dtype* mutable_gpu_diff();
Data transfer between GPU and CPU will be dealt automatically.
Caffe 提供一些抽象数据处理数据:
caffe_set()
andcaffe_gpu_set()
to initialize the data with a valuecaffe_add_scalar()
andcaffe_gpu_add_scalar()
to add a scalar to datacaffe_axpy()
andcaffe_gpu_axpy()
for y←ax+ycaffe_scal()
andcaffe_gpu_scal()
for x←axcaffe_cpu_sign()
andcaffe_gpu_sign()
for y←sign(x)caffe_cpu_axpby()
andcaffe_cpu_axpby
for y←a×x+b×ycaffe_copy()
to deep copycaffe_cpu_gemm()
andcaffe_gpu_gemm()
for matrix multiplication C←αA×B+βCcaffe_gpu_atomic_add()
when you need to update a value in an atomic way (such as requests in ACID databases but for gpu threads in this case)
… and further detail.