eti-p-doray / unet-gan-matting

Background Removal based on U-Net
MIT License
294 stars 83 forks source link

train.py: module 'tensorflow' has no attribute 'get_variable' #26

Open 174n opened 5 years ago

174n commented 5 years ago

I got this error when running train.py

2019-10-14 23:49:24.635561: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
Traceback (most recent call last):
  File "train.py", line 226, in <module>
    main(args)
  File "train.py", line 72, in main
    train_ids = tf.get_variable('train_ids', initializer=ids[0:split_point], trainable=False)
AttributeError: module 'tensorflow' has no attribute 'get_variable'

I'm running windows 10 and I tried python 3.5 and 3.6 with requirements-gpu.txt installed I think you specified wrong tensorflow version.

I tried replacing strings like that

    # train_ids = tf.get_variable('train_ids', initializer=ids[0:split_point], trainable=False)
    # valid_ids = tf.get_variable('valid_ids', initializer=ids[split_point:len(ids)], trainable=False)
    # global_step = tf.get_variable('global_step', initializer=0, trainable=False)
    train_ids = tf.Variable(tf.ones(ids[0:split_point]), name="train_ids")
    valid_ids = tf.Variable(tf.ones(ids[split_point:len(ids)]), name="valid_ids")
    global_step = tf.Variable(tf.ones(0), name="global_step")

But I got another error

2019-10-14 23:54:15.875251: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
2019-10-14 23:54:17.429887: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2019-10-14 23:54:17.553446: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.8475
pciBusID: 0000:1f:00.0
2019-10-14 23:54:17.560973: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2019-10-14 23:54:17.566947: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
2019-10-14 23:54:17.572106: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-10-14 23:54:17.582708: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.8475
pciBusID: 0000:1f:00.0
2019-10-14 23:54:17.588355: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2019-10-14 23:54:17.593767: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
2019-10-14 23:54:18.321282: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-10-14 23:54:18.326692: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165]      0
2019-10-14 23:54:18.330506: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0:   N
2019-10-14 23:54:18.334713: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4708 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:1f:00.0, compute capability: 6.1)
Traceback (most recent call last):
  File "train.py", line 228, in <module>
    main(args)
  File "train.py", line 75, in main
    train_ids = tf.Variable(tf.ones(ids[0:split_point]), name="train_ids")
  File "C:\Users\ivan\Desktop\unet-gan-matting-master\vendor\python\lib\site-packages\tensorflow_core\python\ops\array_ops.py", line 2583, in ones
    output = fill(shape, constant(one, dtype=dtype), name=name)
  File "C:\Users\ivan\Desktop\unet-gan-matting-master\vendor\python\lib\site-packages\tensorflow_core\python\ops\array_ops.py", line 171, in fill
    result = gen_array_ops.fill(dims, value, name=name)
  File "C:\Users\ivan\Desktop\unet-gan-matting-master\vendor\python\lib\site-packages\tensorflow_core\python\ops\gen_array_ops.py", line 3599, in fill
    _six.raise_from(_core._status_to_exception(e.code, message), None)
  File "<string>", line 2, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: dims must be a vector, got shape [6069,2] [Op:Fill] name: ones/
rajeevnarayanan commented 4 years ago

pip install tensorflow-gpu==1.5 It wont work in tensorflow >= 2.0