yael-vinker / CLIPasso

Other
850 stars 91 forks source link

Demo on Windows - RuntimeError with freeze_support #8

Closed MaximeHoude closed 2 years ago

MaximeHoude commented 2 years ago

Hi,

I created an environment following the Readme and I this following error on Windows 10, with GPU:

raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

   This probably means that you are not using fork to start your
  child processes and you have forgotten to use the proper idiom
   in the main module:

      if __name__ == '__main__':
           freeze_support()
           ...

   The "freeze_support()" line can be omitted if the program
   is not going to be frozen to produce an executable.

Thanks in advance!

yael-vinker commented 2 years ago

Hello, can you please provide more information? At which stage this error has occurred? Did you manage to install all the requirements?

MaximeHoude commented 2 years ago

Hello, can you please provide more information? At which stage this error has occurred? Did you manage to install all the requirements?

Sure, sorry for the lack of info. I created the entire environment with all the requirements. This happens when I start sketching the camel with default parameters, using GPU (Cuda + Nvidia 2070ti).

Here's the full error:

==================================================
Processing [camel.png] ...
Results will be saved to
[C:\code\CLIPasso/output_sketches/camel/] ...
==================================================
GPU: True
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Python37\lib\multiprocessing\spawn.py", line 114, in _main
    prepare(preparation_data)
  File "C:\Python37\lib\multiprocessing\spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python37\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "C:\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\code\CLIPasso\run_object_sketching.py", line 73, in <module>
    manager = mp.Manager()
  File "C:\Python37\lib\multiprocessing\context.py", line 56, in Manager
    m.start()
  File "C:\Python37\lib\multiprocessing\managers.py", line 563, in start
    self._process.start()
  File "C:\Python37\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:\Python37\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Python37\lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Python37\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "C:\Python37\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
yael-vinker commented 2 years ago

thanks (: Can you please try to comment lines 72-73 in run_object_sketching.py:

manager = mp.Manager() losses_all = manager.dict()

and add instead: losses_all = {}

MaximeHoude commented 2 years ago

Sorry for the delay, I tried so many options! I still get this error:

[C:\code\ClipMax2\CLIPasso/output_sketches/camel/] ...
==================================================
GPU: True
Traceback (most recent call last):
  File "painterly_rendering.py", line 18, in <module>
    import wandb
ModuleNotFoundError: No module named 'wandb'

Even if I Pip installed wandb. I thing the root of the problem comes from diffvg, which is unsteady on W10 (I tried with Py3.6, Py3.7 and Py3.8). I tried installing diffvg with your method and following their Readme, but still unstable. My last solution is to try with Poetry.

Also, I tried running your project on Docker, but enabling GPU is unavailable one Windows (even with Ubuntu WSL2). This is quiet a challenge, haha!

yael-vinker commented 2 years ago

Hi :) You can try to comment the "import wandb" line, let me know if it worked. Indeed, it is challenging to run the project on Windows (haven't tried:) due to diffvg compilation. If you manage to make it work please update here to help others :)

Thanks! Yael