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

No output from EmissionsTracker #370

Closed
coillarach opened this issue Feb 2, 2023 · 6 comments
Closed

No output from EmissionsTracker #370

coillarach opened this issue Feb 2, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@coillarach
Copy link

  • CodeCarbon version: 1.2.0
  • Python version: 3.9.15
  • Operating System: Ubuntu 18.04.6

Description

I Installed CodeCarbon according to the instructions as part of a JupyterHub setup. The example code worked perfectly with several groups of students, but then the output from the package just stopped. The data was no longer written to the emissions.csv file, and there was no output to the console on calling tracker.stop(). I have exactly the same configuration running locally where it still works fine. I therefore suspect that there is something about the state of the server installation that is causing the problem. My question is, under what circumstances would this behaviour be expected? That would help me track down the problem. From the CodeCarbon point of view, the issue is that there is no error message to say what has failed.

What I Did

Installed TLJH: https://tljh.jupyter.org/en/latest/install/index.html
Installed required packages including CodeCarbon
Prepared and tested the notebook which worked perfectly using the examples: https://mlco2.github.io/codecarbon/examples.html
Ran the same session for several groups of roughly 20 students - everything was fine for the first three groups, but on the fourth, EmissionsTracker.stop() returned no output and nothing was written to emissions.csv

I have reduced the number of configured users and reduced the volume of files to free up disk space. Neither of these actions worked.
I have also restarted the TLJH server and reinstalled CodeCarbon but the behaviour is the same.

from codecarbon import EmissionsTracker
import timeit
tracker = EmissionsTracker()
tracker.start()
t1 = timeit.timeit(stmt='[random.randint(0, 1000) for r in range(10000)]', 
              setup='import random', 
              number=1000
             )
tracker.stop()
@SaboniAmine SaboniAmine added the bug Something isn't working label Feb 2, 2023
@benoit-cty
Copy link
Contributor

benoit-cty commented Feb 7, 2023

Thanks for reporting this. Did you see the log anywhere ?

FYI using CodeCarbon multiple time on the same server at the same time will report wrong result as it will compute the server footprint for each notebook, not only the notebook running it. We are working on #316 for that.

@coillarach
Copy link
Author

coillarach commented Feb 8, 2023 via email

@benoit-cty benoit-cty self-assigned this Feb 10, 2023
@benoit-cty
Copy link
Contributor

Hi Brian,
I just do a test on a new project in TLJH and I saw the log in the Notebook:

image

jupyter-lab --version 3.5.3
jupyterhub --version 1.4.0

@coillarach
Copy link
Author

coillarach commented Feb 11, 2023 via email

@benoit-cty
Copy link
Contributor

benoit-cty commented Feb 11, 2023

You could add file logging this way:

tracker = EmissionsTracker()

# logger customization must be done after EmissionsTracker() because it reset all the log handlers.
set_logger_level(logging.DEBUG)
# create file handler which logs even debug messages
fh = logging.FileHandler("codecarbon.log")
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    "%(asctime)s - %(name)-12s: %(levelname)-8s %(message)s"
)
fh.setFormatter(formatter)
logger.addHandler(fh)
logger.debug("DEBUG TEST")
logger.info("INFO TEST")
logger.warning("warning TEST")

tracker.start()

You will get a file codecarbon.log in the notebook folder. It won't capture the initialization, that's our fault : one more issue.

@coillarach
Copy link
Author

coillarach commented Feb 16, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants