ipex-llm
ipex-llm copied to clipboard
Add attribute sys.stdout.fileno when it is missed on Databricks
Description
In Databricks RayDemo mentioned:
# Ray will crash unless sys.stdout is modified.
import sys
sys.stdout.fileno = lambda: 0
This is because in Databricks notebook, sys.stdout is redirect to a ConsoleBuffer
object, this object has no attribute fileno, and cause ray init crash. Normally, sys.stdout should have attribute fileno and is set to 1. So set sys.stdout.fileno to 1 when this attribute is missed, this should fix the bug when run BigDL ray backend on Databricks, and should not affect non-Databricks env.
This is verified on Databricks.