How to prevent tensorflow from allocating the totality of a GPU memory?

前端 未结 16 2201
南旧
南旧 2020-11-22 04:26

I work in an environment in which computational resources are shared, i.e., we have a few server machines equipped with a few Nvidia Titan X GPUs each.

For small to m

16条回答
  •  北海茫月
    2020-11-22 04:51

    You can use

    TF_FORCE_GPU_ALLOW_GROWTH=true
    

    in your environment variables.

    In tensorflow code:

    bool GPUBFCAllocator::GetAllowGrowthValue(const GPUOptions& gpu_options) {
      const char* force_allow_growth_string =
          std::getenv("TF_FORCE_GPU_ALLOW_GROWTH");
      if (force_allow_growth_string == nullptr) {
        return gpu_options.allow_growth();
    }
    

提交回复
热议问题