pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
Looking in indexes: https://download.pytorch.org/whl/cu118
Collecting torch==2.0.1
Downloading https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-win_amd64.whl (2619.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━━━━━━ 1.9/2.6 GB 1.3 MB/s eta 0:08:55
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in read
data: bytes = self.__fp.read(amt)
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\http\client.py", line 465, in read
s = self.fp.read(amt)
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\socket.py", line 705, in readinto
return self._sock.recv_into(b)
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\bjr\.conda\envs\deeplivecam\lib\ssl.py", line 1130, in read
return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
......
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.
这个错误提示说明在下载 torch 软件包时发生了超时错误,可能是由于网络连接不稳定、下载速度慢或者服务器暂时不可用导致的。要解决这个问题,你可以尝试以下几种方法:
增加下载超时时间: 你可以通过设置 --timeout 参数来增加下载的超时时间,比如设置为 1000 秒:
你可以通过设置 --timeout 参数来增加下载的超时时间,比如设置为 1000 秒:
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118 --timeout 1000
你可以尝试使用国内的 PyPI 镜像源,这些镜像通常能提供更快的下载速度。比如使用清华大学的镜像:
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://pypi.tuna.tsinghua.edu.cn/simple
确保你的网络连接稳定,可以尝试切换到更快的网络,或者关闭 VPN 等可能影响网络连接的工具。
如果一次性安装多个软件包出现问题,可以尝试分别安装每个软件包。例如:
pip install torch==2.0.1 --index-url https://download.pytorch.org/whl/cu118
pip install torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cu118
pip install torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
有时候,网络问题可能是暂时的,稍后重新尝试安装可能就会成功。
如果以上方法都没有解决问题,可以考虑手动下载 .whl 文件,然后使用 pip install .whl 命令进行安装。