安装TensorFlow

一个项目跑在TensorFlow2.4.0上,安装TensorFlow对代码进行测试。
注意:要进入虚拟路径里面安装。

(pytorch_cpu) D:\anaconda3\envs\pytorch_cpu\Scripts>pip --default-timeout=10000 install tensorflow-cpu==2.4.0

用命令安装报错了,原因是清华的镜像中已经没有2.4.0这个版本了。最低的版本是2.5.0,想着TensorFlow2应该是兼容的,于是决定安装处于中间位置的2.9.0版本。
安装TensorFlow_第1张图片

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。')': /simple/tensorflow-cpu/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/tensorflow-cpu/
ERROR: Could not find a version that satisfies the requirement tensorflow-cpu==2.4.0 (from versions: 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.11.1, 2.12.0rc0, 2.12.0rc1, 2.12.0, 2.12.1, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0)
ERROR: No matching distribution found for tensorflow-cpu==2.4.0

安装TensorFlow_第2张图片
镜像的速度还比较快。

安装之后,已经包含了Keras等,具体安装的包如下:

Installing collected packages: tensorboard-plugin-wit, libclang, keras, flatbuffers, wrapt, werkzeug, termcolor, tensorflow-io-gcs-filesystem, tensorflow-estimator, tensorboard-data-server, pyasn1, protobuf, opt-einsum, oauthlib, keras-preprocessing, importlib-metadata, h5py, grpcio, google-pasta, gast, cachetools, astunparse, absl-py, rsa, requests-oauthlib, pyasn1-modules, markdown, google-auth, google-auth-oauthlib, tensorboard, tensorflow-cpu
Successfully installed absl-py-1.4.0 astunparse-1.6.3 cachetools-5.3.1 flatbuffers-1.12 gast-0.4.0 google-auth-2.21.0 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.56.0 h5py-3.9.0 importlib-metadata-6.8.0 keras-2.9.0 keras-preprocessing-1.1.2 libclang-16.0.0 markdown-3.4.3 oauthlib-3.2.2 opt-einsum-3.3.0 protobuf-3.19.6 pyasn1-0.5.0 pyasn1-modules-0.3.0 requests-oauthlib-1.3.1 rsa-4.9 tensorboard-2.9.1 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-cpu-2.9.0 tensorflow-estimator-2.9.0 tensorflow-io-gcs-filesystem-0.31.0 termcolor-2.3.0 werkzeug-2.3.6 wrapt-1.15.0

源码还有Word2Vector的包gensim显示没有安装,看源码的requirments文件,gensim版本为4.1.2,继续安装:

(pytorch_cpu) D:\anaconda3\envs\pytorch_cpu\Scripts>pip --default-timeout=10000 install gensim==4.1.2

安装成功。
安装TensorFlow_第3张图片

你可能感兴趣的:(tensorflow2.x)