robbert-harms/MDT

AttributeError: module 'pyopencl.cltypes' has no attribute '4'

dmd opened this issue · 5 comments

dmd commented

We are getting the error AttributeError: module 'pyopencl.cltypes' has no attribute '4'.

What does this mean?

Full trace:

(mdt_venv) [sgranger@node5 sgranger]$ mdt-model-fit -o /data/sgranger/mdt_venv/bin/ NODDI /data/sgranger/mdt_venv/bin/mdt_example_data/b1k_b2k/b1k_b2k_example_slices_24_38.nii.gz /data/sgranger/mdt_venv/bin/mdt_example_data/b1k_b2k/b1k_b2k.prtcl /data/sgranger/mdt_venv/bin/mdt_example_data/b1k_b2k/b1k_b2k_example_slices_24_38_mask.nii.gz
[2022-10-13 13:42:46,323] [INFO] [mdt.lib.processing.model_fitting] [get_model_fit] - Starting intermediate optimization for generating initialization point.
[2022-10-13 13:42:46,388] [INFO] [mdt.lib.processing.model_fitting] [fit_composite_model] - Using MDT version 1.2.6
[2022-10-13 13:42:46,388] [INFO] [mdt.lib.processing.model_fitting] [fit_composite_model] - Preparing for model BallStick_r1
[2022-10-13 13:42:46,406] [INFO] [mdt.models.composite] [_prepare_input_data] - No volume options to apply, using all 103 volumes.
[2022-10-13 13:42:46,406] [INFO] [mdt.utils] [estimate_noise_std] - Trying to estimate a noise std.
[2022-10-13 13:42:46,407] [INFO] [mdt.utils] [estimate_noise_std] - Estimated global noise std 19.613178253173828.
[2022-10-13 13:42:46,408] [INFO] [mdt.lib.processing.model_fitting] [_model_fit_logging] - Fitting BallStick_r1 model
[2022-10-13 13:42:46,408] [INFO] [mdt.lib.processing.model_fitting] [_model_fit_logging] - The 4 parameters we will fit are: ['S0.s0', 'w_stick0.w', 'Stick0.theta', 'Stick0.phi']
[2022-10-13 13:42:46,408] [INFO] [mdt.lib.processing.model_fitting] [fit_composite_model] - Saving temporary results in /data/sgranger/mdt_venv/bin/BallStick_r1/tmp_results.
Traceback (most recent call last):
  File "/data/sgranger/mdt_venv/bin/mdt-model-fit", line 8, in <module>
    sys.exit(ModelFit.console_script())
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/shell_utils.py", line 47, in console_script
    cls().start(sys.argv[1:])
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/shell_utils.py", line 66, in start
    self.run(args, {})
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/cli_scripts/mdt_model_fit.py", line 161, in run
    fit_model()
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/cli_scripts/mdt_model_fit.py", line 146, in fit_model
    mdt.fit_model(args.model,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/__init__.py", line 189, in fit_model
    inits = get_optimization_inits(model_name, input_data, output_folder, cl_device_ind=cl_device_ind,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/__init__.py", line 97, in get_optimization_inits
    return get_optimization_inits(model_name, input_data, output_folder, cl_device_ind=cl_device_ind,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/processing/model_fitting.py", line 177, in get_optimization_inits
    return get_init_data(model_name)
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/processing/model_fitting.py", line 115, in get_init_data
    fit_results = get_model_fit('BallStick_r1')
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/processing/model_fitting.py", line 84, in get_model_fit
    results = fit_model(model_name, input_data, output_folder, recalculate=False, use_cascaded_inits=False,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/__init__.py", line 204, in fit_model
    fit_composite_model(model_instance, input_data, output_folder, method,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/processing/model_fitting.py", line 301, in fit_composite_model
    worker = FittingProcessor(method, model, input_data.mask,
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/lib/processing/model_fitting.py", line 349, in __init__
    self._kernel_data = self._model.get_kernel_data()
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/models/composite.py", line 154, in get_kernel_data
    'protocol': self._get_protocol_data_as_var_data(),
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mdt/models/composite.py", line 1420, in _get_protocol_data_as_var_data
    const_d = {p.name: Array(value, ctype=p.ctype, parallelize_over_first_dimension=False)}
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mot/lib/kernel_data.py", line 696, in __init__
    self._data = convert_data_to_dtype(self._data, ctype)
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mot/lib/utils.py", line 181, in convert_data_to_dtype
    scalar_dtype = ctype_to_dtype(data_type, mot_float_type)
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/mot/lib/utils.py", line 148, in ctype_to_dtype
    return getattr(cl_array.vec, vector_type)
  File "/data/sgranger/mdt_venv/lib/python3.9/site-packages/pyopencl/array.py", line 210, in __getattr__
    return getattr(cltypes, name)
AttributeError: module 'pyopencl.cltypes' has no attribute '4'
(mdt_venv) [sgranger@node5 sgranger]$

Hi dmd,

Thanks for your inquiry. I see you are using Python 3.9 for running MDT. Unfortunately due to library updates Python 3.9 is not yet supported. I'll try to make time to update MDT to use the latest packages, but for now I would recommend using Python 3.6 to run MDT. In addition, when installing the "tatsu" package use the command:

pip install tatsu==5.5.0.

Alternatively you could use the Docker or Singularity images of MDT.

I am sorry for your inconvenience. I hope to find time to update MDT.

Best wishes,

Robbert

dmd commented

Hmm. I tried using the Singularity image but:

$ nvidia-smi
Tue Oct 18 09:22:31 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           On   | 00000000:3D:00.0 Off |                    0 |
| N/A   44C    P0    61W / 149W |   3502MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla K80           On   | 00000000:3E:00.0 Off |                    0 |
| N/A   27C    P8    30W / 149W |     11MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

$ singularity run --nv MDT/mdt.simg mdt-list-devices

$

Am I missing something obvious?

dmd commented

Also, if I try to install in a python 3.6 venv, I instead get:

Collecting mdt
  Using cached https://files.pythonhosted.org/packages/04/ec/6270404b01db5a2cb9c1b5694c8e260421b67afdfd02ec6f2373627bdac8/mdt-1.2.6-py2.py3-none-any.whl
Collecting pyyaml (from mdt)
  Using cached https://files.pythonhosted.org/packages/b3/85/79b9e5b4e8d3c0ac657f4e8617713cca8408f6cdc65d2ee6554217cedff1/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Collecting numpy>=1.9.0 (from mdt)
  Using cached https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting argcomplete (from mdt)
  Using cached https://files.pythonhosted.org/packages/d3/e5/c5509683462e51b070df9e83e7f72c1ccfe3f733f328b4a0f06804c27278/argcomplete-2.0.0-py2.py3-none-any.whl
Collecting scipy>=0.12.1 (from mdt)
  Using cached https://files.pythonhosted.org/packages/c8/89/63171228d5ced148f5ced50305c89e8576ffc695a90b58fe5bb602b910c2/scipy-1.5.4-cp36-cp36m-manylinux1_x86_64.whl
Collecting mot>=0.11.2 (from mdt)
  Using cached https://files.pythonhosted.org/packages/95/f8/fd9fb4c6ef42ff2f681ac649d3d8b5549ebbb3300e9cfd92f3936f927532/mot-0.11.3-py2.py3-none-any.whl
Collecting matplotlib>=1.5.1 (from mdt)
  Using cached https://files.pythonhosted.org/packages/09/03/b7b30fa81cb687d1178e085d0f01111ceaea3bf81f9330c937fb6f6c8ca0/matplotlib-3.3.4-cp36-cp36m-manylinux1_x86_64.whl
Collecting pyopencl>=2015.2 (from mdt)
  Using cached https://files.pythonhosted.org/packages/3f/64/94c020e7ebce9616162ecb8dcc3f4e0a30def0377fd7743ef26de89fa4f6/pyopencl-2022.2.4.tar.gz
    Complete output from command python setup.py egg_info:
    ---------------------------------------------------------------------------
    Sorry, your build failed. Try rerunning configure.py with different options.
    ---------------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-fg63mdve/numpy-1.23.4/setup.py", line 39, in <module>
        IncludeDir, LibraryDir, Libraries,
    RuntimeError: Python version >= 3.8 required.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-5jtjvn3j/pyopencl/setup.py", line 262, in <module>
        main()
      File "/tmp/pip-build-5jtjvn3j/pyopencl/setup.py", line 258, in main
        zip_safe=False)
      File "/tmp/pip-build-5jtjvn3j/pyopencl/aksetup_helper.py", line 32, in setup
        setup(*args, **kwargs)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/__init__.py", line 128, in setup
        _install_setup_requires(attrs)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/dist.py", line 514, in fetch_build_eggs
        replace_conflicting=True,
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/pkg_resources/__init__.py", line 770, in resolve
        replace_conflicting=replace_conflicting
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/pkg_resources/__init__.py", line 1053, in best_match
        return self.obtain(req, installer)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/pkg_resources/__init__.py", line 1065, in obtain
        return installer(requirement)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/dist.py", line 581, in fetch_build_egg
        return cmd.easy_install(req)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 678, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 704, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 889, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 1157, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 1143, in run_setup
        run_setup(setup_script, args)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 253, in run_setup
        raise
      File "/usr/lib64/python3.6/contextlib.py", line 99, in __exit__
        self.gen.throw(type, value, traceback)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib64/python3.6/contextlib.py", line 99, in __exit__
        self.gen.throw(type, value, traceback)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "/home/ddrucker/venvs/mdt_test/lib64/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-fg63mdve/numpy-1.23.4/setup.py", line 39, in <module>
        IncludeDir, LibraryDir, Libraries,
    RuntimeError: Python version >= 3.8 required.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5jtjvn3j/pyopencl/
You are using pip version 9.0.3, however version 22.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

ddrucker@micc ~ via 🐍 v3.6.8 (mdt_test) took 10s
✖1 ❯

Hi dmd,

I found the time to update MDT to handle this bug (and some others). You can now use MDT with Python 3.10 and the latest version of the TatSu library.

You can install the latest MDT using pip.

Let me know if this indeed solved your issue.

Best,

Robbert

dmd commented

My user says "that did the trick!"