facebookresearch/chameleon

running on windows

CoffeeShifter opened this issue · 3 comments

D:\GitHub\chameleon>python -m chameleon.miniviewer
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\GitHub\chameleon\chameleon\miniviewer\__main__.py", line 9, in <module>
    main()
  File "D:\GitHub\chameleon\cham\lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "D:\GitHub\chameleon\cham\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "D:\GitHub\chameleon\cham\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\GitHub\chameleon\cham\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "D:\GitHub\chameleon\chameleon\miniviewer\miniviewer.py", line 241, in main
    cm3v2_inference_model = ChameleonInferenceModel(
  File "D:\GitHub\chameleon\chameleon\inference\chameleon.py", line 544, in __init__
    self.token_manager = TokenManager(
  File "D:\GitHub\chameleon\chameleon\inference\chameleon.py", line 99, in __init__
    self.vocab = VocabInfo(json.load(open(tokenizer_path))["model"]["vocab"])
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3565933: character maps to <undefined>
Exception ignored in: <function ChameleonInferenceModel.__del__ at 0x00000163593575B0>
Traceback (most recent call last):
  File "D:\GitHub\chameleon\chameleon\inference\chameleon.py", line 572, in __del__
    with self.dctx.active_key_lock:
AttributeError: 'ChameleonInferenceModel' object has no attribute 'dctx'

The error UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3565933: character maps to <undefined> suggests that the JSON file being read is not properly being decoded using the default 'cp1252' encoding.

To resolve this issue, you should explicitly set the encoding to 'utf-8' when opening the JSON file in the TokenManager class. Modify the line in the __init__ method from:

self.vocab = VocabInfo(json.load(open(tokenizer_path))["model"]["vocab"])

to:

self.vocab = VocabInfo(json.load(open(tokenizer_path, encoding='utf-8'))["model"]["vocab"])

This specifies that the file should be opened with 'utf-8' encoding, which is more universal for handling various characters and should prevent the UnicodeDecodeError.

Furthermore, to address the error encountered during the cleanup process in the __del__ method (AttributeError: 'ChameleonInferenceModel' object has no attribute 'dctx'), ensure that the attribute dctx is initialized before it's used, or add a check in the __del__ method to verify the existence of dctx:

def __del__(self):
    try:
        if hasattr(self, 'dctx'):
            with self.dctx.active_key_lock:
                self.dctx.active_key.clear()
            self.dctx.req_q.put([None, None, None, True])
            for w in self.workers:
                w.join()
    except FileNotFoundError:
        pass

These changes should resolve the errors you're encountering.

(cham) D:\GitHub\chameleon>python -m chameleon.miniviewer
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
VQModel loaded from data\tokenizer\vqgan.ckpt
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
[W socket.cpp:663] [c10d] The IPv6 network addresses of (0.0.0.0, 55013) cannot be retrieved (gai error: 11004 - The requested name is valid, but no data of the requested type was found. ).
[W socket.cpp:663] [c10d] The IPv6 network addresses of (0.0.0.0, 55013) cannot be retrieved (gai error: 11004 - The requested name is valid, but no data of the requested type was found. ).
[W socket.cpp:663] [c10d] The IPv6 network addresses of (0.0.0.0, 55013) cannot be retrieved (gai error: 11004 - The requested name is valid, but no data of the requested type was found. ).

We're not likely to support Windows, but PR are welcome :)

Closing. Feel free to submit pr for things like the __del__ update.