rapidsai / cuml

cuML - RAPIDS Machine Learning Library
https://docs.rapids.ai/api/cuml/stable/
Apache License 2.0
4.22k stars 530 forks source link

[BUG] - Failed importing cuml after successfully installing via pip - TypeError: A Message class can only inherit from Message #5395

Open gg4u opened 1 year ago

gg4u commented 1 year ago

Failed importing cuml after successfully installing via pip.

I followed: https://docs.rapids.ai/install#pip-install

pip install cudf-cu11 dask-cudf-cu11 --extra-index-url=https://pypi.nvidia.com
pip install cuml-cu11 --extra-index-url=https://pypi.nvidia.com
pip install cugraph-cu11 --extra-index-url=https://pypi.nvidia.com

Installations were all Ok.

But:

import cuml

Fails with error:

TypeError: A Message class can only inherit from Message

I don't know how to interpret the message and solve it. Can you please help ?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[32], line 1
----> 1 import cuml

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/__init__.py:17
      1 #
      2 # Copyright (c) 2022-2023, NVIDIA CORPORATION.
      3 #
   (...)
     14 # limitations under the License.
     15 #
---> 17 from cuml.internals.base import Base, UniversalBase
     19 # GPU only packages
     21 import cuml.common.cuda as cuda

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/__init__.py:17
      1 #
      2 # Copyright (c) 2019-2023, NVIDIA CORPORATION.
      3 #
   (...)
     14 # limitations under the License.
     15 #
---> 17 from cuml.internals.base_helpers import BaseMetaClass, _tags_class_and_instance
     18 from cuml.internals.api_decorators import (
     19     _deprecate_pos_args,
     20     api_base_fit_transform,
   (...)
     32     exit_internal_api,
     33 )
     34 from cuml.internals.api_context_managers import (
     35     in_internal_api,
     36     set_api_output_dtype,
     37     set_api_output_type,
     38 )

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/base_helpers.py:20
     17 from inspect import Parameter, signature
     18 import typing
---> 20 from cuml.internals.api_decorators import (
     21     api_base_return_generic,
     22     api_base_return_array,
     23     api_base_return_sparse_array,
     24     api_base_return_any,
     25     api_return_any,
     26     _deprecate_pos_args,
     27 )
     28 from cuml.internals.array import CumlArray
     29 from cuml.internals.array_sparse import SparseCumlArray

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/api_decorators.py:24
     21 import warnings
     23 # TODO: Try to resolve circular import that makes this necessary:
---> 24 from cuml.internals import input_utils as iu
     25 from cuml.internals.api_context_managers import BaseReturnAnyCM
     26 from cuml.internals.api_context_managers import BaseReturnArrayCM

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/input_utils.py:19
      1 #
      2 # Copyright (c) 2019-2023, NVIDIA CORPORATION.
      3 #
   (...)
     14 # limitations under the License.
     15 #
     17 from collections import namedtuple
---> 19 from cuml.internals.array import CumlArray
     20 from cuml.internals.array_sparse import SparseCumlArray
     21 from cuml.internals.global_settings import GlobalSettings

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/array.py:22
     19 import operator
     20 import pickle
---> 22 from cuml.internals.global_settings import GlobalSettings
     23 from cuml.internals.logger import debug
     24 from cuml.internals.mem_type import MemoryType, MemoryTypeError

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/global_settings.py:20
     18 import threading
     19 from cuml.internals.available_devices import is_cuda_available
---> 20 from cuml.internals.device_type import DeviceType
     21 from cuml.internals.logger import warn
     22 from cuml.internals.mem_type import MemoryType

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/device_type.py:19
      1 #
      2 # Copyright (c) 2022-2023, NVIDIA CORPORATION.
      3 #
   (...)
     14 # limitations under the License.
     15 #
     18 from enum import Enum, auto
---> 19 from cuml.internals.mem_type import MemoryType
     22 class DeviceTypeError(Exception):
     23     """An exception thrown to indicate bad device type selection"""

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/mem_type.py:22
     19 from cuml.internals.device_support import GPU_ENABLED
     20 from cuml.internals.safe_imports import cpu_only_import, gpu_only_import
---> 22 cudf = gpu_only_import("cudf")
     23 cp = gpu_only_import("cupy")
     24 cpx_sparse = gpu_only_import("cupyx.scipy.sparse")

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cuml/internals/safe_imports.py:353, in gpu_only_import(module, alt)
    327 """A function used to import modules required only in GPU installs
    328 
    329 This function will attempt to import a module with the given name, but it
   (...)
    350     UnavailableMeta.
    351 """
    352 if GPU_ENABLED:
--> 353     return importlib.import_module(module)
    354 else:
    355     return safe_import(
    356         module,
    357         msg=f"{module} is not installed in non GPU-enabled installations",
    358         alt=alt,
    359     )

File /usr/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cudf/__init__.py:71
     69 from cudf.core.tools.datetimes import DateOffset, date_range, to_datetime
     70 from cudf.core.tools.numeric import to_numeric
---> 71 from cudf.io import (
     72     from_dlpack,
     73     read_avro,
     74     read_csv,
     75     read_feather,
     76     read_hdf,
     77     read_json,
     78     read_orc,
     79     read_parquet,
     80     read_text,
     81 )
     82 from cudf.options import describe_option, get_option, set_option
     83 from cudf.utils.dtypes import _NA_REP

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cudf/io/__init__.py:8
      6 from cudf.io.hdf import read_hdf
      7 from cudf.io.json import read_json
----> 8 from cudf.io.orc import read_orc, read_orc_metadata, to_orc
      9 from cudf.io.parquet import (
     10     ParquetDatasetWriter,
     11     merge_parquet_filemetadata,
   (...)
     14     write_to_dataset,
     15 )
     16 from cudf.io.text import read_text

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cudf/io/orc.py:14
     12 from cudf.api.types import is_list_like
     13 from cudf.utils import ioutils
---> 14 from cudf.utils.metadata import (  # type: ignore
     15     orc_column_statistics_pb2 as cs_pb2,
     16 )
     19 def _make_empty_df(filepath_or_buffer, columns):
     20     orc_file = orc.ORCFile(filepath_or_buffer)

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/cudf/utils/metadata/orc_column_statistics_pb2.py:21
     18 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n/cudf/utils/metadata/orc_column_statistics.proto\"B\n\x11IntegerStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\x12\x12\x0f\n\x07maximum\x18\x02 \x01(\x12\x12\x0b\n\x03sum\x18\x03 \x01(\x12\"A\n\x10\x44oubleStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\x01\x12\x0f\n\x07maximum\x18\x02 \x01(\x01\x12\x0b\n\x03sum\x18\x03 \x01(\x01\"A\n\x10StringStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\t\x12\x0f\n\x07maximum\x18\x02 \x01(\t\x12\x0b\n\x03sum\x18\x03 \x01(\x12\"%\n\x10\x42ucketStatistics\x12\x11\n\x05\x63ount\x18\x01 \x03(\x04\x42\x02\x10\x01\"B\n\x11\x44\x65\x63imalStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\t\x12\x0f\n\x07maximum\x18\x02 \x01(\t\x12\x0b\n\x03sum\x18\x03 \x01(\t\"2\n\x0e\x44\x61teStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\x11\x12\x0f\n\x07maximum\x18\x02 \x01(\x11\"_\n\x13TimestampStatistics\x12\x0f\n\x07minimum\x18\x01 \x01(\x12\x12\x0f\n\x07maximum\x18\x02 \x01(\x12\x12\x12\n\nminimumUtc\x18\x03 \x01(\x12\x12\x12\n\nmaximumUtc\x18\x04 \x01(\x12\"\x1f\n\x10\x42inaryStatistics\x12\x0b\n\x03sum\x18\x01 \x01(\x12\"\xa5\x03\n\x10\x43olumnStatistics\x12\x16\n\x0enumberOfValues\x18\x01 \x01(\x04\x12)\n\rintStatistics\x18\x02 \x01(\x0b\x32\x12.IntegerStatistics\x12+\n\x10\x64oubleStatistics\x18\x03 \x01(\x0b\x32\x11.DoubleStatistics\x12+\n\x10stringStatistics\x18\x04 \x01(\x0b\x32\x11.StringStatistics\x12+\n\x10\x62ucketStatistics\x18\x05 \x01(\x0b\x32\x11.BucketStatistics\x12-\n\x11\x64\x65\x63imalStatistics\x18\x06 \x01(\x0b\x32\x12.DecimalStatistics\x12\'\n\x0e\x64\x61teStatistics\x18\x07 \x01(\x0b\x32\x0f.DateStatistics\x12+\n\x10\x62inaryStatistics\x18\x08 \x01(\x0b\x32\x11.BinaryStatistics\x12\x31\n\x13timestampStatistics\x18\t \x01(\x0b\x32\x14.TimestampStatistics\x12\x0f\n\x07hasNull\x18\n \x01(\x08')
     20 _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
---> 21 _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'cudf.utils.metadata.orc_column_statistics_pb2', globals())
     22 if _descriptor._USE_C_DESCRIPTORS == False:
     24   DESCRIPTOR._options = None

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/google/protobuf/internal/builder.py:108, in BuildTopDescriptorsAndMessages(file_des, module_name, module)
    106 # Build messages.
    107 for (name, msg_des) in file_des.message_types_by_name.items():
--> 108   module[name] = BuildMessage(msg_des)

File /data0/home/h21/luas6629/venv/lib/python3.10/site-packages/google/protobuf/internal/builder.py:85, in BuildTopDescriptorsAndMessages.<locals>.BuildMessage(msg_des)
     83 create_dict['DESCRIPTOR'] = msg_des
     84 create_dict['__module__'] = module_name
---> 85 message_class = _reflection.GeneratedProtocolMessageType(
     86     msg_des.name, (_message.Message,), create_dict)
     87 _sym_db.RegisterMessage(message_class)
     88 return message_class

TypeError: A Message class can only inherit from Message
divyegala commented 1 year ago

cc @wphicks any ideas?

wphicks commented 1 year ago

@divyegala This appears to be originating with cuDF on import. You might check with the cuDF folks to see if they've seen anything like this in the latest stable release.

divyegala commented 1 year ago

@shwina could you take a look at this?