编译Caffe-Win错误集锦(持续更新)

来源:互联网 发布:淘宝怎么发微淘 编辑:程序博客网 时间:2024/06/05 08:37

原文地址:http://blog.sina.com.cn/s/blog_141f234870102w8is.html


1.visual studio 2013 error C2371: 'int8_t' : redefinition;

      引入的unistd.h文件里面重定义了int8_t  ,用记事本 打开文件注销之。


2. error C3861: 'getpid': identifier not found    C:\Tools\caffe-master\src\caffe\common.cpp    26
     解决:在common.cpp 里面添加 #include

     修改:

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. pid getpid(); ——>pid _getpid();  

3.  error C3861: 'usleep': identifier not found    C:\Tools\caffe-master\src\caffe\test\test_benchmark.cpp    65

参考:ffmpeg编译总结

      7.出现 'usleep': identifier not found

     这里因为VC中没有usleepusleep是微妙级别的,所以需要把代码改为

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. usleep(is->audio_st && is->show_audio rdftspeed*1000 5000);  
  2. —>    Sleep (is->audio_st && is->show_audio rdftspeed*1 5);  
  3. usleep(300 1000); —> Sleep(300);  
      添加:#include


4. error C3861: 'snprintf': identifier not found    C:\Tools\caffe-master\src\caffe\solver.cpp    331

参考:http://blog.163.com/wanghuajie@126/blog/static/452312862009111114434838/

     在solver.cpp里面添加      #include

   snprintf  修改为 _snprintf


5. error C3861: '__builtin_popcount': identifier not found    C:\Tools\caffe-master\src\caffe\util\math_functions.cpp    346

参考:http://blog.csdn.net/rappy/article/details/1788969

      __builtin_popcount 这是一个GCC的函数:计算一个 32 位无符号整数有多少个位为1 

     解决:自己写一个函数__builtin_popcount

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. template <</span>typename Dtype>  
  2. unsigned int __builtin_popcount(Dtype u)  
  3.  
  4.     (u 0x55555555) ((u >> 1) 0x55555555);  
  5.     (u 0x33333333) ((u >> 2) 0x33333333);  
  6.     (u 0x0F0F0F0F) ((u >> 4) 0x0F0F0F0F);  
  7.     (u 0x00FF00FF) ((u >> 8) 0x00FF00FF);  
  8.     (u 0x0000FFFF) ((u >> 16) 0x0000FFFF);  
  9.     return u;  
  10. }//wishchin!!!  


6.error : identifier "::caffe::kBNLL_THRESHOLD" is undefined in device code    C:\Tools\caffe-master\src\caffe\layers\bnll_layer.cu    36
参考:

        解决:在bnll_layer.cu    里修改

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. Dtype expval exp(min(in_data[index], Dtype(kBNLL_THRESHOLD)));  
  2. ——>Dtype expval exp(min(in_data[index], Dtype(50)));  


7. error C2660: 'mkdir' : function does not take 2 arguments    C:\Tools\caffe-master\src\caffe\test\test_data_layer.cpp    71

参考:

     解决:

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. CHECK_EQ(mkdir(filename_->c_str(), 0744), 0) << "mkdir " << filename_<< "failed"  
     里面的第二个参数去掉。


8.error C2784: '_Ty std::max(std::initializer_list<_Elem>,_Pr)' : could not de

     解决:调用函数处 把std::max 用括号 括起来  (std::max)(std::initializer_list<<br>


9.error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS.

    参考:http://www.zhihu.com/question/26242158

   解决:应该这样添加 -D去掉 属性-> c\c++ -> 预处理器 -> 预处理器定义 里添加 _SCL_SECURE_NO_WARNINGS 编译成功 ,


XXX:不断出现的

        error C1075: end of file found before the left parenthesis '(' at '  test_infogain_loss_layer.cpp    71

       也没有找到哪里错了。应该是Define语句出现问题, 貌似可以不用管它.............


10. error C3861: 'close': identifier not found    \src\caffe\util\io.cpp

error C3861: 'open': identifier not found    \src\caffe\util\io.cpp

在io.hpp文件里加入#include


11. Check failed: error == cudaSuccess (2 vs. 0)  out of memory

train的batch_size设置过大,改小后可以. (个人经验不足所以一直在修改生成h5 file里的“chunksize”这个变量从64改到了1都还是会有 out of memory 的错误,而且也发现怎么改那个变量所消耗的内存数几乎不变。为此郁闷了一整天....后来才发现应该要改的是 train.prototxt里的 “batch_size", 一改以后马上内存就小了。在此记录一下。)


12.Check failed: error == cudaSuccess (38 vs. 0)  no CUDA-capable device is detected

可能原因:solver的参数没有设置或错误


13.check failed:error==cudasuccess(11  vs. 0) invalid argument

可能原因:test的batch_size 和solver的test_iter设置有问题


14.cudnn.h中

inline const char* cudnnGetErrorString(cudnnStatus_t status)  修改为

inline const char* CUDNNWINAPI  cudnnGetErrorString(cudnnStatus_t status)


15.error : identifier "cudnnTensor4dDescriptor_t" is undefined

cudnn版本不兼容问题,下载cudnn R1替换掉就可以。