<@ULVA73B9P> I want to see Tensorflow/Keras output...
# ask-marvin
m
@Marvin I want to see Tensorflow/Keras output in my Prefect logs while I'm training a model, but it's not showing up when I run it in the cloud. It shows up when I run it interactively, though - how do I fix this?
m
To see TensorFlow/Keras logs in Prefect Cloud, you can follow these steps: 1. Configure Logging Levels: Ensure that your logging levels are set correctly. Prefect defaults to show
INFO
level logs and above, but TensorFlow/Keras might be emitting at a different level (e.g.,
DEBUG
).
Copy code
shell
   prefect config set PREFECT_LOGGING_LEVEL=DEBUG
You can also set this in your environment:
Copy code
shell
   export PREFECT_LOGGING_LEVEL=DEBUG
2. Use
get_run_logger
: Leverage Prefect's logging utility. Prefect provides a logger specific for flow runs that might help capture more context.
Copy code
python
   from prefect import flow, task
   from prefect.logging import get_run_logger

   @task
   def train_model():
       logger = get_run_logger()
       # Your TensorFlow/Keras training logic here
       <http://logger.info|logger.info>("Training started.")
       # ...

   @flow
   def main_flow():
       train_model()

   if __name__ == "__main__":
       main_flow()
3. Verify Cloud Configuration: Make sure your Prefect Cloud configuration is correct. Check your API keys and URLs.
Copy code
shell
   prefect config view
Ensure
PREFECT_API_URL
is set to
<https://api.prefect.cloud/api/>
and the
PREFECT_API_KEY
is valid. Sources: - Prefect 2.x Logging Guide - Prefect 2.x Troubleshooting - Prefect 3.0 Logging Configuration - Prefect 3.0 Troubleshooting Cloud If you still face issues, consider checking both Prefect's and TensorFlow/Keras' documentation for logging compatibility and make sure there are no conflicts.