README.md 2.5 KB
Newer Older
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
1 2 3 4
# About

A test program on feeding TF C++ directly from GPU memory.

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
5 6 7 8 9 10 11 12
# What is happeing
* create graph (just copying from input Placeholder to output Identity op) 
* convert graph to session
* set session opts and allocate tensor in gpu - MakeCallable
* RunCallable as is - output tensor will be all 0s
* pass tensor pointer to a test CUDA kernel, run it
* RunCallable - the output will be data from CUDA kernel

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
13
# Requirements
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
14 15 16
Tested on:
* GeForce GTX 1050 Ti
* Ubuntu 18.04.3
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
17 18
* Tensorflow 1.15 lib for C++ (`bazel build //tensorflow:libtensorflow_cc.so`)
* CUDA 10.0
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
19

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
20
See [installation instructions](https://wiki.elphel.com/wiki/Feeding_Tensorflow_from_GPU). OpenCV is not needed.
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
21
# Run
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
22
```
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
23
mkdir build; cd build
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
24 25
cmake ..
./tf-gpu-feed
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
26
```
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
27 28 29 30 31 32 33 34 35 36 37 38 39
# Output
Will print output tensors:

1st RunCallable: 
```
Tensor<type: uint8 shape: [256] values: 0 0 0...>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
```
2nd RunCallable:
```
Tensor<type: uint8 shape: [256] values: 1 2 3...>
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
```