在ubuntu上运行tensorflow gpu时SSL证书错误

时间:2018-10-07 15:56:07

标签: python ssl tensorflow ubuntu-18.04

Tensorflow:1.11.0 Ubuntu的:18.04 的Python:3.6.6

我使用pyenv用python 3.6.6创建了一个环境,并将tensorflow gpu安装到其中。

已验证的tensorflow GPU装有:

python -c "import tensorflow as tf; print(tf.__version__)"

它返回:1.11.0

然后我尝试运行以下示例代码:https://www.tensorflow.org/tutorials/

我遇到以下错误:

ython 3.6.6 (default, Oct  6 2018, 00:35:42) 
[GCC 6.4.0 20180424] on linux
Type "copyright", "credits" or "license()" for more information.
>>> 
=============== RESTART: /home/chubuntu/tf366/tf-tutorial-1.py ===============
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
Traceback (most recent call last):
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/http/client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/site-packages/tensorflow/python/keras/utils/data_utils.py", line 243, in get_file
    urlretrieve(origin, fpath, dl_progress)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chubuntu/tf366/tf-tutorial-1.py", line 4, in <module>
    (x_train, y_train),(x_test, y_test) = mnist.load_data()
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/site-packages/tensorflow/python/keras/datasets/mnist.py", line 49, in load_data
    file_hash='8a61469f7ea1b51cbae51d4f78837e45')
  File "/home/chubuntu/.pyenv/versions/3.6.6/lib/python3.6/site-packages/tensorflow/python/keras/utils/data_utils.py", line 245, in get_file
    raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)
>>> 

帮助!

0 个答案:

没有答案