Not able to connect to remote cluster with dask_ml.joblib being down
I'm getting an error with dask_ml version 1.2.0 -- module dask_ml.joblib not found. I've tried alternatively connecting per the suggestion here-- https://github.com/dask/dask-ml/issues/591, but instead get a TCP stream is closed error. Is there an underlying bug preventing the remote connection? Can anyone confirm connection using the below code?
'from dask.distributed import Client import joblib
client` = Client(processes=False) # create local cluster client = Client("scheduler-address:8786") # or connect to remote cluster'
with joblib.parallel_backend('dask'): # Your scikit-learn code`
I'm getting an error
Can you post the full traceback?
What version of joblib and distributed do you have?
joblib version is 0.14.1 client distributed version is 2.11.0 scheduler distributed version is 2.10.0
able to successfully instantiate the client, but when I try to run the following code appears the connection keeps getting cut
with joblib.parallel_backend('dask'):
Your scikit-learn code`
distributed.batched - INFO - Batched Comm Closed: in <closed TCP>: BrokenPipeError: [Errno 32] Broken pipe
CancelledError Traceback (most recent call last)
<ipython-input-26-0550e019e9bd> in <module>()
7
8 with joblib.parallel_backend('dask'):
----> 9 clf.fit(X,y)
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/sklearn/ensemble/forest.py in fit(self, X, y, sample_weight)
247
248 # Validate or convert input data
--> 249 X = check_array(X, accept_sparse="csc", dtype=DTYPE)
250 y = check_array(y, accept_sparse='csc', ensure_2d=False, dtype=None)
251 if sample_weight is not None:
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
494 try:
495 warnings.simplefilter('error', ComplexWarning)
--> 496 array = np.asarray(array, dtype=dtype, order=order)
497 except ComplexWarning:
498 raise ValueError("Complex data not supported\n"
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
490
491 """
--> 492 return array(a, dtype, copy=False, order=order)
493
494
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/dataframe/core.py in __array__(self, dtype, **kwargs)
363
364 def __array__(self, dtype=None, **kwargs):
--> 365 self._computed = self.compute()
366 x = np.array(self._computed)
367 return x
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/base.py in compute(self, **kwargs)
163 dask.base.compute
164 """
--> 165 (result,) = compute(self, traverse=False, **kwargs)
166 return result
167
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/base.py in compute(*args, **kwargs)
434 keys = [x.__dask_keys__() for x in collections]
435 postcomputes = [x.__dask_postcompute__() for x in collections]
--> 436 results = schedule(dsk, keys, **kwargs)
437 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
438
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in get(self, dsk, keys, restrictions, loose_restrictions, resources, sync, asynchronous, direct, retries, priority, fifo_timeout, actors, **kwargs)
2593 should_rejoin = False
2594 try:
-> 2595 results = self.gather(packed, asynchronous=asynchronous, direct=direct)
2596 finally:
2597 for f in futures.values():
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in gather(self, futures, errors, direct, asynchronous)
1891 direct=direct,
1892 local_worker=local_worker,
-> 1893 asynchronous=asynchronous,
1894 )
1895
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in sync(self, func, asynchronous, callback_timeout, *args, **kwargs)
778 else:
779 return sync(
--> 780 self.loop, func, *args, callback_timeout=callback_timeout, **kwargs
781 )
782
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py in sync(loop, func, callback_timeout, *args, **kwargs)
346 if error[0]:
347 typ, exc, tb = error[0]
--> 348 raise exc.with_traceback(tb)
349 else:
350 return result[0]
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py in f()
330 if callback_timeout is not None:
331 future = asyncio.wait_for(future, callback_timeout)
--> 332 result[0] = yield future
333 except Exception as exc:
334 error[0] = sys.exc_info()
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/tornado/gen.py in run(self)
733
734 try:
--> 735 value = future.result()
736 except Exception:
737 exc_info = sys.exc_info()
CancelledError:
distributed.client - ERROR - Failed to reconnect to scheduler after 10.00 seconds, closing client
_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
concurrent.futures._base.CancelledError
client distributed version is 2.11.0 scheduler distributed version is 2.10.0
Can you try in an environment where the versions match? Dask doesn't really support different versions for the client and scheduler.
Updated the versions to be the same, I see in the dashboard the progress bar completes before returning the following error in the nb--
---------------------------------------------------------------------------
StreamClosedError Traceback (most recent call last)
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/comm/tcp.py in read(self, deserializers)
187 try:
--> 188 n_frames = await stream.read_bytes(8)
189 n_frames = struct.unpack("Q", n_frames)[0]
StreamClosedError: Stream is closed
During handling of the above exception, another exception occurred:
CommClosedError Traceback (most recent call last)
<ipython-input-26-fdfb90ebcb8f> in <module>()
9
10 with joblib.parallel_backend('dask'):
---> 11 clf.fit(X,y)
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/sklearn/ensemble/forest.py in fit(self, X, y, sample_weight)
248
249 # Validate or convert input data
--> 250 X = check_array(X, accept_sparse="csc", dtype=DTYPE)
251 y = check_array(y, accept_sparse='csc', ensure_2d=False, dtype=None)
252 if sample_weight is not None:
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
525 try:
526 warnings.simplefilter('error', ComplexWarning)
--> 527 array = np.asarray(array, dtype=dtype, order=order)
528 except ComplexWarning:
529 raise ValueError("Complex data not supported\n"
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
83
84 """
---> 85 return array(a, dtype, copy=False, order=order)
86
87
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/dataframe/core.py in __array__(self, dtype, **kwargs)
363
364 def __array__(self, dtype=None, **kwargs):
--> 365 self._computed = self.compute()
366 x = np.array(self._computed)
367 return x
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/base.py in compute(self, **kwargs)
163 dask.base.compute
164 """
--> 165 (result,) = compute(self, traverse=False, **kwargs)
166 return result
167
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/dask/base.py in compute(*args, **kwargs)
434 keys = [x.__dask_keys__() for x in collections]
435 postcomputes = [x.__dask_postcompute__() for x in collections]
--> 436 results = schedule(dsk, keys, **kwargs)
437 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
438
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in get(self, dsk, keys, restrictions, loose_restrictions, resources, sync, asynchronous, direct, retries, priority, fifo_timeout, actors, **kwargs)
2585 should_rejoin = False
2586 try:
-> 2587 results = self.gather(packed, asynchronous=asynchronous, direct=direct)
2588 finally:
2589 for f in futures.values():
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in gather(self, futures, errors, direct, asynchronous)
1883 direct=direct,
1884 local_worker=local_worker,
-> 1885 asynchronous=asynchronous,
1886 )
1887
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in sync(self, func, asynchronous, callback_timeout, *args, **kwargs)
765 else:
766 return sync(
--> 767 self.loop, func, *args, callback_timeout=callback_timeout, **kwargs
768 )
769
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py in sync(loop, func, callback_timeout, *args, **kwargs)
343 if error[0]:
344 typ, exc, tb = error[0]
--> 345 raise exc.with_traceback(tb)
346 else:
347 return result[0]
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py in f()
327 if callback_timeout is not None:
328 future = asyncio.wait_for(future, callback_timeout)
--> 329 result[0] = yield future
330 except Exception as exc:
331 error[0] = sys.exc_info()
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/tornado/gen.py in run(self)
733
734 try:
--> 735 value = future.result()
736 except Exception:
737 exc_info = sys.exc_info()
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in _gather(self, futures, errors, direct, local_worker)
1768 else:
1769 self._gather_future = future
-> 1770 response = await future
1771
1772 if response["status"] == "error":
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py in _gather_remote(self, direct, local_worker)
1820
1821 else: # ask scheduler to gather data for us
-> 1822 response = await retry_operation(self.scheduler.gather, keys=keys)
1823 finally:
1824 self._gather_semaphore.release()
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils_comm.py in retry_operation(coro, operation, *args, **kwargs)
389 delay_min=retry_delay_min,
390 delay_max=retry_delay_max,
--> 391 operation=operation,
392 )
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils_comm.py in retry(coro, count, delay_min, delay_max, jitter_fraction, retry_on_exceptions, operation)
377 delay *= 1 + random.random() * jitter_fraction
378 await asyncio.sleep(delay)
--> 379 return await coro()
380
381
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/core.py in send_recv_from_rpc(**kwargs)
755 name, comm.name = comm.name, "ConnectionPool." + key
756 try:
--> 757 result = await send_recv(comm=comm, op=key, **kwargs)
758 finally:
759 self.pool.reuse(self.addr, comm)
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/core.py in send_recv(comm, reply, serializers, deserializers, **kwargs)
538 await comm.write(msg, serializers=serializers, on_error="raise")
539 if reply:
--> 540 response = await comm.read(deserializers=deserializers)
541 else:
542 response = None
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/comm/tcp.py in read(self, deserializers)
206 self.stream = None
207 if not shutting_down():
--> 208 convert_stream_closed_error(self, e)
209 else:
210 try:
~/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/comm/tcp.py in convert_stream_closed_error(obj, exc)
121 raise CommClosedError("in %s: %s: %s" % (obj, exc.__class__.__name__, exc))
122 else:
--> 123 raise CommClosedError("in %s: %s" % (obj, exc))
124
125
CommClosedError: in <closed TCP>: Stream is closed
distributed.client - ERROR - Failed to reconnect to scheduler after 10.00 seconds, closing client
distributed.utils - ERROR -
Traceback (most recent call last):
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py", line 662, in log_errors
yield
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py", line 1306, in _close
await asyncio.wait_for(asyncio.gather(*coroutines), 2)
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/asyncio/tasks.py", line 351, in wait_for
yield from waiter
concurrent.futures._base.CancelledError
distributed.utils - ERROR -
Traceback (most recent call last):
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/utils.py", line 662, in log_errors
yield
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py", line 1024, in _reconnect
await self._close()
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/site-packages/distributed/client.py", line 1306, in _close
await asyncio.wait_for(asyncio.gather(*coroutines), 2)
File "/Users/kayla.every/opt/anaconda3/envs/daskclusterwork/lib/python3.6/asyncio/tasks.py", line 351, in wait_for
yield from waiter
concurrent.futures._base.CancelledError
_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
concurrent.futures._base.CancelledError
Two questions:
- Do you have a minimal example? http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports. May make things easier to debug
- Is
Xorya Dask array or DataFrame. Typically, the model being fit is expecting NumPy arrays or pandas dataframes. You might want to try passing those (by.compute()ing the values).
FYI, you can put code-blocks in triple backticks to make it format nicely
```
```