Run each actor in its own virutal environment

I want each actor to run with their own dependencies.

I am running in a closed environment where doing pip install at runtime is not an option
In the end I plan to run in static ray cluster on kubernetes Deploying a Static Ray Cluster on Kubernetes — Ray v1.8.0
right now I am running my tests on my ubuntu server directly

To do this, I though about using runtime env feature and setting in env_vars the VIRTUAL_ENV variable.

I created a virtual env where I installed ray[Default] and numpy (which my actor uses)
runtime_env = {
“env_vars”: {
“VIRTUAL_ENV”: “path to virtual env”},
}
I did echo $VIRTUAL_ENV in my pycharm terminal to make sure I am copying the correct path

when I call
counter_actor = Counter.options(runtime_env=runtime_env).remote()
I get
(raylet) [2021-12-01 15:26:45,652 E 21303 21303] agent_manager.cc:134: Not all required Ray dependencies for the runtime_env feature were found. To install the required dependencies, please run pip install 'ray[default]'.

I tried passing the runtime_env in ray_init (just to make sure it has nothing to do with the actor) and got the same error with the addition of
(raylet) [2021-12-01 15:53:25,881 E 22621 22621] worker_pool.cc:566: [Eagerly] Couldn’t create a runtime environment for job 01000000.

I am sure ray is installed in my virtual environment as I see the ray folder (with dashboard inside so I know it installed the full installation)

How can I run each actor with its own virtual environment?

Hi, can you see if the error message goes away with the aiohttp downgrade workaround proposed in [Bug] Ray master fails to start dashboard as a result of new aiohttp version (3.8) · Issue #19940 · ray-project/ray · GitHub?

Your approach should then work; the Ray worker will be started with the environment variables that are set.

If you are willing to use conda, another option is to preinstall your desired conda environments on each node, and then pass the name of the environment in the conda field of the runtime environment. (No need to pass any environment variables if using this approach.)

it solved the problem
also had to use PYTHONPATH instead VIRTUAL_ENV