我使用Caffe-windows将jpg图像转成lmdb,发现MDB_MAP_FULL: Environment mapsize limit reached错误,上网查了一圈只找到ubuntu下解决方法,没有windows下解决方案,其实就是更改默认的MAP SIZE即可,方法:
进入caffe-windows文件夹,在我的电脑搜索db_lmdb,找到db_lmdb.cpp文件然后打开它看到如下代码
#ifdef _MSC_VER // On Windows lmdb creates file with the full size causing test failures due // to insufficient disk space. We will reduce lmdb size to make tests pass. const size_t LMDB_MAP_SIZE = 104857600; // 100 MB // Constant will overflow on 32-bit build, assert that we are using correct // build. static_assert(sizeof(size_t) >= 8, "LMDB size overflow."); #else const size_t LMDB_MAP_SIZE = 1099511627776; // 1 TB #endif
我们把默认100M改成500M
#ifdef _MSC_VER // On Windows lmdb creates file with the full size causing test failures due // to insufficient disk space. We will reduce lmdb size to make tests pass. //const size_t LMDB_MAP_SIZE = 104857600; // 100 MB const size_t LMDB_MAP_SIZE = 524288000; // 500 MB也可以改成自己想要的大小 // Constant will overflow on 32-bit build, assert that we are using correct // build. static_assert(sizeof(size_t) >= 8, "LMDB size overflow."); #else const size_t LMDB_MAP_SIZE = 1099511627776; // 1 TB #endif
然后,我运行自己的bat结果发现还是一样的错误,于是我又重新编译caffe-window源码,再次运行就好了。我用图片转成leveldb格式不存在此问题,有兴趣的话大家可以试一试。
最后注意一下,如果大家运行的mnist数据集转换lmdb出现类似错误是改caffe-windows\examples\mnist\convert_mnist_data.cpp这个cpp默认MAP SIZE。
CHECK_EQ(mdb_env_create(&mdb_env), MDB_SUCCESS) << "mdb_env_create failed"; //CHECK_EQ(mdb_env_set_mapsize(mdb_env, 1099511627776), MDB_SUCCESS) // 1TB CHECK_EQ(mdb_env_set_mapsize(mdb_env, 102400), MDB_SUCCESS) // 这是我改的地方 << "mdb_env_set_mapsize failed";