最近、私はcaffeのsoftmax_loss_layerのコードを変更する必要があります。 カフェのバージョンは次のとおりです。私のコードで、残りはsame.Hereです...間https://github.com/BVLC/caffecaffeエラー== cudaSuccess(77対0)不正なメモリアクセスが発生しました
コード私はコード ファーストを変更する方法ですが、私はloss_layers.hppに
class SoftmaxWithLossLayer : public LossLayer<Dtype> {
...
Blob<Dtype> rs_;
...
}
をRS_を追加しました
そして、I [2] dense_image_data_layer.cppから
あるsoftmax_loss_layer.cppvoid SoftmaxWithLossLayer<Dtype>::LayerSetUp(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
...
rs_.Reshape(bottom[2]->num(),bottom[2]->channels(),bottom[2]->height(),
bottom[2]->width());
}
底にRS_を再形成します
F0108 10:45:48.291290 2859 math_functions.cu:81] Check failed: error == cudaSuccess (77 vs. 0) an illegal memory access was encountered
*** Check failure stack trace: ***
@ 0x7f0b3bcfbdaa (unknown)
@ 0x7f0b3bcfbce4 (unknown)
@ 0x7f0b3bcfb6e6 (unknown)
@ 0x7f0b3bcfe687 (unknown)
@ 0x7f0b3c16dd48 caffe::caffe_gpu_memcpy()
@ 0x7f0b3c09b67e caffe::SyncedMemory::gpu_data()
@ 0x7f0b3c054472 caffe::Blob<>::gpu_data()
@ 0x7f0b3c0b0568 caffe::Net<>::ForwardFromTo()
@ 0x7f0b3c0b0947 caffe::Net<>::ForwardPrefilled()
@ 0x7f0b3c08e555 caffe::Solver<>::Step()
@ 0x7f0b3c08ee8f caffe::Solver<>::Solve()
@ 0x407806 train()
@ 0x405d41 main
@ 0x7f0b3b20dec5 (unknown)
@ 0x4062ed (unknown)
@ (nil) (unknown)
は私が正しくまたは[下RS_使用していなかったので、この誤差はあると思います。最後に10
は、私が
template <typename Dtype>
void SoftmaxWithLossLayer<Dtype>::Forward_gpu(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
...
Dtype loss;
Dtype em;
bool add_weight=this->layer_param_.loss_param().add_weight();
Dtype* weight=bottom[2]->mutable_gpu_data();
Dtype z=0;
Dtype* rs=rs_.mutable_gpu_data();
if(add_weight)
{
SoftmaxLossWeightForwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads, prob_data, label,
weight_by_label_freqs_, label_count_data , loss_data,
outer_num_, dim, inner_num_,
has_ignore_label_, ignore_label_, counts,weight,rs);
const Dtype*rs1=rs_.gpu_data();
caffe_gpu_asum(nthreads, loss_data, &loss);
em=loss/nthreads;
count=nthreads;
Dtype am=1/2*log((1-em)/em);
CalculateZ<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads,weight,rs1,am,z,inner_num_);
WeightUpdate<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads,weight,rs1,am,z,inner_num_);
...
}
template <typename Dtype>
void SoftmaxWithLossLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
...
const Dtype* weight=bottom[2]->gpu_data();
bool add_weight=this->layer_param_.loss_param().add_weight();
if(add_weight)
SoftmaxLossWeightBackwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads, top_data, label,
weight_by_label_freqs_, label_count_data, bottom_diff,
outer_num_, dim, inner_num_, has_ignore_label_,
ignore_label_, counts,weight);
...
}
誤りがあるsoftmax_loss_layer.cuにこのコードを追加しました2]は正しくありません。 私が変更したコードはすべて上に掲載されていますので、だれかに何をすべきか教えていただけますか? 追加情報が必要な場合は教えてください。
@shai:結果のCUDAランタイムエラーを脇に残し、この質問は、実際にCUDAをどのように処理するかがありますか? – talonmies
@talonmies私はコードを掘り起こさなかったので、そこにCUDA関連の問題があるかもしれません...しかし、あなたが同意しない場合は、このタグを削除してください。 – Shai
@Shai:私はすでにそれを一度削除し、それを再追加しました。私には、「私はカフェの内部を乱して何かを壊しました、どうすれば修正できますか?」 – talonmies