lfwa / carbontracker

Track and predict the energy consumption and carbon footprint of training deep learning models.
MIT License
382 stars 29 forks source link

"'str' object has no attribute 'decode' " while using pretrained model #53

Closed Thire399 closed 1 year ago

Thire399 commented 1 year ago

I am getting this odd bug while trying to use the carbon tracker with a pretrained pytorch model and my own pytroch model.

Screenshot from 2023-03-02 13-27-17

For reference: Ubuntu 20.04.5 LTS GPU: GTX1070 8GB

raghavian commented 1 year ago

This is a duplicate of Issue 52. I will close it here, please follow the solution presented there until we make a new release.

raghavian commented 1 year ago

Looks like this a different hardware specific issue. So reopening it.

dmdequin commented 1 year ago

When getting the error AttributeError: 'str' object has no attribute 'decode', I was able to solve it by going to "carbontracker/components/gpu/nvidia.py" and commenting out line 25 where it says devices = [name.decode("utf-8") for name in names], then adding devices = names on a line before the return statement of that function. So the function should look like:

def devices(self):
        """Retrieves the name of all GPUs in a list.
        Note:
            Requires NVML to be initialized.
        """
        names = [pynvml.nvmlDeviceGetName(handle) for handle in self._handles]
        #devices = [name.decode("utf-8") for name in names]
        devices = names
        return devices
PedramBakh commented 1 year ago

This issue has been addressed in Release v1.2.0. With Python 3.10's change in handling char* from C extensions, the string decoding for NVIDIA GPU names via NVML has been adjusted accordingly. This ensures compatibility across different Python versions.