Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionRefusedError #2

Open
hhabra opened this issue Aug 3, 2021 · 3 comments
Open

ConnectionRefusedError #2

hhabra opened this issue Aug 3, 2021 · 3 comments

Comments

@hhabra
Copy link

hhabra commented Aug 3, 2021

Hi there,
I've been trying out the NormAE program for some data that I would like corrected for batch effects. Unfortunately I'm getting a "ConnectionRefusedError" among other messages by the console when I try to run the program. If I understand correctly, this may involve running a program on a remote server that my computer cannot connect to. I suspect this may potentially be a Mac-related issue (I use a 2020 Macbook pro), but I'm wondering if you have any ideas for a workaround.

Here's the command I tried and the output from the console:

**python main.py --task train --meta_data EX616_metabolomics_input.csv --sample_data EX616_batchdata_input.csv --save __pycache__**

the settings of training:
task:  train
meta_data:  EX616_metabolomics_input.csv
sample_data:  EX616_batchdata_input.csv
train_data:  all
save:  __pycache__
ae_encoder_units:  [1000, 1000]
ae_decoder_units:  [1000, 1000]
disc_b_units:  [250, 250]
disc_o_units:  [250, 250]
bottle_num:  500
dropouts:  (0.3, 0.1, 0.3, 0.3)
lambda_b:  1.0
lambda_o:  1.0
lr_rec:  0.0002
lr_disc_b:  0.005
lr_disc_o:  0.0005
epoch:  (1000, 10, 700)
use_batch_for_order:  True
batch_size:  64
load:  None
visdom_env:  main
visdom_port:  8097
num_workers:  12
use_log:  False
use_batch:  None
sample_size:  None
random_seed:  1234
device:  None

Setting up a new session...
Exception in user code:
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/Users/hani/anaconda3/lib/python3.8/http/client.py", line 1240, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/hani/anaconda3/lib/python3.8/http/client.py", line 1286, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/hani/anaconda3/lib/python3.8/http/client.py", line 1235, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/hani/anaconda3/lib/python3.8/http/client.py", line 1006, in _send_output
    self.send(msg)
  File "/Users/hani/anaconda3/lib/python3.8/http/client.py", line 946, in send
    self.connect()
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa9235b1e80>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
    retries = retries.increment(
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa9235b1e80>: Failed to establish a new connection: [Errno 61] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/visdom/__init__.py", line 708, in _send
    return self._handle_post(
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/visdom/__init__.py", line 677, in _handle_post
    r = self.session.post(url, data=data)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa9235b1e80>: Failed to establish a new connection: [Errno 61] Connection refused'))
[Errno 61] Connection refused
Batch:   0%|                                                                                                                                     | 0/4 [00:14<?, ?it/s]
Traceback (most recent call last):                                                                                                               | 0/4 [00:00<?, ?it/s]
  File "main.py", line 83, in <module>
    main()
  File "main.py", line 49, in main
    best_models, hist, early_stop_objs = trainer.fit(datas)
  File "/Users/hani/Documents/NormAE-release/train.py", line 103, in fit
    for batch_x, batch_y in tqdm(dataloaders['train'], 'Batch: '):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/tqdm/std.py", line 1129, in __iter__
    for obj in iterable:
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data
    return self._process_data(data)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
    data.reraise()
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/_utils.py", line 428, in reraise
    raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
    data = fetcher.fetch(index)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
    return self.collate_fn(data)
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 83, in default_collate
    return [default_collate(samples) for samples in transposed]
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 83, in <listcomp>
    return [default_collate(samples) for samples in transposed]
  File "/Users/hani/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 61, in default_collate
    raise TypeError(default_collate_err_msg_format.format(elem.dtype))
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found object

rec_pretrain:   0%|
@edwardkuo09
Copy link

hi, I have a same problem,too.

Here's the command I tried and the output from the console:

task:  train
meta_data:  C:\Users\edwardkuo\Downloads\NormAE-release/path/to/meta.csv
sample_data:  C:\Users\edwardkuo\Downloads\NormAE-release/path/to/sample.information.csv
train_data:  all
save:  C:\Users\edwardkuo\Downloads\NormAE-release\path\to\save_dir
ae_encoder_units:  [1000, 1000]
ae_decoder_units:  [1000, 1000]
disc_b_units:  [250, 250]
disc_o_units:  [250, 250]
bottle_num:  500
dropouts:  (0.3, 0.1, 0.3, 0.3)
lambda_b:  1.0
lambda_o:  1.0
lr_rec:  0.0002
lr_disc_b:  0.005
lr_disc_o:  0.0005
epoch:  (1000, 10, 700)
use_batch_for_order:  True
batch_size:  64
load:  None
visdom_env:  main
visdom_port:  8097
num_workers:  12
use_log:  False
use_batch:  None
sample_size:  None
random_seed:  1234
device:  None

Setting up a new session...
Exception in user code:
------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connection.py", line 170, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
    raise err
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 無法連線,因為目標電腦拒絕連線。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\PycharmProjects\pythonProject\.idea\inspectionProfiles\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\PycharmProjects\pythonProject\.idea\inspectionProfiles\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\PycharmProjects\pythonProject\.idea\inspectionProfiles\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\PycharmProjects\pythonProject\.idea\inspectionProfiles\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "C:\Users\edwardkuo\Downloads\NormAE-release\PycharmProjects\pythonProject\.idea\inspectionProfiles\lib\http\client.py", line 964, in send
    self.connect()
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connection.py", line 200, in connect
    conn = self._new_conn()
  File "C:\Users\edwardkuo\Downloads\NormAE-release\venv\lib\site-packages\urllib3\connection.py", line 182, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001F478586E48>: Failed to establish a new connection: [WinError 10061] 無法連線,因為目標電腦拒絕
連線。

@luyiyun
Copy link
Owner

luyiyun commented Aug 5, 2021 via email

@JohanLassen
Copy link

JohanLassen commented Dec 14, 2021

Hi,
I have the same problem(s) as @hhabra.

The first part of the problem I solved by installing visdom correctly - just follow this link. One must run python -m visdom.server in the activated conda environment to open the server.

The second part I still haven't solved, but it seems that dataloaders["train"] returns objects instead of batch x and batch y in the training loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants