bi-att-flow icon indicating copy to clipboard operation
bi-att-flow copied to clipboard

Error when running this tensorflow-1.1.0 version

Open x-zho14 opened this issue 7 years ago • 19 comments

``$ python -m basic.cli --mode train --noload --debug Traceback (most recent call last): File "anaconda2/envs/tensorflow/lib/python3.5/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "anaconda2/envs/tensorflow/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/bi-att-flow/basic/cli.py", line 5, in from basic.main import main as m File "/bi-att-flow/basic/main.py", line 14, in from basic.model import get_multi_gpu_models File "/bi-att-flow/basic/model.py", line 6, in from tensorflow.python.ops.rnn_cell import BasicLSTMCell ImportError: No module named 'tensorflow.python.ops.rnn_cell'

I have installed the tensorflow-gpu 1.1.0 version and python 3.5.3 and all the required libraries.

It may seem some error with the code version and tensorflow, how can I solve this problem?

Well, it's hard to find a tensorflow-gpu 0.11 version available now so I have to run the 1.1.0 version.

Thanks a lot!

x-zho14 avatar Jul 14 '17 02:07 x-zho14

You should use dev branch to run the tensorflow 1.1 version; for master branch, use tensorflow 0.12

neufang avatar Jul 14 '17 14:07 neufang

Thanks for your help! From this I come to know that I should not use git clone for the other branch.

x-zho14 avatar Jul 14 '17 17:07 x-zho14

I encounter another error when turning to the dev branch. (tensorflow-1.1.0) /bi-att-flow-1.1.0/bi-att-flow-dev$ python -m basic.cli --mode train --noload --debug Traceback (most recent call last): File "envs/tensorflow-1.1.0/lib/python3.5/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "anaconda2/envs/tensorflow-1.1.0/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/bi-att-flow-1.1.0/bi-att-flow-dev/basic/cli.py", line 5, in from basic.main import main as m File "/bi-att-flow-1.1.0/bi-att-flow-dev/basic/main.py", line 14, in from basic.model import get_multi_gpu_models File "/bi-att-flow-1.1.0/bi-att-flow-dev/basic/model.py", line 10, in from my.tensorflow.nn import softsel, get_logits, highway_network, multi_conv1d File "/bi-att-flow-1.1.0/bi-att-flow-dev/my/tensorflow/nn.py", line 1, in from tensorflow.python.ops.rnn_cell_impl import _linear ImportError: cannot import name '_linear' And there isn't a _linear module in tensorflow 1.1.0 version, as is shown in https://github.com/tensorflow/tensorflow/blob/r1.1/tensorflow/python/ops/rnn_cell_impl.py. How can I solve this problem?

x-zho14 avatar Jul 14 '17 18:07 x-zho14

check the tensorflow version, you might have installed 1.2, which is different from 1.1 (nice job google). change the first line of requirements.txt to tensorflow-gpu ==1.1.0

neufang avatar Jul 14 '17 22:07 neufang

I met this problem too. I indeed used tensorflow 1.1.0, but there isn't a _linear module in tensorflow 1.1.0 version, as is shown in https://github.com/tensorflow/tensorflow/blob/r1.1/tensorflow/python/ops/rnn_cell_impl.py

daisyjack avatar Aug 10 '17 13:08 daisyjack

@x-zho14 maybe it's because of anaconda package? I use default python3.5 with tensorflow 1.1.0 and virtualenv. It doesnt have this problem.

neufang avatar Aug 10 '17 14:08 neufang

@x-zho14 @daisyjack As per this commit: https://github.com/allenai/bi-att-flow/commit/3fb0943fefd71eea6886dd247d373f46054e922f , it seems this _linear was changed for tf-1.2 compatibility, but on tf-1.1 it doesn't work for me either.

So my workaround is to revert back to previous one:

from tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl import _linear
...
flat_out = _linear(flat_args, output_size, bias, bias_start=bias_start)

this works for me.

usakey avatar Aug 15 '17 06:08 usakey

@usakey Your solution not work under tensorflow v1.4

This fix it for me: from tensorflow.contrib.rnn.python.ops.rnn_cell import _Linear

huan avatar Jan 01 '18 10:01 huan

For anyone starting to try to make sure this works, the following steps did for me:

  1. Create conda env with python version 3.5

  2. Install tensorflow version 0.12.1 after activating env using: export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl (or any appropriate version) pip install $TF_BINARY_URL

  3. Edit the basic/run_single.sh file to use the created env when running by adding this line: source activate tensorflow35

  4. Run the program within the env using this bash command bash basic/run_single.sh $HOME/data/squad/dev-v1.1.json single.json

abeer-khan avatar Jan 05 '18 13:01 abeer-khan

from tensorflow.contrib.rnn.python.ops import core_rnn_cell linear = core_rnn_cell._linear fix my problem!! windows10 + tensorflow1.6

KevinBetterQ avatar Mar 06 '18 07:03 KevinBetterQ

@abeerunscore96 Thank you! Finally it worked!

spate141 avatar Mar 20 '18 22:03 spate141

@abeerunscore96 Thank you! It works well!

HuiBinR avatar Oct 08 '18 12:10 HuiBinR

Using the solution of @abeerunscore96 are you sure that the code runs on GPU?

valsworthen avatar Nov 15 '18 16:11 valsworthen

No, the code can't run on GPU, even I use CUDA_VISIBLE_DEVICES. But it can run on CPU. @valsworthen

HuiBinR avatar Nov 16 '18 06:11 HuiBinR

Finally I managed to run the code correctly on GPU

  • pip install tensorflow-gpu==1.2 (the version of @abeerunscore96 only installs tensorflow for cpu)
  • make sure you have CUDA 8 and cuDNN 5 (or 5.1) and that you correctly setup the .bashrc
  • use the dev branch of the repo

Run CUDA_VISIBLE_DEVICES=devicenumber python -m basic.cli --mode train --noload --debug

I didn't have the issue with _linear mentioned in this thread.

I think this would also work for the master branch with tensorflow 0.11 / 0.12 provided you install the gpu version.

valsworthen avatar Nov 16 '18 11:11 valsworthen

@valsworthen Please help me! I am new in this area and I try to follow your steps to succeed to run the code, what do you mean by setup the .bashrc'? Waiting to hear from you, I really appreciate your help!

RehamAbobeah avatar Nov 29 '18 12:11 RehamAbobeah

@valsworthen I am not sure if it works well or not. Every time I have the following warning which means sensor flow may be unable to work with GPU.
From search, someone suggests solving this issue by following this link: https://github.com/mind/wheels/releases?after=tf1.3-gpu However, the GPU wheel for TensorFlow 1.2 is only working with python 3.6 and our version here for this project is 3.5, How to solve this issue, please? warning

RehamAbobeah avatar Nov 29 '18 13:11 RehamAbobeah

You can run this branch for the newer version of tensorflow (all errors have been fixed): https://github.com/Vimos/bi-att-flow/tree/tf1.8

shimafoolad avatar Feb 16 '19 21:02 shimafoolad

tensorflow版本改为0.12.1

1910066023 avatar Nov 10 '21 07:11 1910066023