    def from_spec(cls, spec: t.Any) -> float:
        """
        Convert spec to CpuResource.

        spec can be a float, int or string.
        - 1.0 -> 1.0
        - 1 -> 1.0
        - "1" -> 1.0
        - "10m" -> 0.01
        """
        if not isinstance(spec, (int, float, str)):
            raise TypeError("cpu must be int, float or str")

        if isinstance(spec, (int, float)):
            return float(spec)

        milli_match = re.match("([0-9]+)m", spec)
        if milli_match:
            return float(milli_match[1]) / 1000.0

        try:
            return float(spec)
        except ValueError:
            raise BentoMLConfigException(f"Invalid CPU resource limit '{spec}'. ")
Convert spec to CpuResource.

spec can be a float, int or string.
- 1.0 -> 1.0
- 1 -> 1.0
- "1" -> 1.0
- "10m" -> 0.01
src/bentoml/_internal/resource.py