0

Using MSVC 2015

Everything has been going great until I introduced a few new lines of code:

Before:

static tensorflow::SessionOptions MakeSessionOptions() {
    tensorflow::SessionOptions options;
    tensorflow::ConfigProto* config = &options.config;
    auto* device_count = options.config.mutable_device_count();

    device_count->insert({ "CPU", 1 });
    device_count->insert({ "GPU", 1 });
    return options;
}

After

static tensorflow::SessionOptions MakeSessionOptions() {
    tensorflow::SessionOptions options;
    tensorflow::ConfigProto* config = &options.config;
    auto* device_count = options.config.mutable_device_count();

    auto* gpu_options = options.config.mutable_gpu_options();
    gpu_options->set_allow_growth(true);
    gpu_options->set_per_process_gpu_memory_fraction(0.8);

    device_count->insert({ "CPU", 1 });
    device_count->insert({ "GPU", 1 });
    return options;
}

Once the new code is inserted I get the following linking error

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol "public: static class tensorflow::GPUOptions * __cdecl google::protobuf::Arena::CreateMessage<class tensorflow::GPUOptions>(class google::protobuf::Arena *)" (??$CreateMessage@VGPUOptions@tensorflow@@@Arena@protobuf@google@@SAPEAVGPUOptions@tensorflow@@PEAV012@@Z) referenced in function "struct tensorflow::SessionOptions __cdecl MakeSessionOptions(void)" (?MakeSessionOptions@@YA?AUSessionOptions@tensorflow@@XZ)   rotobotmaskrcnn C:\msys64\home\hodgefamily\dev\openfx_gpu\Support\Plugins\RotobotMaskRCNN\rotobotmaskrcnn.obj   1   

So does anybody know what .lib file contains the symbols for google::protobuf::Arena.

I basically followed the contrib cmake instructions for Tensorflow r1.5

here:

https://github.com/tensorflow/tensorflow/blob/r1.5/tensorflow/contrib/cmake/README.md

Where are those symbols hiding?

Sam Hodge
  • 15
  • 6
  • Just in case, try `auto *` instead of `auto` for `gpu_options`. – Arash Dec 23 '18 at 23:45
  • public: static class tensorflow::GPUOptions * __ptr64 __cdecl google::protobuf::Arena::CreateMessage(class google::protobuf::Arena * __ptr64) – Sam Hodge Dec 23 '18 at 23:56
  • https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.arena#Arena.CreateMessage.details – Sam Hodge Dec 23 '18 at 23:58
  • It might look ridiculous but could you please avoid defining a variable and use them this way `options.config.mutable_gpu_options()->set_allow_growth(true);` , `options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(0.8);` and also check if both are causing linker error? – Arash Dec 24 '18 at 00:01
  • `static tensorflow::SessionOptions MakeSessionOptions() { tensorflow::SessionOptions options; tensorflow::ConfigProto* config = &options.config; auto* device_count = options.config.mutable_device_count(); tensorflow::GPUOptions gpu_options = options.config.gpu_options(); gpu_options.set_allow_growth(true); gpu_options.set_per_process_gpu_memory_fraction(0.8); //options.config.gpu_options.set_allocated_gpu_options(gpu_options); device_count->insert({ "CPU", 1 }); device_count->insert({ "GPU", 1 }); return options; }` – Sam Hodge Dec 24 '18 at 00:22
  • @Arash that seems to cause the same linker error – Sam Hodge Dec 24 '18 at 03:20

1 Answers1

1

the following seems to work

static tensorflow::SessionOptions MakeSessionOptions() {
    tensorflow::SessionOptions options; 
    tensorflow::ConfigProto* config = &options.config; 
    auto* device_count = options.config.mutable_device_count(); 
    tensorflow::GPUOptions gpu_options = options.config.gpu_options();
    gpu_options.set_allow_growth(true);
    gpu_options.set_per_process_gpu_memory_fraction(0.2); 
    device_count->insert({ "CPU", 1 });
    device_count->insert({ "GPU", 1 });
    return options; 
}

But I am not sure if it is having the desired effect as I can still OOM kill my program is that normal?

Also I am certainly using more than 20% of the allocatable memory when it doesnt OOM

Sam Hodge
  • 15
  • 6