Code Monkey home page Code Monkey logo

Comments (6)

zanieb avatar zanieb commented on May 30, 2024 1

Regarding

AttributeError: 'RemoteFunction' object has no attribute '__qualname__'

The task decorator could be updated to not require that. I'm not sure it'll get us far this this case though.

from prefect-ray.

ahuang11 avatar ahuang11 commented on May 30, 2024

Perhaps this link can help:
https://docs.ray.io/en/latest/ray-core/tasks/using-ray-with-gpus.html

Something like:

@task
@ray.remote(num_gpus=1)   # or maybe reverse the decorators
def use_gpu():
    print("ray.get_gpu_ids(): {}".format(ray.get_gpu_ids()))
    print("CUDA_VISIBLE_DEVICES: {}".format(os.environ["CUDA_VISIBLE_DEVICES"]))

Let me know if that works!

from prefect-ray.

christianvogellive avatar christianvogellive commented on May 30, 2024

Thanks a lot for your response.
We tried mixing the ray and prefect decorators like you also suggested, but we did not have any success yet.
Therefore we are a bit uncertain how to realize the resource requirements.

Depending on the order of the two decorators the following errors are received:

Traceback (most recent call last):
  File "/home/christian/Documents/temp/prefect-example/ray-anyscale-stress-test/time-wait-flow.py", line 18, in <module>
    def wait_time(time_in_secs):
  File "/home/christian/Documents/temp/prefect-example/venv/lib/python3.9/site-packages/prefect/tasks.py", line 778, in task
    Task(
  File "/home/christian/Documents/temp/prefect-example/venv/lib/python3.9/site-packages/prefect/context.py", line 163, in __register_init__
    __init__(__self__, *args, **kwargs)
  File "/home/christian/Documents/temp/prefect-example/venv/lib/python3.9/site-packages/prefect/tasks.py", line 136, in __init__
    self.name = name or self.fn.__name__
AttributeError: 'RemoteFunction' object has no attribute '__name__'
Traceback (most recent call last):
  File "/home/christian/Documents/temp/prefect-example/ray-anyscale-stress-test/time-wait-flow.py", line 18, in <module>
    def wait_time(time_in_secs):
  File "/home/christian/Documents/temp/prefect-example/venv/lib/python3.9/site-packages/ray/_private/worker.py", line 2603, in _make_remote
    raise TypeError(
TypeError: The @ray.remote decorator must be applied to either a function or a class.


from prefect-ray.

ahuang11 avatar ahuang11 commented on May 30, 2024

Can you pass in a name to the task to test? @task(name="task_name")

from prefect-ray.

ahuang11 avatar ahuang11 commented on May 30, 2024

Okay that didn't seem to work either:

import ray
from prefect import task

@task(name="abc")
@ray.remote(num_gpus=1)   # or maybe reverse the decorators
def use_gpu():
    print("ray.get_gpu_ids(): {}".format(ray.get_gpu_ids()))
    print("CUDA_VISIBLE_DEVICES: {}".format(os.environ["CUDA_VISIBLE_DEVICES"]))

AttributeError: 'RemoteFunction' object has no attribute '__qualname__'

from prefect-ray.

zanieb avatar zanieb commented on May 30, 2024

With Dask, we expect users to use Dask's config context manager. We could do something similar here...

@flow
def foo():
   with ray_remote_settings(num_gpus=1):
       my_task()
       my_other_task()

I believe we'd need to implement this ourselves. It'd be pretty easy though. We'd then pass the remote settings to the remote invocation in the task runner?

from prefect-ray.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.