microsoft / Recursive-Cascaded-Networks

[ICCV 2019] Recursive Cascaded Networks for Unsupervised Medical Image Registration
https://arxiv.org/abs/1907.12353
MIT License
361 stars 87 forks source link

ModuleNotFoundError: No module named 'tensorflow.compat' #47

Closed agatadefr closed 3 years ago

agatadefr commented 3 years ago

Hi Guys,

I tried to run registration demo. My set up is python 3.6 and tensorflow=1.4 and cuda 8.0 But I am getting all the time an error : 0%| | 0/46 [00:00<?, ?it/s] 2%|▏ | 1/46 [00:00<00:29, 1.51it/s] 13%|█▎ | 6/46 [00:00<00:18, 2.13it/s] 20%|█▉ | 9/46 [00:01<00:14, 2.58it/s] 33%|███▎ | 15/46 [00:01<00:08, 3.61it/s] 39%|███▉ | 18/46 [00:02<00:07, 3.90it/s] 54%|█████▍ | 25/46 [00:02<00:04, 4.84it/s] 65%|██████▌ | 30/46 [00:02<00:02, 6.59it/s] 72%|███████▏ | 33/46 [00:03<00:02, 6.09it/s] 85%|████████▍ | 39/46 [00:03<00:00, 8.26it/s] 91%|█████████▏| 42/46 [00:03<00:00, 7.87it/s] 100%|██████████| 46/46 [00:03<00:00, 11.52it/s] 140 180 160 200 Traceback (most recent call last): File "demo.py", line 285, in main() File "demo.py", line 55, in main import tflearn File "/.local/lib/python3.6/site-packages/tflearn/init.py", line 4, in import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat'

Do I miss something ? or try any other version ?

I would appreciate for any help please.

Best, Agata

zsyzzsoft commented 3 years ago

Please try pip install tflearn==0.3.2

agatadefr commented 3 years ago

Hi @zsyzzsoft,

I updated tflearn==0.3.2

But I am still getting an error :

`{'base_network': 'VTN', 'n_cascades': 3, 'rep': 1, 'gpu': '0,1,2,3', 'checkpoint': None, 'dataset': 'datasets/liver.json', 'batch': 4, 'round': 20000, 'epochs': 5, 'debug': False, 'val_steps': 100, 'net_args': '', 'data_args': '', 'lr': 0.0001, 'clear_steps': False, 'finetune': None, 'name': None, 'logs': ''} [(<network.base_networks.VTNAffineStem object at 0x2aab0adfcb00>, {'raw_weight': 0, 'reg_weight': 0, 'weight': 1}), (<network.base_networks.VTN object at 0x2aab0adcdf60>, {'raw_weight': 0, 'weight': 1, 'reg_weight': 1}), (<network.base_networks.VTN object at 0x2aab0b17feb8>, {'raw_weight': 0, 'weight': 1, 'reg_weight': 1}), (<network.base_networks.VTN object at 0x2aab0b1f5da0>, {'raw_weight': 1, 'weight': 1, 'reg_weight': 1})] Graph built Traceback (most recent call last): File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call return fn(*args) File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1293, in _run_fn self._extend_graph() File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1354, in _extend_graph self._session, graph_def.SerializeToString(), status) File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'gaffdfrm/deform_stem_2/upsamp1to0/W': Operation was explicitly assigned to /gpu:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device. [[Node: gaffdfrm/deform_stem_2/upsamp1to0/W = VariableV2[_class=["loc:@gaffdfrm/deform_stem_2/upsamp1to0/W"], container="", dtype=DT_FLOAT, shape=[4,4,4,3,35], shared_name="", _device="/gpu:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "demo.py", line 285, in main() File "demo.py", line 93, in main saver.restore(sess, checkpoint) File "/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1666, in restore {self.saver_def.filename_tensor_name: save_path}) File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1120, in _run feed_dict_tensor, options, run_metadata) File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run options, run_metadata) File "/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'gaffdfrm/deform_stem_2/upsamp1to0/W': Operation was explicitly assigned to /gpu:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device. [[Node: gaffdfrm/deform_stem_2/upsamp1to0/W = VariableV2[_class=["loc:@gaffdfrm/deform_stem_2/upsamp1to0/W"], container="", dtype=DT_FLOAT, shape=[4,4,4,3,35], shared_name="", _device="/gpu:0"]()]]

Caused by op 'gaffdfrm/deform_stem_2/upsamp1to0/W', defined at: File "demo.py", line 285, in main() File "demo.py", line 85, in main fast_reconstruction=args.fast_reconstruction, validation=True) File "/dev/reg3/Recursive-Cascaded-Networks/network/framework.py", line 98, in init self.predictions = gpus(self.network, net_pls) File "Agata/dev/reg3/Recursive-Cascaded-Networks/network/utils.py", line 151, in call result = net([arg[i] for arg in args]) File "/Agata/dev/reg3/Recursive-Cascaded-Networks/network/utils.py", line 108, in call return self.build(args, kwargs) File "/Agata/dev/reg3/Recursive-Cascaded-Networks/network/recursive_cascaded_networks.py", line 87, in build stem_result = stem(img1, stem_results[-1]['warped']) File "/Agata/dev/reg3/Recursive-Cascaded-Networks/network/utils.py", line 108, in call return self.build(*args, *kwargs) File "/Agata/dev/reg3/Recursive-Cascaded-Networks/network/base_networks.py", line 120, in build pred0 = upconvolve('upsamp1to0', concat1, dims, 4, 2, shape0[1:4]) File "/Agata/dev/reg3/Recursive-Cascaded-Networks/network/base_networks.py", line 30, in upconvolve padding='same', activation='linear', bias=False, scope=opName, reuse=reuse, weights_init=weights_init) File "/.local/lib/python3.6/site-packages/tflearn/layers/conv.py", line 1147, in conv_3d_transpose trainable=trainable, restore=restore) File "/.local/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args return func(args, current_args) File "/.local/lib/python3.6/site-packages/tflearn/variables.py", line 65, in variable validate_shape=validate_shape) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1203, in get_variable constraint=constraint) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1092, in get_variable constraint=constraint) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 425, in get_variable constraint=constraint) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 394, in _true_getter use_resource=use_resource, constraint=constraint) File "/pstore/home/krasona/.local/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 805, in _get_single_variable constraint=constraint) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 213, in init constraint=constraint) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 309, in _init_from_args name=name) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 133, in variable_op_v2 shared_name=shared_name) File "/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 927, in _variable_v2 shared_name=shared_name, name=name) File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2956, in create_op op_def=op_def) File "/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1470, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'gaffdfrm/deform_stem_2/upsamp1to0/W': Operation was explicitly assigned to /gpu:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device. [[Node: gaffdfrm/deform_stem_2/upsamp1to0/W = VariableV2[_class=["loc:@gaffdfrm/deform_stem_2/upsamp1to0/W"], container="", dtype=DT_FLOAT, shape=[4,4,4,3,35], shared_name="", _device="/gpu:0"]()]]

`

zsyzzsoft commented 3 years ago

Are there GPUs on the machine? Did you install tensorflow-gpu or tensorflow?

agatadefr commented 3 years ago

Hi @zsyzzsoft ,

I run it on cluster and I can have an option with gpu and without gpu. Finally I mananed to run it properly. Thank You so much for your help !! Thank You @zsyzzsoft :)

Hoodini-Gzj commented 2 years ago

Hi @zsyzzsoft ,

I run it on cluster and I can have an option with gpu and without gpu. Finally I mananed to run it properly. Thank You so much for your help !! Thank You @zsyzzsoft :)

I'm in the same situation as you. How did you solve it?Looking forward to your reply