Caffe编译代码的时候报各种未定义未声明

自己装的CUDNN是一个版本,而运行别人的code时可能人家对应CUDNN的另一个版本,此时需要修改关键字来兼容版本,参考

1.

https://github.com/BVLC/caffe/issues/1792

https://github.com/BVLC/caffe/pull/1739

https://github.com/BVLC/caffe/pull/1739/commits/bb00447d9438a0b5adf3d5ca6b1dc1d4995a464f

 include/caffe/common_layers.hpp
@@ -407,8 +407,8 @@ class CuDNNSoftmaxLayer : public SoftmaxLayer<Dtype> {
    const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
   
    cudnnHandle_t handle_;
   - cudnnTensor4dDescriptor_t bottom_desc_;
   - cudnnTensor4dDescriptor_t top_desc_;
    + cudnnTensorDescriptor_t bottom_desc_;
    + cudnnTensorDescriptor_t top_desc_;
    };
    #endif
   
 
View 
12  include/caffe/neuron_layers.hpp
@@ -380,8 +380,8 @@ class CuDNNReLULayer : public ReLULayer<Dtype> {
    const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
   
    cudnnHandle_t handle_;
   - cudnnTensor4dDescriptor_t bottom_desc_;
   - cudnnTensor4dDescriptor_t top_desc_;
    + cudnnTensorDescriptor_t bottom_desc_;
    + cudnnTensorDescriptor_t top_desc_;
    };
    #endif
   
@@ -464,8 +464,8 @@ class CuDNNSigmoidLayer : public SigmoidLayer<Dtype> {
    const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
   
    cudnnHandle_t handle_;
   - cudnnTensor4dDescriptor_t bottom_desc_;
   - cudnnTensor4dDescriptor_t top_desc_;
    + cudnnTensorDescriptor_t bottom_desc_;
    + cudnnTensorDescriptor_t top_desc_;
    };
    #endif
   
@@ -550,8 +550,8 @@ class CuDNNTanHLayer : public TanHLayer<Dtype> {
    const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
   
    cudnnHandle_t handle_;
   - cudnnTensor4dDescriptor_t bottom_desc_;
   - cudnnTensor4dDescriptor_t top_desc_;
    + cudnnTensorDescriptor_t bottom_desc_;
    + cudnnTensorDescriptor_t top_desc_;
    };
    #endif
   
 
View 
29  include/caffe/util/cudnn.hpp
@@ -56,34 +56,34 @@ template<> class dataType<double> {
    };
   
    template <typename Dtype>
   -inline void createTensor4dDesc(cudnnTensor4dDescriptor_t* desc) {
   - CUDNN_CHECK(cudnnCreateTensor4dDescriptor(desc));
    +inline void createTensor4dDesc(cudnnTensorDescriptor_t* desc) {
    + CUDNN_CHECK(cudnnCreateTensorDescriptor(desc));
    }
   
    template <typename Dtype>
   -inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc,
   - int n, int c, int h, int w,
   - int stride_n, int stride_c, int stride_h, int stride_w) {
    +inline void setTensor4dDesc(cudnnTensorDescriptor_t* desc,
    + int n, int c, int h, int w,
    + int stride_n, int stride_c, int stride_h, int stride_w) {
    CUDNN_CHECK(cudnnSetTensor4dDescriptorEx(*desc, dataType<Dtype>::type,
   - n, c, h, w, stride_n, stride_c, stride_h, stride_w));
    + n, c, h, w, stride_n, stride_c, stride_h, stride_w));
    }
   
    template <typename Dtype>
   -inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc,
   - int n, int c, int h, int w) {
    +inline void setTensor4dDesc(cudnnTensorDescriptor_t* desc,
    + int n, int c, int h, int w) {
    const int stride_w = 1;
    const int stride_h = w * stride_w;
    const int stride_c = h * stride_h;
    const int stride_n = c * stride_c;
    setTensor4dDesc<Dtype>(desc, n, c, h, w,
   - stride_n, stride_c, stride_h, stride_w);
    + stride_n, stride_c, stride_h, stride_w);
    }
   
    template <typename Dtype>
    inline void createFilterDesc(cudnnFilterDescriptor_t* desc,
    int n, int c, int h, int w) {
    CUDNN_CHECK(cudnnCreateFilterDescriptor(desc));
   - CUDNN_CHECK(cudnnSetFilterDescriptor(*desc, dataType<Dtype>::type,
    + CUDNN_CHECK(cudnnSetFilter4dDescriptor(*desc, dataType<Dtype>::type,
    n, c, h, w));
    }
   
@@ -94,9 +94,9 @@ inline void createConvolutionDesc(cudnnConvolutionDescriptor_t* conv) {
   
    template <typename Dtype>
    inline void setConvolutionDesc(cudnnConvolutionDescriptor_t* conv,
   - cudnnTensor4dDescriptor_t bottom, cudnnFilterDescriptor_t filter,
    + cudnnTensorDescriptor_t bottom, cudnnFilterDescriptor_t filter,
    int pad_h, int pad_w, int stride_h, int stride_w) {
   - CUDNN_CHECK(cudnnSetConvolutionDescriptor(*conv, bottom, filter,
    + CUDNN_CHECK(cudnnSetConvolution2dDescriptor(*conv,
    pad_h, pad_w, stride_h, stride_w, 1, 1, CUDNN_CROSS_CORRELATION));
    }
   
@@ -109,14 +109,15 @@ inline void createPoolingDesc(cudnnPoolingDescriptor_t* conv,
    *mode = CUDNN_POOLING_MAX;
    break;
    case PoolingParameter_PoolMethod_AVE:
    + // *mode = CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING;
    *mode = CUDNN_POOLING_AVERAGE;
    break;
    default:
    LOG(FATAL) << "Unknown pooling method.";
    }
    CUDNN_CHECK(cudnnCreatePoolingDescriptor(conv));
   - CUDNN_CHECK(cudnnSetPoolingDescriptor(*conv, *mode, h, w,
   - stride_h, stride_w));
    + CUDNN_CHECK(cudnnSetPooling2dDescriptor(*conv, *mode, h, w,
    + 0, 0, stride_h, stride_w));
    }
   
    } // namespace cudnn
 
View 
 include/caffe/vision_layers.hpp
@@ -145,8 +145,8 @@ class CuDNNConvolutionLayer : public ConvolutionLayer<Dtype> {
   
    cudnnHandle_t* handle_;
    cudaStream_t* stream_;
   - vector<cudnnTensor4dDescriptor_t> bottom_descs_, top_descs_;
   - cudnnTensor4dDescriptor_t bias_desc_;
    + vector<cudnnTensorDescriptor_t> bottom_descs_, top_descs_;
    + cudnnTensorDescriptor_t bias_desc_;
    cudnnFilterDescriptor_t filter_desc_;
    vector<cudnnConvolutionDescriptor_t> conv_descs_;
    int bottom_offset_, top_offset_, weight_offset_, bias_offset_;
@@ -344,7 +344,7 @@ class CuDNNPoolingLayer : public PoolingLayer<Dtype> {
    const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
   
    cudnnHandle_t handle_;
   - cudnnTensor4dDescriptor_t bottom_desc_, top_desc_;
    + cudnnTensorDescriptor_t bottom_desc_, top_desc_;
    cudnnPoolingDescriptor_t pooling_desc_;
    cudnnPoolingMode_t mode_;
    };
 
View 
10  src/caffe/layers/cudnn_conv_layer.cpp
@@ -43,10 +43,10 @@ void CuDNNConvolutionLayer<Dtype>::LayerSetUp(
   
    // Create tensor descriptor(s) for data and corresponding convolution(s).
    for (int i = 0; i < bottom.size(); i++) {
   - cudnnTensor4dDescriptor_t bottom_desc;
    + cudnnTensorDescriptor_t bottom_desc;
    cudnn::createTensor4dDesc<Dtype>(&bottom_desc);
    bottom_descs_.push_back(bottom_desc);
   - cudnnTensor4dDescriptor_t top_desc;
    + cudnnTensorDescriptor_t top_desc;
    cudnn::createTensor4dDesc<Dtype>(&top_desc);
    top_descs_.push_back(top_desc);
    cudnnConvolutionDescriptor_t conv_desc;
@@ -99,12 +99,12 @@ void CuDNNConvolutionLayer<Dtype>::Reshape(
    template <typename Dtype>
    CuDNNConvolutionLayer<Dtype>::~CuDNNConvolutionLayer() {
    for (int i = 0; i < bottom_descs_.size(); i++) {
   - cudnnDestroyTensor4dDescriptor(bottom_descs_[i]);
   - cudnnDestroyTensor4dDescriptor(top_descs_[i]);
    + cudnnDestroyTensorDescriptor(bottom_descs_[i]);
    + cudnnDestroyTensorDescriptor(top_descs_[i]);
    cudnnDestroyConvolutionDescriptor(conv_descs_[i]);
    }
    if (this->bias_term_) {
   - cudnnDestroyTensor4dDescriptor(bias_desc_);
    + cudnnDestroyTensorDescriptor(bias_desc_);
    }
    cudnnDestroyFilterDescriptor(filter_desc_);
   
 
View 
87  src/caffe/layers/cudnn_conv_layer.cu
@@ -21,21 +21,51 @@ void CuDNNConvolutionLayer<Dtype>::Forward_gpu(
   
    // Forward through cuDNN in parallel over groups.
    for (int g = 0; g < this->group_; g++) {
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    + cudnnConvolutionFwdAlgo_t algo;
    +
    + // get the desired convolution algorithm
    + CUDNN_CHECK(cudnnGetConvolutionForwardAlgorithm(handle_[g],
    + bottom_descs_[i],
    + filter_desc_,
    + conv_descs_[i],
    + top_descs_[i],
    + CUDNN_CONVOLUTION_FWD_NO_WORKSPACE,
    + 0, // memoryLimitInBytes,
    + &algo));
    +
    + // get minimum size of the workspace needed for the desired algorithm
    + size_t workspaceSizeInBytes;
    +
    + CUDNN_CHECK(cudnnGetConvolutionForwardWorkspaceSize(handle_[g],
    + bottom_descs_[i],
    + filter_desc_,
    + conv_descs_[i],
    + top_descs_[i],
    + algo,
    + &workspaceSizeInBytes));
    +
    + void *workspace = NULL;
    +
    // Filters.
   - CUDNN_CHECK(cudnnConvolutionForward(handle_[g],
   - bottom_descs_[i], bottom_data + bottom_offset_ * g,
   - filter_desc_, weight + weight_offset_ * g,
   - conv_descs_[i],
   - top_descs_[i], top_data + top_offset_ * g,
   - CUDNN_RESULT_NO_ACCUMULATE));
    + CUDNN_CHECK(cudnnConvolutionForward(handle_[g], (void *)(&alpha),
    + bottom_descs_[i], bottom_data + bottom_offset_ * g,
    + filter_desc_, weight + weight_offset_ * g,
    + conv_descs_[i],
    + algo, workspace, workspaceSizeInBytes, // algo, workspace, workspacebytes,
    + (void *)(&beta),
    + top_descs_[i], top_data + top_offset_ * g));
   
    // Bias.
    if (this->bias_term_) {
    const Dtype* bias_data = this->blobs_[1]->gpu_data();
   - Dtype alpha = 1.;
   - CUDNN_CHECK(cudnnAddTensor4d(handle_[g], CUDNN_ADD_SAME_C, &alpha,
   - bias_desc_, bias_data + bias_offset_ * g,
   - top_descs_[i], top_data + top_offset_ * g));
    + Dtype alpha = 1.0;
    + Dtype beta = 1.0;
    + CUDNN_CHECK(cudnnAddTensor(handle_[g], CUDNN_ADD_SAME_C, (void *)(&alpha),
    + bias_desc_, bias_data + bias_offset_ * g, (void *)(&beta),
    + top_descs_[i], top_data + top_offset_ * g));
    }
    }
   
@@ -65,34 +95,39 @@ void CuDNNConvolutionLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_diff = top[i]->gpu_diff();
    // Backward through cuDNN in parallel over groups and gradients.
    for (int g = 0; g < this->group_; g++) {
    +
    // Gradient w.r.t. bias.
    if (this->bias_term_ && this->param_propagate_down_[1]) {
   - CUDNN_CHECK(cudnnConvolutionBackwardBias(handle_[0*this->group_ + g],
   - top_descs_[i], top_diff + top_offset_ * g,
   - bias_desc_, bias_diff + bias_offset_ * g,
   - CUDNN_RESULT_ACCUMULATE));
    + const Dtype alpha = 1.0;
    + const Dtype beta = 1.0;
    + CUDNN_CHECK(cudnnConvolutionBackwardBias(handle_[0*this->group_ + g], (void *)(&alpha),
    + top_descs_[i], top_diff + top_offset_ * g,
    + (void *)(&beta),
    + bias_desc_, bias_diff + bias_offset_ * g));
    }
   
    // Gradient w.r.t. weights.
    if (this->param_propagate_down_[0]) {
    + const Dtype alpha = 1.0;
    + const Dtype beta = 1.0;
    const Dtype* bottom_data = (*bottom)[i]->gpu_data();
   - CUDNN_CHECK(cudnnConvolutionBackwardFilter(handle_[1*this->group_ + g],
   - bottom_descs_[i], bottom_data + bottom_offset_ * g,
   - top_descs_[i], top_diff + top_offset_ * g,
   - conv_descs_[i],
   - filter_desc_, weight_diff + weight_offset_ * g,
   - CUDNN_RESULT_ACCUMULATE));
    + CUDNN_CHECK(cudnnConvolutionBackwardFilter(handle_[1*this->group_ + g], (void *)(&alpha),
    + bottom_descs_[i], bottom_data + bottom_offset_ * g,
    + top_descs_[i], top_diff + top_offset_ * g,
    + conv_descs_[i], (void *)(&beta),
    + filter_desc_, weight_diff + weight_offset_ * g));
    }
   
    // Gradient w.r.t. bottom data.
    if (propagate_down[i]) {
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    Dtype* bottom_diff = (*bottom)[i]->mutable_gpu_diff();
   - CUDNN_CHECK(cudnnConvolutionBackwardData(handle_[2*this->group_ + g],
   - filter_desc_, weight + weight_offset_ * g,
   - top_descs_[i], top_diff + top_offset_ * g,
   - conv_descs_[i],
   - bottom_descs_[i], bottom_diff + bottom_offset_ * g,
   - CUDNN_RESULT_NO_ACCUMULATE));
    + CUDNN_CHECK(cudnnConvolutionBackwardData(handle_[2*this->group_ + g], (void *)(&alpha),
    + filter_desc_, weight + weight_offset_ * g,
    + top_descs_[i], top_diff + top_offset_ * g,
    + conv_descs_[i], (void *)(&beta),
    + bottom_descs_[i], bottom_diff + bottom_offset_ * g));
    }
    }
   
 
View 
 src/caffe/layers/cudnn_pooling_layer.cpp
@@ -34,8 +34,8 @@ void CuDNNPoolingLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
   
    template <typename Dtype>
    CuDNNPoolingLayer<Dtype>::~CuDNNPoolingLayer() {
   - cudnnDestroyTensor4dDescriptor(bottom_desc_);
   - cudnnDestroyTensor4dDescriptor(top_desc_);
    + cudnnDestroyTensorDescriptor(bottom_desc_);
    + cudnnDestroyTensorDescriptor(top_desc_);
    cudnnDestroyPoolingDescriptor(pooling_desc_);
    cudnnDestroy(handle_);
    }
 
View 
18  src/caffe/layers/cudnn_pooling_layer.cu
@@ -21,8 +21,12 @@ void CuDNNPoolingLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
   
    const Dtype* bottom_data = bottom[0]->gpu_data();
    Dtype* top_data = (*top)[0]->mutable_gpu_data();
   - CUDNN_CHECK(cudnnPoolingForward(handle_, pooling_desc_,
   - bottom_desc_, bottom_data, top_desc_, top_data));
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    + CUDNN_CHECK(cudnnPoolingForward(handle_, pooling_desc_, (void *)(&alpha),
    + bottom_desc_, bottom_data, (void *)(&beta), top_desc_, top_data));
    }
   
    template <typename Dtype>
@@ -43,9 +47,13 @@ void CuDNNPoolingLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_data = top[0]->gpu_data();
    const Dtype* bottom_data = (*bottom)[0]->gpu_data();
    Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
   - CUDNN_CHECK(cudnnPoolingBackward(handle_, pooling_desc_,
   - top_desc_, top_data, top_desc_, top_diff,
   - bottom_desc_, bottom_data, bottom_desc_, bottom_diff));
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    + CUDNN_CHECK(cudnnPoolingBackward(handle_, pooling_desc_, (void *)(&alpha),
    + top_desc_, top_data, top_desc_, top_diff,
    + bottom_desc_, bottom_data, (void *)(&beta), bottom_desc_, bottom_diff));
    }
   
    INSTANTIATE_CLASS(CuDNNPoolingLayer);
 
View 
 src/caffe/layers/cudnn_relu_layer.cpp
@@ -31,8 +31,8 @@ void CuDNNReLULayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
   
    template <typename Dtype>
    CuDNNReLULayer<Dtype>::~CuDNNReLULayer() {
   - cudnnDestroyTensor4dDescriptor(this->bottom_desc_);
   - cudnnDestroyTensor4dDescriptor(this->top_desc_);
    + cudnnDestroyTensorDescriptor(this->bottom_desc_);
    + cudnnDestroyTensorDescriptor(this->top_desc_);
    cudnnDestroy(this->handle_);
    }
   
 
View 
20  src/caffe/layers/cudnn_relu_layer.cu
@@ -17,9 +17,14 @@ void CuDNNReLULayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
   
    const Dtype* bottom_data = bottom[0]->gpu_data();
    Dtype* top_data = (*top)[0]->mutable_gpu_data();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationForward(this->handle_,
   - CUDNN_ACTIVATION_RELU,
   - this->bottom_desc_, bottom_data, this->top_desc_, top_data));
    + CUDNN_ACTIVATION_RELU, (void *)(&alpha),
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->top_desc_, top_data));
    }
   
    template <typename Dtype>
@@ -39,10 +44,15 @@ void CuDNNReLULayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_diff = top[0]->gpu_diff();
    const Dtype* bottom_data = (*bottom)[0]->gpu_data();
    Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationBackward(this->handle_,
   - CUDNN_ACTIVATION_RELU,
   - this->top_desc_, top_data, this->top_desc_, top_diff,
   - this->bottom_desc_, bottom_data, this->bottom_desc_, bottom_diff));
    + CUDNN_ACTIVATION_RELU, (void *)(&alpha),
    + this->top_desc_, top_data, this->top_desc_, top_diff,
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->bottom_desc_, bottom_diff));
    }
   
    INSTANTIATE_CLASS(CuDNNReLULayer);
 
View 
 src/caffe/layers/cudnn_sigmoid_layer.cpp
@@ -31,8 +31,8 @@ void CuDNNSigmoidLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
   
    template <typename Dtype>
    CuDNNSigmoidLayer<Dtype>::~CuDNNSigmoidLayer() {
   - cudnnDestroyTensor4dDescriptor(this->bottom_desc_);
   - cudnnDestroyTensor4dDescriptor(this->top_desc_);
    + cudnnDestroyTensorDescriptor(this->bottom_desc_);
    + cudnnDestroyTensorDescriptor(this->top_desc_);
    cudnnDestroy(this->handle_);
    }
   
 
View 
20  src/caffe/layers/cudnn_sigmoid_layer.cu
@@ -12,9 +12,14 @@ void CuDNNSigmoidLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
    vector<Blob<Dtype>*>* top) {
    const Dtype* bottom_data = bottom[0]->gpu_data();
    Dtype* top_data = (*top)[0]->mutable_gpu_data();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationForward(this->handle_,
   - CUDNN_ACTIVATION_SIGMOID,
   - this->bottom_desc_, bottom_data, this->top_desc_, top_data));
    + CUDNN_ACTIVATION_SIGMOID, (void *)(&alpha),
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->top_desc_, top_data));
    }
   
    template <typename Dtype>
@@ -29,10 +34,15 @@ void CuDNNSigmoidLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_diff = top[0]->gpu_diff();
    const Dtype* bottom_data = (*bottom)[0]->gpu_data();
    Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationBackward(this->handle_,
   - CUDNN_ACTIVATION_SIGMOID,
   - this->top_desc_, top_data, this->top_desc_, top_diff,
   - this->bottom_desc_, bottom_data, this->bottom_desc_, bottom_diff));
    + CUDNN_ACTIVATION_SIGMOID, (void *)(&alpha),
    + this->top_desc_, top_data, this->top_desc_, top_diff,
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->bottom_desc_, bottom_diff));
    }
   
    INSTANTIATE_CLASS(CuDNNSigmoidLayer);
 
View 
 src/caffe/layers/cudnn_softmax_layer.cpp
@@ -35,8 +35,8 @@ void CuDNNSoftmaxLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
   
    template <typename Dtype>
    CuDNNSoftmaxLayer<Dtype>::~CuDNNSoftmaxLayer() {
   - cudnnDestroyTensor4dDescriptor(bottom_desc_);
   - cudnnDestroyTensor4dDescriptor(top_desc_);
    + cudnnDestroyTensorDescriptor(bottom_desc_);
    + cudnnDestroyTensorDescriptor(top_desc_);
    cudnnDestroy(handle_);
    }
   
 
View 
18  src/caffe/layers/cudnn_softmax_layer.cu
@@ -16,9 +16,14 @@ void CuDNNSoftmaxLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
    vector<Blob<Dtype>*>* top) {
    const Dtype* bottom_data = bottom[0]->gpu_data();
    Dtype* top_data = (*top)[0]->mutable_gpu_data();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnSoftmaxForward(handle_, CUDNN_SOFTMAX_ACCURATE,
   - CUDNN_SOFTMAX_MODE_CHANNEL,
   - bottom_desc_, bottom_data, top_desc_, top_data));
    + CUDNN_SOFTMAX_MODE_CHANNEL, (void *)(&alpha),
    + bottom_desc_, bottom_data, (void *)(&beta),
    + top_desc_, top_data));
    }
   
    template <typename Dtype>
@@ -29,9 +34,14 @@ void CuDNNSoftmaxLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_diff = top[0]->gpu_diff();
    const Dtype* bottom_data = (*bottom)[0]->gpu_data();
    Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnSoftmaxBackward(handle_, CUDNN_SOFTMAX_ACCURATE,
   - CUDNN_SOFTMAX_MODE_CHANNEL,
   - top_desc_, top_data, top_desc_, top_diff, bottom_desc_, bottom_diff));
    + CUDNN_SOFTMAX_MODE_CHANNEL, (void *)(&alpha),
    + top_desc_, top_data, top_desc_, top_diff, (void *)(&beta),
    + bottom_desc_, bottom_diff));
    }
    }
   
 
View 
 src/caffe/layers/cudnn_tanh_layer.cpp
@@ -31,8 +31,8 @@ void CuDNNTanHLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
   
    template <typename Dtype>
    CuDNNTanHLayer<Dtype>::~CuDNNTanHLayer() {
   - cudnnDestroyTensor4dDescriptor(this->bottom_desc_);
   - cudnnDestroyTensor4dDescriptor(this->top_desc_);
    + cudnnDestroyTensorDescriptor(this->bottom_desc_);
    + cudnnDestroyTensorDescriptor(this->top_desc_);
    cudnnDestroy(this->handle_);
    }
   
 
View 
20  src/caffe/layers/cudnn_tanh_layer.cu

@@ -12,9 +12,14 @@ void CuDNNTanHLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
    vector<Blob<Dtype>*>* top) {
    const Dtype* bottom_data = bottom[0]->gpu_data();
    Dtype* top_data = (*top)[0]->mutable_gpu_data();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationForward(this->handle_,
   - CUDNN_ACTIVATION_TANH,
   - this->bottom_desc_, bottom_data, this->top_desc_, top_data));
    + CUDNN_ACTIVATION_TANH, (void *)(&alpha),
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->top_desc_, top_data));
    }
   
    template <typename Dtype>
@@ -29,10 +34,15 @@ void CuDNNTanHLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
    const Dtype* top_diff = top[0]->gpu_diff();
    const Dtype* bottom_data = (*bottom)[0]->gpu_data();
    Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
    +
    + const Dtype alpha = 1.0;
    + const Dtype beta = 0.0;
    +
    CUDNN_CHECK(cudnnActivationBackward(this->handle_,
   - CUDNN_ACTIVATION_TANH,
   - this->top_desc_, top_data, this->top_desc_, top_diff,
   - this->bottom_desc_, bottom_data, this->bottom_desc_, bottom_diff));
    + CUDNN_ACTIVATION_TANH, (void *)(&alpha),
    + this->top_desc_, top_data, this->top_desc_, top_diff,
    + this->bottom_desc_, bottom_data, (void *)(&beta),
    + this->bottom_desc_, bottom_diff));
    }
   
    INSTANTIATE_CLASS(CuDNNTanHLayer);
2. 

http://stackoverflow.com/questions/36637923/caffe-error-make-test

https://github.com/BVLC/caffe/pull/3919/files

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/313303.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

友浩达优选上新,原生态农产品,买得安心,吃得放心

大闸蟹还在热卖&#xff0c;需要的同学可以访问 各位一直支持队长的朋友们友浩达优选上新了本着为大家推荐好东西的想法商城里上架的商品都是队长亲自挑选有质量保证的口碑好商品这次&#xff0c;来看看队长又给大家带了哪些好东西本次上新全是各地优选原生态农产品食品优质、安…

判别学习与生成学习的区别

参照http://blog.csdn.net/daijiguo/article/details/52218207 比如二类分类问题&#xff0c;不管是感知器算法还是逻辑斯蒂回归算法&#xff0c;都是在解空间中寻找一条直线从而把两种类别的样例分开&#xff0c;对于新的样例只要判断在直线的哪一侧即可&#xff1b;这种直接对…

树莓派4上跑 .NET Core 3.0,这次,真·64位!

导语前不久我写了一篇《Gentoo由于 Windows 10 IoT Core &#xff08;以及上面的UWP们&#xff09;暴尸荒野而苟且偷生使用 Linux 的我&#xff0c;已经彻底开荤了。最近我发现有个叫 Gentoo 的 Linux 系统&#xff0c;支持树莓派4的64位CPU。项目地址&#xff1a;https://gith…

微软100题第20题

http://blog.csdn.net/zwb8848happy/article/details/7340634 输入一个表示整数的字符串&#xff0c;把该字符串转换成整数并输出 //Analysis: //1. Whether it is a negative number //2. Whether there exist other characters that do not represent numbers //#includ…

asp.net core 使用 AccessControlHelper 控制访问权限

asp.net core 使用 AccessControlHelper 控制访问权限Intro由于项目需要&#xff0c;需要在基于 asp.net mvc 的 Web 项目框架中做权限的控制&#xff0c;于是才有了这个权限控制组件&#xff0c;最初只是支持 netframework&#xff0c;后来 dotnetcore 2.0 发布了之后添加了对…

Caffe 增加自定义 Layer 及其 ProtoBuffer 参数

转载自&#xff1a;http://blog.csdn.net/kkk584520/article/details/52721838 http://blog.csdn.net/kkk584520 博客内容基于新书《深度学习&#xff1a;21 天实战 Caffe》&#xff0c;书中课后习题答案欢迎读者留言讨论。以下进入正文。 在使用 Caffe 过程中经常会有这样的…

.NET Core 3.0愈加成熟,微软将不再把.NET Framework API移植给它

目前 .NET Core 3.0 拥有的 API 总数约为 .NET Framework API 的 80%&#xff0c;剩下尚未从 .NET Framework 移植到 .NET Core 的 API&#xff0c;微软考虑以开源的形式发布。微软方面表示&#xff0c;通过 .NET Core 3.0&#xff0c;他们现在已具备轻松移植现代 workload 所需…

开发问题记录

1、MySQL死锁问题解决 Waiting for table metadata lock &#xff1a; Alter table qimao.qimao_content_distribute drop index idx_content_id,add UNIQUE ind直接执行 kill id&#xff0c;杀掉死锁进程即可 2、Mybatis 自动生成 使用MyBatis Generator自动生成实体、…

参加 JSConf China 2019 是怎样的体验?VS Code 和 TypeScript 都很火

JSConf China 2019 于 10 月 19-20 日于上海尚浦中心举行。很高兴作为讲师参加这次的 JSConf。Day 1在 Day 1 给大家聊了聊 The Beauty of TypeScript。简单总结下我讲的 TypeScript 的 session。千言万语&#xff0c;汇聚成下面两页的 PPT。TypeScript 的使用场景&#xff08;…

记一次应用配置的数据库连接被打满问题

线上应用&#xff0c;配置的数据库连接数为50&#xff0c;正常情况是已经够用了&#xff0c;但是有天发现50个连接全部被占满&#xff0c;并且长时间无法恢复&#xff0c;重启服务后会好一段时间。 1、问题现象 Druid获取MySQL数据库连接超时&#xff0c;超时时间设置的为60s…

Caffe阅读代码并修改

这个教程是最好理解的了 http://city.shaform.com/blog/2016/02/26/caffe.html 主要分成四個部份來講。首先是整個 Caffe 的大架構&#xff0c;以及一些重要的元件。 其次&#xff0c;我也研究了如何自己新增一個 layer。 接下來&#xff0c;再重新回到 Caffe 做更深入的解析…

ABP v1.0正式发布

经过长时间的开发终于发布了ABP v1.0&#xff01;感谢为该项目做出了贡献的你~https://github.com/abpframework/abp/releases

JVM解惑:消失的异常堆栈,log中打印异常堆栈为空

最近线上发现很多异常没有堆栈信息&#xff0c;只有一句描述&#xff0c;如下&#xff1a; java.lang.NullPointerException: null排查问题时受到了一些阻碍。然后发现无论是在本地环境还是测试环境&#xff0c;堆栈信息都可以正常打印&#xff0c;使用的是同一份日志配置文件…

Caffe自己修改训练方法

作者&#xff1a;Gein Chen链接&#xff1a;https://www.zhihu.com/question/27982282/answer/80242005&#xff11;&#xff0e;学习程序的第一步&#xff0c;先让程序跑起来&#xff0c;看看结果&#xff0c;这样就会有直观的感受。Caffe的官网上Caffe | Deep Learning Frame…

Ubuntu下用eclipse调试caffe code

本文地址&#xff1a;http://blog.csdn.net/mounty_fsc/article/details/51089864 1 运行范例脚本train_lenet.sh Ubuntu下终端行执行train_lenet.sh可训练lenet-5&#xff08;详细情况参考其他教程&#xff09;&#xff0c;能直观地看到lenet训练起来带情况。 train_lenet.sh…

idea使用jar包依赖,替换掉项目依赖

idea使用jar包依赖&#xff0c;替换掉项目依赖最近遇到了个问题&#xff0c;父子项目中&#xff0c;原本一个项目在idea下默认是项目依赖于另一个子项目&#xff0c;但是由于当前开发分支里不包含相应的代码&#xff0c;最新代码在别的分支&#xff0c;导致项目依赖时&#xff…

C#中Array.Sort()方法分析

Array.Sort()是在我们日常工作中非常常用的函数&#xff0c;不需要自己编写排序算法就可以方便的对数组进行排序。利用Array.Sort()排序具有以下特点&#xff1a;排序是不稳定的采用内省排序&#xff08;introspective sort&#xff09;这里简单解释一下内省排序。内省排序会先…

输入两个整数 n 和 m ,从数列 1 , 2 , 3.......n 中随意取几个数 ,使其和等于 m

转载自&#xff1a;http://blog.sina.com.cn/s/blog_7571423b01016707.html 编程求解&#xff1a;输入两个整数 n 和 m &#xff0c;从数列 1 &#xff0c; 2 &#xff0c; 3.......n 中随意取几个数 ,使其和等于 m , 要求将其中所有的可能组合列出来. 分析&#xff1a; 主要思…

张高兴的 .NET Core IoT 入门指南:(五)串口通信入门

在开始之前&#xff0c;首先要说明的是串口通信所用到的 SerialPort 类并不包含在 System.Device.Gpio NuGet 包中&#xff0c;而是在 System.IO.Ports NuGet 包中。之所以在这里介绍串口通信&#xff0c;是因为在嵌入式中串口通信是与其他设备进行交互的一种重要方式&#xff…