1、安装

Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。 [1] 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB),如果只需要某些包,或者需要节省带宽或存储空间,也可以使用Miniconda这个较小的发行版(仅包含conda和 Python)。

https://www.jianshu.com/p/62f155eb6ac5

conda结合了pip和virtualenv的功能。

======================================================

2、参考文章

https://blog.csdn.net/cliukai/article/details/102051891

======================================================

3、创建环境

conda create -n TF_2C python=3.8

conda activate TF_2C

(TF_2C) C:\WINDOWS\system32>

conda activate TF_2C

======================================================

4、安装tf

pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

报错了

pip install tensorflow==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

切到2.3.0的版本

=====================================

Collecting tensorflow==2.3.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/16/aa/3b0e0751a3bff298133941b54aad366230862c827b701f13d51e52bcc5ee/tensorflow-2.3.0-cp38-cp38-win_amd64.whl (342.5 MB)

|████████████████████████████████| 342.5 MB 2.2 MB/s

Collecting grpcio>=1.8.6

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/88/79/8e1d693a0fcf241b25aa88830ed28e509116149378518311f2ce21c61c7d/grpcio-1.31.0-cp38-cp38-win_amd64.whl (2.6 MB)

|████████████████████████████████| 2.6 MB 181 kB/s

Collecting six>=1.12.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl (10 kB)

Collecting protobuf>=3.9.2

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/09/f1/cf9d4248461aefd49cd2fdf9acdeb0aa5009f50adab1cd907fd4a461f00d/protobuf-3.12.4-py2.py3-none-any.whl (443 kB)

|████████████████████████████████| 443 kB 731 kB/s

Collecting h5py<2.11.0,>=2.10.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1e/63/0d32c1803c08518dd03e02f3cfe302335624f511155be723bcc7329fed4e/h5py-2.10.0-cp38-cp38-win_amd64.whl (2.5 MB)

|████████████████████████████████| 2.5 MB 6.8 MB/s

Collecting astunparse==1.6.3

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl (12 kB)

Collecting google-pasta>=0.1.8

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57 kB)

|████████████████████████████████| 57 kB 3.8 MB/s

Collecting tensorboard<3,>=2.3.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/1b/6a420d7e6ba431cf3d51b2a5bfa06a958c4141e3189385963dc7f6fbffb6/tensorboard-2.3.0-py3-none-any.whl (6.8 MB)

|████████████████████████████████| 6.8 MB 2.2 MB/s

Collecting termcolor>=1.1.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz (3.9 kB)

Collecting tensorflow-estimator<2.4.0,>=2.3.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/ed/5853ec0ae380cba4588eab1524e18ece1583b65f7ae0e97321f5ff9dfd60/tensorflow_estimator-2.3.0-py2.py3-none-any.whl (459 kB)

|████████████████████████████████| 459 kB 6.4 MB/s

Collecting keras-preprocessing<1.2,>=1.1.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/79/4c/7c3275a01e12ef9368a892926ab932b33bb13d55794881e3573482b378a7/Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)

|████████████████████████████████| 42 kB 3.2 MB/s

Collecting scipy==1.4.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f8/b9/98a75846fdda3756ce75705b518dde4c599ba419d11415ce3fe1ebc4a885/scipy-1.4.1-cp38-cp38-win_amd64.whl (31.0 MB)

|████████████████████████████████| 31.0 MB 655 kB/s

Collecting absl-py>=0.7.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/53/9243c600e047bd4c3df9e69cfabc1e8004a82cac2e0c484580a78a94ba2a/absl-py-0.9.0.tar.gz (104 kB)

|████████████████████████████████| 104 kB 6.8 MB/s

Requirement already satisfied: wheel>=0.26 in d:\programdata\anaconda3\envs\tf_2c\lib\site-packages (from tensorflow==2.3.0) (0.34.2)

Collecting numpy<1.19.0,>=1.16.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/22/cb/21a148329591931d8764e7ef49cb19586dd5b5e002a184988cb5ec1ccba9/numpy-1.18.5-cp38-cp38-win_amd64.whl (12.8 MB)

|████████████████████████████████| 12.8 MB 211 kB/s

Collecting gast==0.3.3

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d6/84/759f5dd23fec8ba71952d97bcc7e2c9d7d63bdc582421f3cd4be845f0c98/gast-0.3.3-py2.py3-none-any.whl (9.7 kB)

Collecting opt-einsum>=2.3.2

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl (65 kB)

|████████████████████████████████| 65 kB 1.3 MB/s

Collecting wrapt>=1.11.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz (27 kB)

Requirement already satisfied: setuptools in d:\programdata\anaconda3\envs\tf_2c\lib\site-packages (from protobuf>=3.9.2->tensorflow==2.3.0) (49.2.0.post20200714)

Collecting google-auth-oauthlib<0.5,>=0.4.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7b/b8/88def36e74bee9fce511c9519571f4e485e890093ab7442284f4ffaef60b/google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)

Collecting markdown>=2.6.8

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/63/eaec2bd025ab48c754b55e8819af0f6a69e2b1e187611dd40cbbe101ee7f/Markdown-3.2.2-py3-none-any.whl (88 kB)

|████████████████████████████████| 88 kB 392 kB/s

Collecting werkzeug>=0.11.15

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)

|████████████████████████████████| 298 kB 92 kB/s

Collecting requests<3,>=2.21.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61 kB)

|████████████████████████████████| 61 kB 145 kB/s

Collecting tensorboard-plugin-wit>=1.6.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b6/85/5c5ac0a8c5efdfab916e9c6bc18963f6a6996a8a1e19ec4ad8c9ac9c623c/tensorboard_plugin_wit-1.7.0-py3-none-any.whl (779 kB)

|████████████████████████████████| 779 kB 344 kB/s

Collecting google-auth<2,>=1.6.3

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cb/02/00e06ffa98fd0f11f36f808511012fa1fce41e4f79fa35dc7c515364ed01/google_auth-1.20.0-py2.py3-none-any.whl (91 kB)

|████████████████████████████████| 91 kB 422 kB/s

Collecting requests-oauthlib>=0.7.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/12/b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379/requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)

Collecting idna<3,>=2.5

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58 kB)

|████████████████████████████████| 58 kB 787 kB/s

Collecting chardet<4,>=3.0.2

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133 kB)

|████████████████████████████████| 133 kB 547 kB/s

Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl (127 kB)

|████████████████████████████████| 127 kB 656 kB/s

Requirement already satisfied: certifi>=2017.4.17 in d:\programdata\anaconda3\envs\tf_2c\lib\site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow==2.3.0) (2020.6.20)

Collecting pyasn1-modules>=0.2.1

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/95/de/214830a981892a3e286c3794f41ae67a4495df1108c3da8a9f62159b9a9d/pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)

|████████████████████████████████| 155 kB 819 kB/s

Collecting rsa<5,>=3.1.4; python_version >= "3.5"

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1c/df/c3587a667d6b308fadc90b99e8bc8774788d033efcc70f4ecaae7fad144b/rsa-4.6-py3-none-any.whl (47 kB)

|████████████████████████████████| 47 kB 825 kB/s

Collecting cachetools<5.0,>=2.0.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cd/5c/f3aa86b6d5482f3051b433c7616668a9b96fbe49a622210e2c9781938a5c/cachetools-4.1.1-py3-none-any.whl (10 kB)

Collecting oauthlib>=3.0.0

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/05/57/ce2e7a8fa7c0afb54a0581b14a65b56e62b5759dbc98e80627142b8a3704/oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)

|████████████████████████████████| 147 kB 172 kB/s

Collecting pyasn1<0.5.0,>=0.4.6

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)

|████████████████████████████████| 77 kB 593 kB/s

Building wheels for collected packages: termcolor, absl-py, wrapt

Building wheel for termcolor (setup.py) ... done

Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4835 sha256=7250f5ef320841f23b0bacbab0397bd0e228e9f195579f90f1ee1e4e16b51825

Stored in directory: c:\users\lemon\appdata\local\pip\cache\wheels\e3\de\40\cc69e66c496ef6bfe23010d31ca5584a6d58ab4cf2f5b5a187

Building wheel for absl-py (setup.py) ... done

Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121935 sha256=d658b2787203f64c8d9733560ecb157350c08f4cb570f489038f9a7b08c09a69

Stored in directory: c:\users\lemon\appdata\local\pip\cache\wheels\17\04\32\c00a5b5955b03178eb17879bb9dd937a13389eb8bec32d28ad

Building wheel for wrapt (setup.py) ... done

Created wheel for wrapt: filename=wrapt-1.12.1-cp38-cp38-win_amd64.whl size=33696 sha256=af9e69508cd702a9e7b7d1eb0fe6894766c7cb4dfff46f22b8d9988286355a2f

Stored in directory: c:\users\lemon\appdata\local\pip\cache\wheels\9b\c8\62\9d6aad874ab4f2600bf95167be834ab8abfdb1d73e3051c8c6

Successfully built termcolor absl-py wrapt

Installing collected packages: six, grpcio, protobuf, numpy, h5py, astunparse, google-pasta, pyasn1, pyasn1-modules, rsa, cachetools, google-auth, oauthlib, idna, chardet, urllib3, requests, requests-oauthlib, google-auth-oauthlib, markdown, werkzeug, tensorboard-plugin-wit, absl-py, tensorboard, termcolor, tensorflow-estimator, keras-preprocessing, scipy, gast, opt-einsum, wrapt, tensorflow

下载到了相当多的包

======================================================

5、测试安装

import tensorflow as tf

version = tf.__version__

gpu_ok = tf.test.is_gpu_available()

print("tf version:",version,"\nif use GPU",gpu_ok)

GPU那块估计还是需要启动的,这块稍后再看;

这个内存消耗啊,几百兆内存瞬间就出去了;

(TF_2C) D:\development\tf_demo>python test.py

2020-08-06 13:44:23.845676: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

2020-08-06 13:44:23.845876: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

WARNING:tensorflow:From test.py:3: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.

Instructions for updating:

Use `tf.config.list_physical_devices('GPU')` instead.

2020-08-06 13:46:09.966865: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2

To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

2020-08-06 13:46:09.976087: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2636c5b3b80 initialized for platform Host (this does not guarantee that XLA will be used). Devices:

2020-08-06 13:46:09.976202: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version

2020-08-06 13:46:09.977678: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll

2020-08-06 13:46:10.009138: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:

pciBusID: 0000:01:00.0 name: GeForce RTX 2070 with Max-Q Design computeCapability: 7.5

coreClock: 1.185GHz coreCount: 36 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 357.69GiB/s

2020-08-06 13:46:10.012615: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

2020-08-06 13:46:10.015965: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found

2020-08-06 13:46:10.019218: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found

2020-08-06 13:46:10.022966: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found

2020-08-06 13:46:10.026259: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found

2020-08-06 13:46:10.029529: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found

2020-08-06 13:46:10.032883: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found

2020-08-06 13:46:10.032974: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.

Skipping registering GPU devices...

2020-08-06 13:46:10.123444: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:

2020-08-06 13:46:10.123542: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0

2020-08-06 13:46:10.123846: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N

2020-08-06 13:46:10.126417: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2636c5b4900 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:

2020-08-06 13:46:10.126500: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce RTX 2070 with Max-Q Design, Compute Capability 7.5

tf version: 2.3.0

if use GPU False

======================================================