diff --git a/samples/tensorflow/README.md b/samples/tensorflow/README.md index 8338bbb6ee7..f12a5c03c76 100644 --- a/samples/tensorflow/README.md +++ b/samples/tensorflow/README.md @@ -8,16 +8,14 @@ this example is built on top of the [TensorFlow C API](https://github.com/tensorflow/tensorflow/blob/r1.1/tensorflow/c/c_api.h), showing how a TensorFlow client in Kotlin/Native could look like. -##Installation - -[Install TensorFlow for C](https://www.tensorflow.org/versions/r1.1/install/install_c) into `/usr/local`. - -Compile: +## Installation ./build.sh -Run: +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. ./HelloTensorflow.kexe -You may need to specify `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` to `/opt/local/lib` if TensorFlow dynamic library cannot be found. +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. \ No newline at end of file diff --git a/samples/tensorflow/build.sh b/samples/tensorflow/build.sh index 1c0f0ece0f3..de0fec41d8d 100755 --- a/samples/tensorflow/build.sh +++ b/samples/tensorflow/build.sh @@ -2,7 +2,8 @@ PATH=../../dist/bin:../../bin:$PATH DIR=. -TF_TARGET_DIRECTORY="/opt/local" +TF_TARGET_DIRECTORY="/opt/local" # If you change this, adapt compilerOpts in tensorflow.def accordingly +TF_TYPE="cpu" # Change to "gpu" for GPU support if [ x$TARGET == x ]; then case "$OSTYPE" in @@ -20,9 +21,8 @@ var=COMPILER_ARGS_${TARGET} COMPILER_ARGS=${!var} # add -opt for an optimized build. if [ ! -d $TF_TARGET_DIRECTORY/include/tensorflow ]; then - echo "Installing TensorFlow..." - TF_TYPE="cpu" # Change to "gpu" for GPU support - TF_TARGET_DIRECTORY="/opt/local" + echo "Installing TensorFlow into $TF_TARGET_DIRECTORY ..." + sudo 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 @@ -30,4 +30,4 @@ 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/opt/local/lib -ltensorflow" || exit 1 + -linkerArgs "-L$TF_TARGET_DIRECTORY/lib -ltensorflow" || exit 1