无法启动 ray 速成课程笔记本,ray.init 失败,对等方重置连接

问题描述

我正在尝试通过在我的 mac 机器上本地运行光线学院crash course来学习 Ray。我正在使用以下方法设置虚拟环境:

conda env create -f environment.yml
conda activate anyscale-academy
tools/fix-jupyter.sh

但是当我尝试初始化光线会话时:

import ray
ray.init()

并得到错误

---------------------------------------------------------------------------
ConnectionResetError                      Traceback (most recent call last)
~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in read_from_socket(self,timeout,raise_on_timeout)
    426             if HIREdis_USE_BYTE_BUFFER:
--> 427                 bufflen = recv_into(self._sock,self._buffer)
    428                 if bufflen == 0:

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/_compat.py in recv_into(sock,*args,**kwargs)
     74     def recv_into(sock,**kwargs):
---> 75         return sock.recv_into(*args,**kwargs)
     76 

ConnectionResetError: [Errno 54] Connection reset by peer

During handling of the above exception,another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-1-1dcc6cb73a4f> in <module>
      1 import ray
----> 2 ray.init()

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/worker.py in init(address,num_cpus,num_gpus,resources,object_store_memory,local_mode,ignore_reinit_error,include_dashboard,dashboard_host,dashboard_port,job_config,configure_logging,logging_level,logging_format,log_to_driver,_enable_object_reconstruction,_redis_max_memory,_plasma_directory,_node_ip_address,_driver_object_store_memory,_memory,_redis_password,_java_worker_options,_code_search_path,_temp_dir,_load_code_from_local,_lru_evict,_metrics_export_port,_system_config)
    720             shutdown_at_exit=False,721             spawn_reaper=True,--> 722             ray_params=ray_params)
    723     else:
    724         # In this case,we are connecting to an existing cluster.

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/node.py in __init__(self,ray_params,head,shutdown_at_exit,spawn_reaper,connect_only)
    214         # Start processes.
    215         if head:
--> 216             self.start_head_processes()
    217             redis_client = self.create_redis_client()
    218             redis_client.set("session_name",self.session_name)

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/node.py in start_head_processes(self)
    765         assert self._redis_address is None
    766         # If this is the head node,start the relevant head node processes.
--> 767         self.start_redis()
    768 
    769         self.start_gcs_server()

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/node.py in start_redis(self)
    595              redirect_worker_output=True,596              password=self._ray_params.redis_password,--> 597              fate_share=self.kernel_fate_share)
    598         assert (
    599             ray_constants.PROCESS_TYPE_REdis_SERVER not in self.all_processes)

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/_private/services.py in start_redis(node_ip_address,redirect_files,resource_spec,port,redis_shard_ports,num_redis_shards,redis_max_clients,redirect_worker_output,password,fate_share)
    849     primary_redis_client = redis.StrictRedis(
    850         host=node_ip_address,port=port,password=password)
--> 851     primary_redis_client.set("NumRedisShards",str(num_redis_shards))
    852 
    853     # Put the redirect_worker_output bool in the Redis shard so that workers

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/client.py in set(self,name,value,ex,px,nx,xx,keepttl)
   1799             pieces.append('KEEPTTL')
   1800 
-> 1801         return self.execute_command('SET',*pieces)
   1802 
   1803     def __setitem__(self,value):

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/client.py in execute_command(self,**options)
    896         pool = self.connection_pool
    897         command_name = args[0]
--> 898         conn = self.connection or pool.get_connection(command_name,**options)
    899         try:
    900             conn.send_command(*args)

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in get_connection(self,command_name,*keys,**options)
   1190         try:
   1191             # ensure this connection is connected to Redis
-> 1192             connection.connect()
   1193             # connections that the pool provides should be ready to send
   1194             # a command. if not,the connection was either returned to the

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in connect(self)
    565         self._sock = sock
    566         try:
--> 567             self.on_connect()
    568         except RedisError:
    569             # clean up after any error in on_connect

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in on_connect(self)
    641 
    642             try:
--> 643                 auth_response = self.read_response()
    644             except AuthenticationWrongNumberOfArgsError:
    645                 # a username and password were specified but the Redis

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in read_response(self)
    737         "Read the response from a prevIoUsly sent command"
    738         try:
--> 739             response = self._parser.read_response()
    740         except socket.timeout:
    741             self.disconnect()

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in read_response(self)
    468         response = self._reader.gets()
    469         while response is False:
--> 470             self.read_from_socket()
    471             response = self._reader.gets()
    472         # if an older version of hiredis is installed,we need to attempt

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/redis/connection.py in read_from_socket(self,raise_on_timeout)
    451                 return False
    452             raise ConnectionError("Error while reading from socket: %s" %
--> 453                                   (ex.args,))
    454         finally:
    455             if custom_timeout:

ConnectionError: Error while reading from socket: (54,'Connection reset by peer')

我已经在初始化之前在端口 6379 上启动了 redis 服务器,并通过

验证了 redis 连接
import redis
r = redis.Redis()
r.ping()
``` and get back True. Now the only way for me to try out Ray is by running it in Google Colab. I am not sure what had gone wrong,so any suggestion or help is greatly appreciated!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)