Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Improve handling of TF CUDA tests for 14_0_X #44375

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions PhysicsTools/TensorFlow/src/TensorFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ namespace tensorflow {
// NVidia GPU
else if (backend == Backend::cuda) {
if (not ri->nvidiaDriverVersion().empty()) {
// Check if one GPU device is visible to TF
// If not, an exception is raised --> this can happen in case of driver version mismatch
// or missing CUDA support in TF compilation
if ((*_options.config.mutable_device_count())["GPU"] == 0) {
edm::Exception ex(edm::errors::UnavailableAccelerator);
ex << "Cuda backend requested, NVIDIA GPU visible to cmssw, but not visible to TensorFlow in the job";
ex.addContext("Calling tensorflow::setBackend()");
throw ex;
}
// Take only the first GPU in the CUDA_VISIBLE_DEVICE list
(*_options.config.mutable_device_count())["GPU"] = 1;
_options.config.mutable_gpu_options()->set_visible_device_list("0");
Expand Down
16 changes: 9 additions & 7 deletions PhysicsTools/TensorFlow/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">
<iftool name="tf_cuda_support">
<bin name="testTFHelloWorldCUDA" file="testRunner.cpp,testHelloWorldCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -29,7 +29,7 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">
<iftool name="tf_cuda_support">
<bin name="testTFMetaGraphLoadingCUDA" file="testRunner.cpp,testMetaGraphLoadingCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -52,7 +52,7 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">
<iftool name="tf_cuda_support">
<bin name="testTFGraphLoadingCUDA" file="testRunner.cpp,testGraphLoadingCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -75,7 +75,8 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">

<iftool name="tf_cuda_support">
<bin name="testTFConstSessionCUDA" file="testRunner.cpp,testConstSessionCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -98,7 +99,7 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">
<iftool name="tf_cuda_support">
<bin name="testTFSessionCacheCUDA" file="testRunner.cpp,testSessionCacheCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -121,7 +122,8 @@
<use name="PhysicsTools/TensorFlow"/>
</bin>

<iftool name="cuda">

<iftool name="tf_cuda_support">
<bin name="testTFThreadPoolsCUDA" file="testRunner.cpp,testThreadPoolsCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand All @@ -145,7 +147,7 @@
</bin>


<iftool name="cuda">
<iftool name="tf_cuda_support">
<bin name="testTFVisibleDevicesCUDA" file="testRunner.cpp,testVisibleDevicesCUDA.cc">
<use name="boost_filesystem"/>
<use name="catch2"/>
Expand Down