lightonai / lightonml

Python library for running large-scale computations on LightOn's OPUs
https://docs.lighton.ai
Other
35 stars 11 forks source link

opu.json missing? #3

Closed remiwastaken closed 3 years ago

remiwastaken commented 3 years ago

Hi,

When trying the example https://docs.lighton.ai/examples/randomized_svd.html (about dimensionality reduction), the "OPUMap" outputs the following error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-46-e9e261d0e6c1> in <module>
      1 k = 100
      2 start = time()
----> 3 ratings_proj = randomize(ratings, k)
      4 rp_time = time() - start

<ipython-input-45-237d9a863aa4> in randomize(x, k, thresh)
      6 
      7 def randomize(x, k, thresh=0):
----> 8     mapping = OPUMap(n_components=k)
      9     x = (x > thresh).astype('uint8')
     10     y = mapping.transform(x)

~/.local/lib/python3.8/site-packages/lightonml/projections/sklearn.py in __init__(self, n_components, opu, ndims, n_2d_features, packed, simulated, max_n_features, verbose_level)
     85                                n_components=n_components)
     86             else:
---> 87                 self.opu = OPU(n_components=n_components)
     88         else:
     89             self.opu = opu

~/.local/lib/python3.8/site-packages/lightonml/opu.py in __init__(self, n_components, opu_device, max_n_features, config_file, config_override, verbose_level, input_roi_strategy, open_at_init, disable_pbar)
    111         # Device init, or take the one passed as input
    112         if not opu_device:
--> 113             opu_type = self.config["type"]
    114             self._base_frametime_us = self.config["input"]["frametime_us"]
    115             self._base_exposure_us = self.config["output"]["exposure_us"]

~/.local/lib/python3.8/site-packages/lightonml/opu.py in config(self)
    493         # Load it when asked first time
    494         if not self.__opu_config:
--> 495             self.__opu_config = config.load_config(self.__config_file, self._trace)
    496             if self.__config_override is not None:
    497                 utils.recurse_update(self.__opu_config, self.__config_override)

~/.local/lib/python3.8/site-packages/lightonml/internal/config.py in load_config(override_location, trace_fn)
     45         host = json.loads(host_path.read_text())
     46         config_location = host["opu_config"]
---> 47     return get_config_from(config_location, trace_fn)
     48 
     49 

~/.local/lib/python3.8/site-packages/lightonml/internal/config.py in get_config_from(config_location, trace_fn)
     24         return json.loads(content)
     25     elif config_location.startswith("/"):
---> 26         return json.loads(Path(config_location).read_text())
     27     else:
     28         raise ValueError("Unknown protocol for config_location")

/opt/anaconda3/lib/python3.8/pathlib.py in read_text(self, encoding, errors)
   1230         Open the file in text mode, read it, and close the file.
   1231         """
-> 1232         with self.open(mode='r', encoding=encoding, errors=errors) as f:
   1233             return f.read()
   1234 

/opt/anaconda3/lib/python3.8/pathlib.py in open(self, mode, buffering, encoding, errors, newline)
   1216         if self._closed:
   1217             self._raise_closed()
-> 1218         return io.open(self, mode, buffering, encoding, errors, newline,
   1219                        opener=self._opener)
   1220 

/opt/anaconda3/lib/python3.8/pathlib.py in _opener(self, name, flags, mode)
   1072     def _opener(self, name, flags, mode=0o666):
   1073         # A stub for the opener argument to built-in open()
-> 1074         return self._accessor.open(self, flags, mode)
   1075 
   1076     def _raw_open(self, flags, mode=0o777):

FileNotFoundError: [Errno 2] No such file or directory: '/etc/lighton/opu.json'

I can't seem to find any information about this mysterious file on the documentation.

Thanks for your help!

CharlesB2 commented 3 years ago

Hi!

By default, lightonml's OPUMap is looking for a real OPU, but if you don't have it you need to add simulated=True to init arguments in order to simulate the OPU operation on CPU. This is documented here https://docs.lighton.ai/notes/get_started.html#Simulating-an-OPU Sorry for the inconvenience, we'll add a better message on this error. Also, if you want to test a real OPU, feel free to apply for access on our cloud: https://cloud.lighton.ai/

CharlesB2 commented 3 years ago

In version 1.4, a more informative error message is printed in this case, so we can close the issue