-
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.
[Tensorflow] add helper script to check version, if tf is not install…
…ed or too old, return error
- Loading branch information
Showing
2 changed files
with
55 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,17 @@ | ||
#!/usr/bin/env bash | ||
# Build SSVM-Storage dependencies | ||
cd ./rust_native_storage_library/ | ||
make target/debug/librust_native_storage_library.so | ||
cd ../ | ||
|
||
# Check TensorFlow version | ||
c++ ./utils/checker/tensorflow_version_checker.cc -ltensorflow -o ./tf_ver | ||
./tf_ver | ||
if [ "$?" -eq "0" ] | ||
then | ||
rm ./tf_ver | ||
exit 0 | ||
else | ||
echo "TensorFlow C library is not yet installed or is too old to support" | ||
exit 1 | ||
fi |
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,42 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
#include <tensorflow/c/c_api.h> | ||
|
||
struct Version { | ||
int Major; | ||
int Minor; | ||
int Revision; | ||
Version() = default; | ||
Version(std::string Str) { | ||
std::stringstream Ss(Str); | ||
std::string Buffer; | ||
// Major | ||
std::getline(Ss, Buffer, '.'); | ||
Major = std::stoi(Buffer); | ||
// Minor | ||
std::getline(Ss, Buffer, '.'); | ||
Minor = std::stoi(Buffer); | ||
// Revision | ||
std::getline(Ss, Buffer, '.'); | ||
Revision = std::stoi(Buffer); | ||
} | ||
bool isTooOld() { | ||
if (Major < 2) { | ||
return true; | ||
} else if (Major == 2 && Minor < 3) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; | ||
int main() { | ||
std::string TFVer(TF_Version()); | ||
std::cout << "Your TensorFlow C library version: " << TFVer << "\n"; | ||
Version V(TFVer); | ||
if (V.isTooOld()) { | ||
std::cerr << "Your TensorFlow C library is too old. Please upgrade to >=2.3.0\n"; | ||
return 1; | ||
} | ||
return 0; | ||
} |