ray-project / ray

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
32.04k stars 5.46k forks source link

Building an executable using Ray and Cx_freeze #42101

Open MahdiALLALA opened 6 months ago

MahdiALLALA commented 6 months ago

What happened + What you expected to happen

I'm trying to build a flask app that uses modin with ray. When I run the flask app in dev mode using the python interpreter everything works fine. When I build my flask app using cx_freeze the executable that I'm getting is not behaving as expected in both Windows 11 and Ubuntu 22.04.

What happend: When I launch the executable, my computer freezes and sometime I get the following error message: -- Failed to start the dashboard -- Error should be written to 'dashboard.log' or 'dashboard.err'. We are printing the last 20 lines for you. See 'https://docs.ray.io/en/master/ray-observability/ray-logging.html#logging-directory-structure' to find where the log file is. -- Couldn't read dashboard.log file. Error: [Errno 2] No such file or directory: 'C:\\Users\\r7318\\AppData\\Local\\Temp\\ray\\session_2023-08-14_22-26-14_649513_28428\\logs\\dashboard.log'. It means the dashboard is broken even before it initializes the logger (mostly dependency issues). Reading the dashboard.err file which contains stdout/stderr. -- Failed to read dashboard.err file: cannot mmap an empty file. It is unexpected. Please report an issue to Ray github. https://github.com/ray-project/ray/issues What is expected to happen: the generated executable should run normally

Versions / Dependencies

I'm using Python 3.11.1 64 bits

I'm running this code in 2 machines:

the requirements.txt file contains this: cx-Freeze==6.15.12 Flask==3.0.0 modin[ray]==0.26.0

this requirements.txt will install Ray 2.9.0

Reproduction script

In order to replicate this issue please clone this repo.

This is the successful scenario using the dev mode:

  1. create a virtual environment
  2. install the dependencies using the requirements.txt file
  3. run the app in dev mode using this command: "python app.py"
  4. open your browser and navigate to http://localhost:5050/ you should be able to see "data reading was successful" in the browser and you can see the dataframe printed in the console.

This is the failed scenario using Cx_freeze:

  1. create a virtual environment
  2. install the dependencies using the requirements.txt file
  3. build the executable using this command: "python setup.py build"
  4. run the executable named "data_reader" located under "/build/exe.../data_reader" after running the executable my computer crashes due to memory problems

Issue Severity

High: It blocks me from completing my task.

rayen-mhamdi commented 6 months ago

hello @MahdiALLALA

I'm facing the same problem. i want to build an exe in windows using Ray. but my pc keeps crushing.

i think the problem due to this line of code in this file

loop.run_until_complete(dashboard.run())

it keeps looping forever.

I also tried using include_dashboardargument with both True and False values. same problem. I also tried to change the _temp_dir argument of ray.init(). same problem

No solution yet

rayen-mhamdi commented 6 months ago

@sven1977 do you have any idea ?

jjyao commented 4 months ago

@MahdiALLALA thanks for reporting this. Given it's working with normal Python interpreter and we don't officially support Cx_freeze, I'll make it as P2 for now.