[GH-ISSUE #129] tqdm error in clip.py #115

Closed
opened 2026-10-31 21:11:21 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @qo4on on GitHub (Jul 22, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/129

Hi!
I see a tqdm error when running clip.py in Kaggle kernel. Do you have any idea what should be the problem here?

print(tf.__version__)
print(tf.test.is_gpu_available())
print(torch.cuda.is_available())

device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device) 

1.15.5
True
True

/opt/conda/lib/python3.7/site-packages/clip/clip.py:53: UserWarning: /root/.cache/clip/ViT-B-32.pt exists, but the SHA256 checksum does not match; re-downloading the file
  warnings.warn(f"{download_target} exists, but the SHA256 checksum does not match; re-downloading the file")
TypeError                                 Traceback (most recent call last)
<ipython-input-12-bb23a3fe1b49> in <module>
     18 device = "cuda" if torch.cuda.is_available() else "cpu"
     19
---> 20 model, preprocess = clip.load("ViT-B/32", device=device)

/opt/conda/lib/python3.7/site-packages/clip/clip.py in load(name, device, jit)
    107     """
    108     if name in _MODELS:
--> 109         model_path = _download(_MODELS[name])
    110     elif os.path.isfile(name):
    111         model_path = name

/opt/conda/lib/python3.7/site-packages/clip/clip.py in _download(url, root)
     54
     55     with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:
---> 56         with tqdm(total=int(source.info().get("Content-Length")), ncols=80, unit='iB', unit_scale=True) as loop:
     57             while True:
     58                 buffer = source.read(8192)

/opt/conda/lib/python3.7/site-packages/tqdm/std.py in __init__(self, iterable, desc, total, leave, file, ncols, mininterval, maxinterval, miniters, ascii, disable, unit, unit_scale, dynamic_ncols, smoothing, bar_format, initial, position, postfix, unit_divisor, write_bytes, lock_args, nrows, colour, delay, gui, **kwargs)
    976                 file, encoding=getattr(file, 'encoding', None) or 'utf-8')
    977
--> 978         file = DisableOnWriteError(file, tqdm_instance=self)
    979
    980         if disable is None and hasattr(file, "isatty") and not file.isatty():

/opt/conda/lib/python3.7/site-packages/tqdm/utils.py in __init__(self, wrapped, tqdm_instance)
    152
    153     def __init__(self, wrapped, tqdm_instance):
--> 154         super(DisableOnWriteError, self).__init__(wrapped)
    155         if hasattr(wrapped, 'write'):
    156             self.wrapper_setattr(

TypeError: super(type, obj): obj must be an instance or subtype of type
Originally created by @qo4on on GitHub (Jul 22, 2021). Original GitHub issue: https://github.com/openai/CLIP/issues/129 Hi! I see a `tqdm` error when running `clip.py` in Kaggle kernel. Do you have any idea what should be the problem here? ``` print(tf.__version__) print(tf.test.is_gpu_available()) print(torch.cuda.is_available()) device = "cuda" if torch.cuda.is_available() else "cpu" model, preprocess = clip.load("ViT-B/32", device=device) 1.15.5 True True /opt/conda/lib/python3.7/site-packages/clip/clip.py:53: UserWarning: /root/.cache/clip/ViT-B-32.pt exists, but the SHA256 checksum does not match; re-downloading the file warnings.warn(f"{download_target} exists, but the SHA256 checksum does not match; re-downloading the file") TypeError Traceback (most recent call last) <ipython-input-12-bb23a3fe1b49> in <module> 18 device = "cuda" if torch.cuda.is_available() else "cpu" 19 ---> 20 model, preprocess = clip.load("ViT-B/32", device=device) /opt/conda/lib/python3.7/site-packages/clip/clip.py in load(name, device, jit) 107 """ 108 if name in _MODELS: --> 109 model_path = _download(_MODELS[name]) 110 elif os.path.isfile(name): 111 model_path = name /opt/conda/lib/python3.7/site-packages/clip/clip.py in _download(url, root) 54 55 with urllib.request.urlopen(url) as source, open(download_target, "wb") as output: ---> 56 with tqdm(total=int(source.info().get("Content-Length")), ncols=80, unit='iB', unit_scale=True) as loop: 57 while True: 58 buffer = source.read(8192) /opt/conda/lib/python3.7/site-packages/tqdm/std.py in __init__(self, iterable, desc, total, leave, file, ncols, mininterval, maxinterval, miniters, ascii, disable, unit, unit_scale, dynamic_ncols, smoothing, bar_format, initial, position, postfix, unit_divisor, write_bytes, lock_args, nrows, colour, delay, gui, **kwargs) 976 file, encoding=getattr(file, 'encoding', None) or 'utf-8') 977 --> 978 file = DisableOnWriteError(file, tqdm_instance=self) 979 980 if disable is None and hasattr(file, "isatty") and not file.isatty(): /opt/conda/lib/python3.7/site-packages/tqdm/utils.py in __init__(self, wrapped, tqdm_instance) 152 153 def __init__(self, wrapped, tqdm_instance): --> 154 super(DisableOnWriteError, self).__init__(wrapped) 155 if hasattr(wrapped, 'write'): 156 self.wrapper_setattr( TypeError: super(type, obj): obj must be an instance or subtype of type ```
Author
Owner

@vinson2233 commented on GitHub (Jul 27, 2021):

I see you are using both Tensorflow and Pytorch in your code. Just want to make sure that you import tensorflow first, before importing clip or pytorch. https://github.com/tensorflow/tensorflow/issues/13615
I don't know why your tqdm raise error like that.

<!-- gh-comment-id:887143584 --> @vinson2233 commented on GitHub (Jul 27, 2021): I see you are using both Tensorflow and Pytorch in your code. Just want to make sure that you import tensorflow first, before importing clip or pytorch. https://github.com/tensorflow/tensorflow/issues/13615 I don't know why your tqdm raise error like that.
Author
Owner

@qo4on commented on GitHub (Jul 31, 2021):

I think it was a CUDA issue. Reinstalling CUDA fixed the error.

<!-- gh-comment-id:890329937 --> @qo4on commented on GitHub (Jul 31, 2021): I think it was a CUDA issue. Reinstalling CUDA fixed the error.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#115
No description provided.