BBillot / SynthSeg

Contrast-agnostic segmentation of MRI scans
Apache License 2.0
358 stars 92 forks source link

Installation issue #93

Open Shreyas-Bhat opened 6 days ago

Shreyas-Bhat commented 6 days ago

Hello,

Thanks a lot for open-sourcing this code. It is very helpful. I am facing the following error. I tried to downgrade my numpy to several previous versions. However, this issues hasn't been resolved. Can the maintainers of synthseg kindly look into this issue and let me know what I can do to solve this?

Best,

2024-09-09 22:45:54.444118: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:92
61] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN wh
en one has already been registered                                                     
2024-09-09 22:45:54.444265: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:60
7] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT whe
n one has already been registered                                                      
2024-09-09 22:45:54.792866: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1
515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS
 when one has already been registered                                                  
2024-09-09 22:45:55.454141: I tensorflow/core/platform/cpu_feature_guard.cc:182] This Te
nsorFlow binary is optimized to use available CPU instructions in performance-critical o
perations.                                                                             
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow
with the appropriate compiler flags.                                                   
2024-09-09 22:46:03.084162: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-T
RT Warning: Could not find TensorRT                                                    

SynthSeg 2.0                                                                           

using 1 thread                                                                         
Traceback (most recent call last):                                                     
  File "/home/sbb36/SynthSeg/scripts/commands/SynthSeg_predict.py", line 113, in <module
>                                                                                      
    predict(path_images=args['i'],                                                     
  File "/home/sbb36/SynthSeg/SynthSeg/predict_synthseg.py", line 87, in predict        
    labels_segmentation, _ = utils.get_list_labels(label_list=labels_segmentation)     
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^     
  File "/home/sbb36/SynthSeg/ext/lab2im/utils.py", line 227, in get_list_labels        
    label_list = np.array(reformat_to_list(label_list, load_as_numpy=True, dtype='int'))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sbb36/SynthSeg/ext/lab2im/utils.py", line 335, in reformat_to_list       
    if isinstance(var, (int, float, np.int, np.int32, np.int64, np.float, np.float32, np
.float64)):                                                                            
                                    ^^^^^^                                             
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site
-packages/numpy/__init__.py", line 319, in __getattr__                                 
    raise AttributeError(__former_attrs__[attr])                                       
AttributeError: module 'numpy' has no attribute 'int'.  
hvgazula commented 5 days ago
File "/home/sbb36/SynthSeg/ext/lab2im/utils.py", line 335, in reformat_to_list       
    if isinstance(var, (int, float, np.int, np.int32, np.int64, np.float, np.float32, np
.float64)):

As suggested by the error, simply remove np.int and np.float from the offending line in utils.py and you should be alright.

Shreyas-Bhat commented 3 days ago

Thank you so much for your response @hvgazula ! There seems to be a followup error and I wonder if it has anything to do with the numpy version. Thanks

Traceback (most recent call last):                                                                                                                                                                                              
  File "/home/sbb36/SynthSeg/scripts/commands/SynthSeg_predict.py", line 28, in <module>                                                                                                                                        
    from SynthSeg.predict_synthseg import predict                                                                                                                                                                               
  File "/home/sbb36/SynthSeg/SynthSeg/__init__.py", line 1, in <module>                                                                                                                                                         
    from . import brain_generator                                                                                                                                                                                               
  File "/home/sbb36/SynthSeg/SynthSeg/brain_generator.py", line 21, in <module>                                                                                                                                                 
    from SynthSeg.model_inputs import build_model_inputs                                                                                                                                                                        
  File "/home/sbb36/SynthSeg/SynthSeg/model_inputs.py", line 22, in <module>                                                                                                                                                    
    from ext.lab2im import utils                                                                                                                                                                                                
  File "/home/sbb36/SynthSeg/ext/lab2im/__init__.py", line 1, in <module>                                                                                                                                                       
    from . import edit_tensors                                                                                                                                                                                                  
  File "/home/sbb36/SynthSeg/ext/lab2im/edit_tensors.py", line 28, in <module>                                                                                                                                                  
    import tensorflow as tf                                                                                                                                                                                                     
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/__init__.py", line 48, in <module>                                                                                 
    from tensorflow._api.v2 import __internal__                                                                                                                                                                                 
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/_api/v2/__internal__/__init__.py", line 8, in <module>                                                             
    from tensorflow._api.v2.__internal__ import autograph                                                                                                                                                                       
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/_api/v2/__internal__/autograph/__init__.py", line 8, in <module>                                                   
    from tensorflow.python.autograph.core.ag_ctx import control_status_ctx # line: 34 
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/autograph/core/ag_ctx.py", line 21, in <module>
    from tensorflow.python.autograph.utils import ag_logging
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/autograph/utils/__init__.py", line 17, in <module>
    from tensorflow.python.autograph.utils.context_managers import control_dependency_on_returns
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/autograph/utils/context_managers.py", line 19, in <module>
    from tensorflow.python.framework import ops
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 45, in <module>
    from tensorflow.python.eager import context
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/eager/context.py", line 37, in <module>
    from tensorflow.python.eager import execute
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/eager/execute.py", line 21, in <module>
    from tensorflow.python.framework import dtypes
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py", line 21, in <module>
    import ml_dtypes
  File "/autofs/vast/qtim/tools/pyenv/versions/3.11.3/envs/brainmets/lib/python3.11/site-packages/ml_dtypes/__init__.py", line 32, in <module>
    from ml_dtypes._custom_floats import bfloat16
ImportError: numpy.core.umath failed to import