Unsuccessfully running tensorflow federated "Hello world" example

109 Views Asked by At

I am trying to execute tensorflow federated "Hello world" in jupyter notebook on Visual Studio Code, however the code freezes and doesn't display anything.

Here is the code:

import tensorflow as tf
import tensorflow_federated as tff

import nest_asyncio
nest_asyncio.apply()

print(tff.federated_computation(lambda: 'Hello, World!')())

Output looks something like:

2023-10-06 06:34:20.644234: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2023-10-06 06:34:20.644271: W tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:265] failed call to cuInit: UNKNOWN ERROR (303)
2023-10-06 06:34:20.644299: I tensorflow/compiler/xla/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (ab1clmll01): /proc/driver/nvidia/version does not exist
2023-10-06 06:34:20.644609: I tensorflow/core/grappler/clusters/single_machine.cc:358] Starting new session
2023-10-06 06:34:20.645058: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

Below are package version details:

  • python: 3.9.16
  • tensorflow_federated: 0.48.0
  • tensorflow: 2.11.1
  • notebook: 7.0.4

Can anyone suggest how can this be corrected?

1

There are 1 best solutions below

1
Brave On

You can try to fix this problem for cpu-only machines by using the tensorflow-cpu package and deleting old tensorflow

pip uninstall tensorflow
pip install tensorflow-cpu