Closed headscott closed 2 months ago
Hello,
You could lower logs with parameter log_level
: EmissionsTracker(output_dir="emissions", log_level="error")
But could you tell us more on your environment ?
Because you seems to have a SLURM_JOB_ID
env variable set but no scontrol
tool. Are you on a SLURM supercomputer ?
Okay thank you.
I am running this code on a remote cluster. There I started a tmux session
and inside this session I started my slurm job via srun
I can use squeue and scontrol on the cluster, but not inside the tmux session with my slurmjob already running. I am not sure if the setup is wrong, but this is probably the reason, why it keeps saying Error running scontrol show job $SLURM_JOB_ID
.
Thank's for the information. We display a warning, that seems legit. But it will be better to display it only once in this case.
If I do log_level="error"
, it still prints
/bin/bash: line 1: scontrol: command not found
/bin/bash: line 1: scontrol: command not found
multiple times
I don't get it, but now when I run this code:
from codecarbon import EmissionsTracker
def energy_of_command(command):
tracker = EmissionsTracker(output_dir="emissions")
tracker.start()
try:
print("TEST")
finally:
tracker.stop()
print(f"Energy consumed (kWh): {tracker.final_emissions_data['emissions'] / 1000.0}")
if __name__ == "__main__":
energy_of_command(f"make experiments/RaResNet50/.done_train")
it says:
TEST
[codecarbon INFO @ 16:07:00] Saving emissions data to file C:\Users\fabia\PycharmProjects\RobustBenchCarbon\emissions\emissions.csv
[codecarbon INFO @ 16:07:00] Energy consumed for RAM : 0.000000 kWh. RAM Power : 5.98262357711792 W
[codecarbon INFO @ 16:07:00] Energy consumed for all GPUs : 0.000000 kWh. Total GPU Power : 0.0 W
[codecarbon INFO @ 16:07:00] Energy consumed for all CPUs : 0.000000 kWh. Total CPU Power : 42.5 W
[codecarbon INFO @ 16:07:00] 0.000000 kWh of electricity used since the beginning.
C:\Python312\Lib\site-packages\codecarbon\output_methods\file.py:50: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
df = pd.concat([df, pd.DataFrame.from_records([dict(total.values)])])
[codecarbon WARNING @ 16:07:00] graceful shutdown. Exceptions:
[codecarbon WARNING @ 16:07:00] <class 'Exception'>
Traceback (most recent call last):
File "C:\Python312\Lib\site-packages\codecarbon\core\util.py", line 23, in suppress
yield
File "C:\Python312\Lib\contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\site-packages\codecarbon\emissions_tracker.py", line 569, in stop
self._persist_data(
File "C:\Python312\Lib\site-packages\codecarbon\emissions_tracker.py", line 590, in _persist_data
handler.out(total_emissions, delta_emissions)
File "C:\Python312\Lib\site-packages\codecarbon\output_methods\file.py", line 71, in out
df.to_csv(self.save_file_path, index=False)
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\util\_decorators.py", line 333, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\core\generic.py", line 3967, in to_csv
return DataFrameRenderer(formatter).to_csv(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\io\formats\format.py", line 1014, in to_csv
csv_formatter.save()
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\io\formats\csvs.py", line 251, in save
with get_handle(
^^^^^^^^^^^
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\io\common.py", line 749, in get_handle
check_parent_directory(str(handle))
File "C:\Users\fabia\AppData\Roaming\Python\Python312\site-packages\pandas\io\common.py", line 616, in check_parent_directory
raise OSError(rf"Cannot save file into a non-existent directory: '{parent}'")
OSError: Cannot save file into a non-existent directory: 'emissions'
[codecarbon WARNING @ 16:07:00] stopping.
Traceback (most recent call last):
File "C:\Users\fabia\PycharmProjects\RobustBenchCarbon\testeTracker.py", line 13, in <module>
energy_of_command(f"make experiments/RaResNet50/.done_train")
File "C:\Users\fabia\PycharmProjects\RobustBenchCarbon\testeTracker.py", line 10, in energy_of_command
print(f"Energy consumed (kWh): {tracker.final_emissions_data['emissions'] / 1000.0}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EmissionsTracker' object has no attribute 'final_emissions_data'. Did you mean: '_prepare_emissions_data'?
Sorry for the delay,
They are two things to change:
OSError: Cannot save file into a non-existent directory: 'emissions'
tracker.final_emissions_data.emissions
instead of tracker.final_emissions_data['emissions']
I've created a PR to have a better error message : https://github.com/mlco2/codecarbon/pull/611
okay thank you. This helped
Description
I got these prints:
Why does it print the scontrol error muliple times while training? It also prints the "Energy consumed" messages all the time
What I Did
I just wanted to run this code:
the make command is from this github: poloclub/robust-principles