tensorflex icon indicating copy to clipboard operation
tensorflex copied to clipboard

Segmentation Fault

Open gulcancan opened this issue 6 years ago • 2 comments

Hi,

Thank you for your effort in this project!

We are trying to use this repo to run a Tensorflow image segmentation model on Elixir. Please see the code below.

{:ok, graph} = Tensorflex.read_graph("./frozen_inference_graph.pb")

{:ok, input_tensor} = Tensorflex.load_image_as_tensor("example.jpg")

out_dims = Tensorflex.create_matrix(1,3,[[513,431,1]])

{:ok, output_tensor} = Tensorflex.float32_tensor_alloc(out_dims)

results = Tensorflex.run_session(graph, input_tensor, output_tensor, "ImageTensor", "SemanticPredictions")

Unfortunately, we get a segmentation fault error. Please see the stack trace in gdb below.

(gdb) bt #0 0x00007fe846a53701 in TF_NumDims () from /usr/local/lib/libtensorflow.so #1 0x00007fe8c6e3ad14 in run_session (env=0x7fe8c7cfbd80, argc=<optimized out>, argv=<optimized out>) at c_src/Tensorflex.c:696 #2 0x000055e2cd8fc042 in process_main () at x86_64-unknown-linux-gnu/opt/smp/beam_cold.h:119 #3 0x000055e2cd8eddbd in sched_thread_func (vesdp=0x7fe8cd2e3900) at beam/erl_process.c:8332 #4 0x000055e2cdb2fbcd in thr_wrapper (vtwd=0x7ffc34ad3050) at pthread/ethread.c:118 #5 0x00007fe9100f26db in start_thread (arg=0x7fe8c7cfc700) at pthread_create.c:463 #6 0x00007fe90fc1388f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

After digging up the issue, we came up with the conclusion that it originates from the allocation of "output_tensor" variable. Could you please help us on the issue? If you would like to populate the error, you can use any pretrained image segmentation model from the tensorflow deeplab model zoo page. Looking forward to your reply. Thank you.

gulcancan avatar Sep 27 '18 15:09 gulcancan

Thank you for bringing up the issue! I will try to solve it ASAP. :) Unfortunately I am completely swamped with some deadlines at the moment so I will only be able to take a look at this after 2-3 days. I apologize for any inconvenience caused and I appreciate your patience.

Thanks! :)

anshuman23 avatar Sep 27 '18 20:09 anshuman23

I noticed that there is some error handling missing that tells you what is wrong. If, for example, your "ImageTensor" or "SemanticPredictions" are not contained in the graph you loaded the run_session call crashes. So either you try starting with some example that works and move to your graph or you use some C debugger that lets you examine what's happening.

synalysis avatar Dec 19 '18 12:12 synalysis