I am simply following the tutorials of tensorflow and while performing following cmd :
python ptb_word_lm.py --data_path=/home/priyankit/data/validsrc2-hi --
model=small
It is showing following error:
Traceback (most recent call last):
File "ptb_word_lm.py", line 68, in
import util
File "/home/priyankit/models-master/tutorials/rnn/ptb/util.py", line
23, in
from tensorflow.core.protobuf import rewriter_config_pb2
ImportError: cannot import name rewriter_config_pb2
link to the repository
You need to do two things. First, upgrade tensorflow by doing:
pip install --upgrade tensorflow
Second, if you are not using a GPU, then execute the script with 0 GPUs as follows:
python ptb_word_lm.py --data_path=/home/priyankit/data/validsrc2-hi --model=small --num_gpus=0
I had exactly the same error loop when I tried doing the RNN Tensorflow tutorial on their website.
What worked for me (I don't have a GPU) was including this at the end "--num_gpus=0" when running my program on the terminal.
Related
I am trying to run the following:
from keras.backend import theano_backend
But I get this error:
Traceback (most recent call last):
File "<ipython-input-64-39e623866e51>", line 1, in <module>
from keras.backend import theano_backend
ImportError: cannot import name 'theano_backend' from 'keras.backend' (C:\Users\Dr. Sunil Singla\anaconda3\lib\site-packages\keras\backend.py)
I cloned this repo: https://github.com/titu1994/DenseNet.git and attempted to run it on my image data.
The latest Keras versions are just a wrapper on top of tf.keras, they are not the multi-backend keras you are expecting.
For this code to work, you should downgrade Keras to a version that is still multi-backend, like 2.2.x versions. I think 2.3.x still have multiple backends too, but versions 2.4 are TensorFlow only.
I'm trying to use a very cool machine learning Colab. https://colab.research.google.com/drive/1eQLZrNYRZMo9zdnGGccE0hFswGiinO-Z?usp=sharing Running their steps as is, I keep getting ERROR: Failed building wheel for pytorch3d.
After much Googling, I've tried for instance replacing the install line with
!pip install 'git+https://github.com/facebookresearch/pytorch3d.git#stable'
and also
!pip install pytorch3d
The former doesn't work. The latter makes another issue arise:
"ImportError: /usr/local/lib/python3.6/dist-packages/pytorch3d/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor7is_cudaEv"
I also tried doing !pip install torch==1.6.0 which causes
Traceback (most recent call last):
File "./meshrcnn/demo/demo.py", line 11, in <module>
from detectron2.data import MetadataCatalog
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/__init__.py", line 4, in <module>
from .build import (
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/build.py", line 14, in <module>
from detectron2.structures import BoxMode
File "/usr/local/lib/python3.6/dist-packages/detectron2/structures/__init__.py", line 6, in <module>
from .keypoints import Keypoints, heatmaps_to_keypoints
File "/usr/local/lib/python3.6/dist-packages/detectron2/structures/keypoints.py", line 6, in <module>
from detectron2.layers import interpolate
File "/usr/local/lib/python3.6/dist-packages/detectron2/layers/__init__.py", line 3, in <module>
from .deform_conv import DeformConv, ModulatedDeformConv
File "/usr/local/lib/python3.6/dist-packages/detectron2/layers/deform_conv.py", line 10, in <module>
from detectron2 import _C
ImportError: /usr/local/lib/python3.6/dist-packages/detectron2/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceISt7complexIdEEEPKNS_6detail12TypeMetaDataEv
Have done !pip install mmcv-full===1.2.1 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7.0/index.html to try fixing that and the error persists.
Does anyone have ideas for how to make the Colab environment work?
I got the same error and found your post. I tried to install current master (with:
!pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
and after downloading and compiling pytorch3D==0.4.0 it actually worked correctly.
I think that what solved the problem was downloading and compiling pytorch3d, so that it got properly linked with cuda: if it downloads a precompiled wheel you'll probably get that undefined symbol error.
Only other change I made: I had to remove a demo=True from the call to group_keypoints() in the bounding rectangle calculation cell (it said that parameter was unknown)
I found the same problem for Google Colab. Then I solved it from
https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md
In this area, you can see the required solution for your current machine. If you face a problem with Google Colab you can try this code.
In general, from inside IPython, or in Google Colab or a Jupyter notebook, you can install with
import sys
import torch
pyt_version_str=torch.__version__.split("+")[0].replace(".", "")
version_str="".join([
f"py3{sys.version_info.minor}_cu",
torch.version.cuda.replace(".",""),
f"_pyt{pyt_version_str}"
])
!pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html
You have to restart your runtime environment after installing this. In my case, it worked perfectly in Google Colab with GPU instance.
I am trying to use gpt-2 for text generation. I get compatibility errors, even after running the Tensorflow 2.0 code upgrade script.
Steps I've followed:
Clone repo
From here on out, follow the directions in DEVELOPERS.md
Run upgrade script on files in /src
In terminal run: sudo docker build --tag gpt-2 -f Dockerfile.gpu .
After building is done, run: sudo docker run --runtime=nvidia -it gpt-2 bash
Enter python3 src/generate_unconditional_samples.py | tee /tmp/samples
Get this traceback:
Traceback (most recent call last):
File "src/generate_unconditional_samples.py", line 9, in <module>
import model, sample, encoder
File "/gpt-2/src/model.py", line 4, in <module>
from tensorboard.plugins.hparams.api import HParam
ImportError: No module named 'tensorboard.plugins.hparams'
root#f8bdde043f91:/gpt-2# python3 src/generate_unconditional_samples.py | tee
/tmp/samples
Traceback (most recent call last):
File "src/generate_unconditional_samples.py", line 9, in <module>
import model, sample, encoder
File "/gpt-2/src/model.py", line 4, in <module>
from tensorboard.plugins.hparams.api import HParam
ImportError: No module named 'tensorboard.plugins.hparams'```
It appears that HParams has been deprecated and the new version in Tensorflow 2.0 is called HParam. However, the parameters are different. In model.py, the params are instantiated as follows:
def default_hparams():
return HParams(
n_vocab=0,
n_ctx=1024,
n_embd=768,
n_head=12,
n_layer=12,
)
There doesn't appear to be any 1:1 translation into Tensorflow 2.0. Does anyone know how to make gpt-2 work with Tensorflow 2.0?
My GPU is an NVIDIA 20xx.
Thank you.
If you want to take a look at my 1.x fork it's here, compiling:
https://github.com/timschott/gpt-2
I had the same issue but got it resolved by creating a separate hparams.py file in the folder and populating it with the content from here: https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/utils/hparam.py
then in your model.py you can add the following code and swap out this:
import tensorflow as tf
from tensorflow.contrib.training import HParams
with this:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from hparams import HParams
Then you will have to add "compat.v1" inbetween "tf" and the module (if that's what it's called)... For instance if it is "tf.Session" change it to "tf.compat.v1.Session" or if it is "tf.placeholder" change it to "tf.compat.v1.placeholder", etc.
I did this after trying to downgrade to tensorflow-gpu 1.13 and gpt-2 still wasn't working. Same was the case with running the environment in 3.6 version of Python.
P.S. This is my first answer, not sure if I formatted it correctly, but will learn as I go as well.
Automatically upgrading code rarely works out of the box. With that repo, you should use Tensorflow=1.15 maximum.
If you really want Tensorflow=2, you can look at this repo: https://github.com/akanyaani/gpt-2-tensorflow2.0
Note: that you won't get the pre-trained models (probably the most interesting part of gpt2 for the average user). Meaning no access to their 1554M or 778M models.
I know of no method to automatically upgrade pre-trained models from 1.15 to 2.3 or whatnot.
I was on a robot class so i need both opencv and tensorflow, so i dowloaded both of them on window 10 64-bit. this is my code:
import cv2
import numpy as np
import tensorflow
#code here
which return this trace back:
Traceback (most recent call last):
File "C:/Users/Dell/PycharmProjects/SignClassifer/.idea/source_code.py", line 3, in <module>
import tensorflow
File "C:\Users\Dell\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
ImportError: No module named 'tensorflow.python'
Process finished with exit code 1
i was following those steps for downloading tensorflow with GPU for python on window. The "native" pip way: running this command:
C:\> pip3 install --upgrade tensorflow-gpu
It downloaded and installed fine. But when i try to import tensorflow this error happened, in an attempt to fix this error i also downloaded a tensorflow GPU packet with pycharm, doesnt seem to be any better, i ve looking all over the internet, doesnt seem to find anything.
I keep getting the following error, when using tensorflow in PyCharm:
/home/user/tensorflow/bin/python /home/user/PycharmProjects /TensorPlay/hello.py
Traceback (most recent call last):
File "/home/user/PycharmProjects/TensorPlay/hello.py", line 2, in <module>
import tensorflow as tf
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 27, in <module>
import ctypes
File "/usr/lib/python3.5/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /home/user/tensorflow/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_AsWideCharString
Process finished with exit code 1
hello.py is this simple example code:
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
PyCharm detects all the Tensorflow elements and autocomplete everything i want to.
I also tried to run the virtualenv in the console.
Any Python related leads to the same error. I tried to upgrade tensorflow with
source ~/tensorflow/bin/activate
pip3 install --upgrade tensorflow
and had the exact same error too (Just instead of hello.py there was an error in file pip3)
Any suggestions?
EDIT:
I guess I see the problem. Might it be that my virtualenv wants Python 3.5.3? I thing with the last upgrade my Linux upgraded to Python 3.5.4 How can I fix it without creating a new virtualenv? And how I can make sure it doesn't happen on future updates?
I could only fix the issue with deleting the old virtualenv and setting up a new one.