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

Feature Request: Cost to offset #276

Open
Erotemic opened this issue Jan 12, 2022 · 2 comments
Open

Feature Request: Cost to offset #276

Erotemic opened this issue Jan 12, 2022 · 2 comments
Labels
good first issue Good for newcomers

Comments

@Erotemic
Copy link
Contributor

In addition to knowing how much carbon a computation emits, it can also be insightful and more importantly actionable to know how much it would cost to offset that emission. I have a small demo script that uses the rates reported by two services: terrapass and cotap.

"""
Requirements:
    pip install codecarbon pint
"""

# Use pint for easy unit conversion
import pint
from codecarbon import EmissionsTracker
reg = pint.UnitRegistry()
reg.define('CO2 = []')
reg.define('dollar = []')
CO2_ton = reg.CO2 * reg.metric_ton
CO2_kg = reg.CO2 * reg.kg
CO2_pound = reg.CO2 * reg.pound


# ====================
# Carbon tracking code
# ====================
tracker = EmissionsTracker()
tracker.start()

# GPU Intensive code goes here
for i in range(100):
    pass

# tracker returns CO2 emissions in kgs
emissions = tracker.stop() * CO2_kg

# Pretend that we did a lot more than we did
pretend_factor = 1000000000
compute_emissions = emissions * pretend_factor

# ========================================
# That's all there is too carbon tracking!
# ========================================

# Calculate cost to offset with one of these carbon capture services:
co2_offset_costs = {
    'terrapass': (100.75 * reg.dollars) / (20_191 * CO2_pound).to(CO2_ton),
    'cotap': (15 * reg.dollars) / (1 * CO2_ton),
}
service = 'cotap'  # cotap is non-profit, lets use them
dollar_per_co2ton = co2_offset_costs[service]

cost_to_offset = (compute_emissions * dollar_per_co2ton).to_base_units()
print(f'It will cost roughly ${cost_to_offset:.2f} to offset this emission')

I think gathering information on available carbon offsetting services and increasing awareness of them would be a great direction for this project.

@vict0rsch
Copy link
Contributor

vict0rsch commented Jan 12, 2022

Thank you for your message!

I personally think this is a great next step, action after information and we don't want people being stuck and satisfied with info only.

However I'm not sure whether we should include offsetting as a part of the package, or at least not associated with any particular organisation.

We can also discuss the opportunity for even recommending offsetting. While I agree with the intention I know some people have reservations, + sobriety is probably the actual goal (re: Jevons paradox) and some infrastructures (such as cloud services) already offset emissions linked to computations.

It is not my area of expertise, so if you want to help and contribute something like a Wiki page that would be great :)

@benoit-cty
Copy link
Contributor

Maybe we could add it in Dashboard, with a common interface to allow other offsetting partner to add their services.

And, yes, offsetting is not sustainable. But still better than nothing ?

@benoit-cty benoit-cty added the good first issue Good for newcomers label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants