samples: Install Tensorflow in HOME directory

This commit is contained in:
Ilya Matveev
2017-05-15 15:22:30 +07:00
committed by ilmat192
parent d28f8ce7f2
commit 12847428fa
4 changed files with 17 additions and 8 deletions
+5 -2
View File
@@ -47,5 +47,8 @@ proto/compiler/google/src/google/protobuf/compiler/kotlin/protoc
# translator auto generated artifacts
kotstd/ll
#test teamcity property: commitable only with -f
backend.native/tests/teamcity-test.property
# test teamcity property: commitable only with -f
backend.native/tests/teamcity-test.property
# Sample output
samples/**/*.kt.bc-build
+4 -2
View File
@@ -12,10 +12,12 @@ showing how a TensorFlow client in Kotlin/Native could look like.
./build.sh
will install [TensorFlow for C](https://www.tensorflow.org/versions/r1.1/install/install_c) into `/opt/local` (if not yet done) and build the example.
will install [TensorFlow for C](https://www.tensorflow.org/versions/r1.1/install/install_c) into
`$HOME/.konan/third-party/tensorflow` (if not yet done) and build the example.
./HelloTensorflow.kexe
will then run the example.
You may need to specify `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` to `/opt/local/lib` if the TensorFlow dynamic library cannot be found.
You may need to specify `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` to `$HOME/.konan/third-party/tensorflow/lib`
if the TensorFlow dynamic library cannot be found.
+8 -3
View File
@@ -2,9 +2,12 @@
PATH=../../dist/bin:../../bin:$PATH
DIR=.
TF_TARGET_DIRECTORY="/opt/local" # If you change this, adapt compilerOpts in tensorflow.def accordingly
TF_TARGET_DIRECTORY="$HOME/.konan/third-party/tensorflow"
TF_TYPE="cpu" # Change to "gpu" for GPU support
CFLAGS_macbook="-I${TF_TARGET_DIRECTORY}/include"
CFLAGS_linux="-I${TF_TARGET_DIRECTORY}/include"
if [ x$TARGET == x ]; then
case "$OSTYPE" in
darwin*) TARGET=macbook; TF_TARGET=darwin ;;
@@ -22,12 +25,14 @@ COMPILER_ARGS=${!var} # add -opt for an optimized build.
if [ ! -d $TF_TARGET_DIRECTORY/include/tensorflow ]; then
echo "Installing TensorFlow into $TF_TARGET_DIRECTORY ..."
sudo mkdir -p $TF_TARGET_DIRECTORY
mkdir -p $TF_TARGET_DIRECTORY
curl -s -L \
"https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-${TF_TARGET}-x86_64-1.1.0.tar.gz" |
sudo tar -C $TF_TARGET_DIRECTORY -xz
tar -C $TF_TARGET_DIRECTORY -xz
fi
cinterop -def $DIR/tensorflow.def -copt "$CFLAGS" -target $TARGET -o tensorflow.kt.bc || exit 1
konanc $COMPILER_ARGS -target $TARGET $DIR/HelloTensorflow.kt -library tensorflow.kt.bc -o HelloTensorflow.kexe \
-linkerArgs "-L$TF_TARGET_DIRECTORY/lib -ltensorflow" || exit 1
echo "Note: You may need to specify LD_LIBRARY_PATH or DYLD_LIBRARY_PATH env variables to $TF_TARGET_DIRECTORY/lib if the TensorFlow dynamic library cannot be found."
-1
View File
@@ -1,2 +1 @@
headers = tensorflow/c/c_api.h
compilerOpts = -I/opt/local/include -L/opt/local/lib