forked from tensorflow/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This partially addresses tensorflow#69, but it requires us to build TensorFlow from source, which is too slow to do on Travis.
- Loading branch information
Showing
7 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*~ | ||
*.log | ||
Cargo.lock | ||
target | ||
travis-ci/travis_rsa | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Runs valgrind and reports results. | ||
# | ||
# Since jemalloc dropped support for valgrind | ||
# (https://github.com/jemalloc/jemalloc/issues/369), and both Rust and TensorFlow | ||
# use jemalloc by default, we need to compile both without it. Unfortunately, | ||
# compiling TensorFlow from source is expensive, so this script takes a long | ||
# time to run. | ||
|
||
cd $(dirname $(readlink -f "$0")) | ||
|
||
tensorflow_version=1.1.0 | ||
|
||
valgrind_log=valgrind.log | ||
truncate --size=0 "$valgrind_log" | ||
|
||
# Disable jemalloc in TensorFlow. | ||
export TF_NEED_JEMALLOC=0 | ||
|
||
# Disable jemalloc in Rust. | ||
export TF_RUST_BUILD_FROM_SRC=true | ||
|
||
# Don't need to rebuild the world, and `cargo clean --package tensorflow-sys` doesn't seem to do the job. | ||
rm -rf tensorflow/target tensorflow-sys/target | ||
|
||
# This is the very expensive step. | ||
cargo +nightly build --features=nightly -p tensorflow-sys -vv | ||
|
||
# Run valgrind against all the things. | ||
export LD_LIBRARY_PATH="$PWD"/tensorflow-sys/target/libtensorflow-cpu-linux-x86_64-$tensorflow_version/lib | ||
for example in addition regression expressions; do | ||
cargo +nightly build --features='nightly tensorflow_unstable' --example="$example" | ||
valgrind --leak-check=full target/debug/examples/"$example" >> "$valgrind_log" 2>&1 | ||
done | ||
|
||
# Aggregate results. | ||
lost_bytes=$(awk '/(definitely|indirectly) lost:/{sum+=gensub(",","","g",$4)}END{print sum}' < "$valgrind_log") | ||
echo "Lost bytes: $lost_bytes" | ||
rel_log=$(readlink -f "$PWD"/"$valgrind_log") | ||
echo "For details, see $rel_log" |