【问题标题】:Setting batch_size in data_param for Caffe has no effect在 Caffe 的 data_param 中设置 batch_size 没有效果
【发布时间】:2023-03-23 04:52:02
【问题描述】:

当我在 Google deep dream bvlc_googlenet 中将 'batch_size' 中的 deploy.prototxt file 设置为降低 GPU 内存要求时,它对速度和内存要求都没有影响。就好像它被忽略了一样。我知道正在使用文件本身(deploy.prototxt),因为其他更改会反映在结果中,所以这不是问题。我还尝试在所有相关层上设置 batch_size(“inception_4c/1x1”等),同样没有区别。

我是这样设置的:

layer {
  name: "inception_4c/output"
  type: "Concat"
  bottom: "inception_4c/1x1"
  bottom: "inception_4c/3x3"
  bottom: "inception_4c/5x5"
  bottom: "inception_4c/pool_proj"
  top: "inception_4c/output"
  data_param {
    batch_size 1
  }
}

当我对脚本的运行时间计时,batch_size 1 和batch_size 512 是一样的,没有区别。

我做错了什么?

【问题讨论】:

    标签: python artificial-intelligence neural-network deep-learning caffe


    【解决方案1】:

    data_param是输入数据层的参数。您可以仅为输入设置batch_size,该值会通过网络传播。

    deploy.prototxt 中,批处理大小由第一个'input_dim' 参数(third line)设置,尝试更改此值,看看它是否对网络的内存消耗有任何影响。

    deploy.prototxt 文件的前几行应该被解释为

    input: "data"  # the "top" name of input layer
    input_dim: 10  # 4th dimension - batch size
    input_dim: 3   # 3rd dimension - number of channels
    input_dim: 224 # 2nd dimension - height of input
    input_dim: 224 # 1st dimension - width of input
    

    因此,您希望在您的第一个 conv 层 ("conv1/7x7_s2") 有一个名为“data”的“底部”,其形状为 10-by-3-by-224-by-224

    【讨论】:

    • 这改变了“数据所需的内存”输出,因此它会影响某些东西。但是该进程仍然内存不足。所需内存现在只有 50MB,显卡容量为 4GB,但内存不足“syncedmem.cpp:51] Check failed: error == cudaSuccess (2 vs. 0) out of memory”。有什么想法吗?
    • @Sergey 我不熟悉“深梦”系统的模型/设置。但听起来(a)您是否与其他进程共享 GPU? (b) GPU 中的内存分配是否可能不是“免费”的?
    • 根据“nvidia-smi”命令,有问题的python脚本消耗的内存从10MB(之前)到4GB(运行脚本时)。它在服务器环境中。
    • @Sergey hoe 服务器运行了多少进程?是单个进程使用的所有内存吗?
    • @Sergey 你能在调试中逐行运行脚本并同时监控 GPU 内存吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 2016-09-30
    • 2015-02-19
    • 1970-01-01
    • 2023-04-03
    • 2023-03-10
    相关资源
    最近更新 更多