Tensorflow (0) 安装

部署运行你感兴趣的模型镜像

1、conda create -n tf

 

 

 

(tf) robot@robot-All-Series:~$ python
Python 3.9.7 (default, Sep 16 2021, 13:09:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2022-03-22 10:48:03.479799: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
>>> hello = tf.constant('Hellllo')
2022-03-22 10:48:37.685215: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2022-03-22 10:48:37.686987: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2022-03-22 10:48:37.741005: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:05:00.0 name: NVIDIA TITAN Xp computeCapability: 6.1
coreClock: 1.582GHz coreCount: 30 deviceMemorySize: 11.91GiB deviceMemoryBandwidth: 510.07GiB/s
2022-03-22 10:48:37.741362: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties: 
pciBusID: 0000:09:00.0 name: NVIDIA TITAN Xp computeCapability: 6.1
coreClock: 1.582GHz coreCount: 30 deviceMemorySize: 11.91GiB deviceMemoryBandwidth: 510.07GiB/s
2022-03-22 10:48:37.741391: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 10:48:37.743109: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10
2022-03-22 10:48:37.743152: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10
2022-03-22 10:48:37.744683: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2022-03-22 10:48:37.744945: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2022-03-22 10:48:37.746622: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2022-03-22 10:48:37.747540: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10
2022-03-22 10:48:37.751180: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7
2022-03-22 10:48:37.752242: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1
2022-03-22 10:48:37.752584: 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:  SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-03-22 10:48:38.084989: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:05:00.0 name: NVIDIA TITAN Xp computeCapability: 6.1
coreClock: 1.582GHz coreCount: 30 deviceMemorySize: 11.91GiB deviceMemoryBandwidth: 510.07GiB/s
2022-03-22 10:48:38.085183: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties: 
pciBusID: 0000:09:00.0 name: NVIDIA TITAN Xp computeCapability: 6.1
coreClock: 1.582GHz coreCount: 30 deviceMemorySize: 11.91GiB deviceMemoryBandwidth: 510.07GiB/s
2022-03-22 10:48:38.085208: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 10:48:38.085249: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10
2022-03-22 10:48:38.085265: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10
2022-03-22 10:48:38.085279: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2022-03-22 10:48:38.085297: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2022-03-22 10:48:38.085313: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2022-03-22 10:48:38.085331: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10
2022-03-22 10:48:38.085347: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7
2022-03-22 10:48:38.085933: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1
2022-03-22 10:48:38.085967: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 10:48:38.747587: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2022-03-22 10:48:38.747628: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0 1 
2022-03-22 10:48:38.747640: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0:   N Y 
2022-03-22 10:48:38.747647: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 1:   Y N 
2022-03-22 10:48:38.748426: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10902 MB memory) -> physical GPU (device: 0, name: NVIDIA TITAN Xp, pci bus id: 0000:05:00.0, compute capability: 6.1)
2022-03-22 10:48:38.748996: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 11208 MB memory) -> physical GPU (device: 1, name: NVIDIA TITAN Xp, pci bus id: 0000:09:00.0, compute capability: 6.1)
2022-03-22 10:48:38.749209: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
>>> se=tf.Session
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'Session'
>>> se=tf.Session()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'Session'
>>> se1 = tf.Session()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'Session'
>>> tf.__version__
'2.4.1'
>>> 

 错误是因为使用的tensorflow 2.0以上版本。

更换为1.14.0

conda uninstall tensorflow-gpu

conda install tensorflow-gpu==1.14.0

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - tensorflow-gpu==1.14.0 -> python[version='2.7.*|3.6.*|3.7.*']

Your python: python=3.9

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with your system:

  - feature:/linux-64::__glibc==2.31=0
  - feature:|@/linux-64::__glibc==2.31=0

Your installed version is: 2.31

 更改python版本为3.7.11

 

Downloading and Extracting Packages
certifi-2021.10.8    | 151 KB    | ################################################################################################################### | 100% 
python-3.7.11        | 45.3 MB   | ################################################################################################################### | 100% 
pip-21.2.2           | 1.8 MB    | ################################################################################################################### | 100% 
setuptools-58.0.4    | 775 KB    | ################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(tf) robot@robot-All-Series:~$ conda install tensorflow-gpu==1.14.0
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.11.0
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /home/robot/anaconda3/envs/tf

  added / updated specs:
    - tensorflow-gpu==1.14.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    astor-0.8.1                |   py37h06a4308_0          47 KB
    gast-0.5.3                 |     pyhd3eb1b0_0          21 KB
    grpcio-1.42.0              |   py37hce63b2e_0         2.1 MB
    h5py-3.6.0                 |   py37ha0f2276_0         1.0 MB
    importlib-metadata-4.8.2   |   py37h06a4308_0          39 KB
    keras-applications-1.0.8   |             py_1          29 KB
    markdown-3.3.4             |   py37h06a4308_0         127 KB
    mkl-service-2.4.0          |   py37h7f8727e_0          56 KB
    mkl_fft-1.3.1              |   py37hd3c417c_0         172 KB
    mkl_random-1.2.2           |   py37h51133e4_0         287 KB
    numpy-1.21.2               |   py37h20f2e39_0          23 KB
    numpy-base-1.21.2          |   py37h79a1101_0         4.8 MB
    protobuf-3.19.1            |   py37h295c915_0         306 KB
    scipy-1.7.3                |   py37hc147768_0        16.4 MB
    tensorboard-1.14.0         |   py37hf484d3e_0         3.1 MB
    tensorflow-1.14.0          |gpu_py37h74c33d7_0           4 KB
    tensorflow-base-1.14.0     |gpu_py37he45bfe2_0       146.3 MB
    tensorflow-estimator-1.14.0|             py_0         261 KB
    tensorflow-gpu-1.14.0      |       h0d30ee6_0           3 KB
    termcolor-1.1.0            |   py37h06a4308_1           9 KB
    wrapt-1.13.3               |   py37h7f8727e_2          51 KB
    ------------------------------------------------------------
                                           Total:       175.0 MB

The following NEW packages will be INSTALLED:

  _tflow_select      pkgs/main/linux-64::_tflow_select-2.1.0-gpu
  absl-py            pkgs/main/noarch::absl-py-0.15.0-pyhd3eb1b0_0
  astor              pkgs/main/linux-64::astor-0.8.1-py37h06a4308_0
  blas               pkgs/main/linux-64::blas-1.0-mkl
  c-ares             pkgs/main/linux-64::c-ares-1.18.1-h7f8727e_0
  cached-property    pkgs/main/noarch::cached-property-1.5.2-py_0
  cudatoolkit        pkgs/main/linux-64::cudatoolkit-10.1.243-h6bb024c_0
  cudnn              pkgs/main/linux-64::cudnn-7.6.5-cuda10.1_0
  cupti              pkgs/main/linux-64::cupti-10.1.168-0
  dataclasses        pkgs/main/noarch::dataclasses-0.8-pyh6d0b6a4_7
  gast               pkgs/main/noarch::gast-0.5.3-pyhd3eb1b0_0
  google-pasta       pkgs/main/noarch::google-pasta-0.2.0-pyhd3eb1b0_0
  grpcio             pkgs/main/linux-64::grpcio-1.42.0-py37hce63b2e_0
  h5py               pkgs/main/linux-64::h5py-3.6.0-py37ha0f2276_0
  hdf5               pkgs/main/linux-64::hdf5-1.10.6-hb1b8bf9_0
  importlib-metadata pkgs/main/linux-64::importlib-metadata-4.8.2-py37h06a4308_0
  intel-openmp       pkgs/main/linux-64::intel-openmp-2021.4.0-h06a4308_3561
  keras-applications pkgs/main/noarch::keras-applications-1.0.8-py_1
  keras-preprocessi~ pkgs/main/noarch::keras-preprocessing-1.1.2-pyhd3eb1b0_0
  libgfortran-ng     pkgs/main/linux-64::libgfortran-ng-7.5.0-ha8ba4b0_17
  libgfortran4       pkgs/main/linux-64::libgfortran4-7.5.0-ha8ba4b0_17
  libprotobuf        pkgs/main/linux-64::libprotobuf-3.19.1-h4ff587b_0
  markdown           pkgs/main/linux-64::markdown-3.3.4-py37h06a4308_0
  mkl                pkgs/main/linux-64::mkl-2021.4.0-h06a4308_640
  mkl-service        pkgs/main/linux-64::mkl-service-2.4.0-py37h7f8727e_0
  mkl_fft            pkgs/main/linux-64::mkl_fft-1.3.1-py37hd3c417c_0
  mkl_random         pkgs/main/linux-64::mkl_random-1.2.2-py37h51133e4_0
  numpy              pkgs/main/linux-64::numpy-1.21.2-py37h20f2e39_0
  numpy-base         pkgs/main/linux-64::numpy-base-1.21.2-py37h79a1101_0
  protobuf           pkgs/main/linux-64::protobuf-3.19.1-py37h295c915_0
  scipy              pkgs/main/linux-64::scipy-1.7.3-py37hc147768_0
  six                pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1
  tensorboard        pkgs/main/linux-64::tensorboard-1.14.0-py37hf484d3e_0
  tensorflow         pkgs/main/linux-64::tensorflow-1.14.0-gpu_py37h74c33d7_0
  tensorflow-base    pkgs/main/linux-64::tensorflow-base-1.14.0-gpu_py37he45bfe2_0
  tensorflow-estima~ pkgs/main/noarch::tensorflow-estimator-1.14.0-py_0
  tensorflow-gpu     pkgs/main/linux-64::tensorflow-gpu-1.14.0-h0d30ee6_0
  termcolor          pkgs/main/linux-64::termcolor-1.1.0-py37h06a4308_1
  typing_extensions  pkgs/main/noarch::typing_extensions-3.10.0.2-pyh06a4308_0
  werkzeug           pkgs/main/noarch::werkzeug-2.0.3-pyhd3eb1b0_0
  wrapt              pkgs/main/linux-64::wrapt-1.13.3-py37h7f8727e_2
  zipp               pkgs/main/noarch::zipp-3.7.0-pyhd3eb1b0_0


Proceed ([y]/n)? 
Downloading and Extracting Packages
h5py-3.6.0           | 1.0 MB    | ################################################################################################################### | 100% 
grpcio-1.42.0        | 2.1 MB    | ################################################################################################################### | 100% 
numpy-1.21.2         | 23 KB     | ################################################################################################################### | 100% 
protobuf-3.19.1      | 306 KB    | ################################################################################################################### | 100% 
mkl_fft-1.3.1        | 172 KB    | ################################################################################################################### | 100% 
tensorflow-gpu-1.14. | 3 KB      | ################################################################################################################### | 100% 
wrapt-1.13.3         | 51 KB     | ################################################################################################################### | 100% 
tensorboard-1.14.0   | 3.1 MB    | ################################################################################################################### | 100% 
tensorflow-estimator | 261 KB    | ################################################################################################################### | 100% 
keras-applications-1 | 29 KB     | ################################################################################################################### | 100% 
numpy-base-1.21.2    | 4.8 MB    | ################################################################################################################### | 100% 
gast-0.5.3           | 21 KB     | ################################################################################################################### | 100% 
astor-0.8.1          | 47 KB     | ################################################################################################################### | 100% 
tensorflow-base-1.14 | 146.3 MB  | ################################################################################################################### | 100% 
mkl_random-1.2.2     | 287 KB    | ################################################################################################################### | 100% 
tensorflow-1.14.0    | 4 KB      | ################################################################################################################### | 100% 
mkl-service-2.4.0    | 56 KB     | ################################################################################################################### | 100% 
importlib-metadata-4 | 39 KB     | ################################################################################################################### | 100% 
scipy-1.7.3          | 16.4 MB   | ################################################################################################################### | 100% 
termcolor-1.1.0      | 9 KB      | ################################################################################################################### | 100% 
markdown-3.3.4       | 127 KB    | ################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

 测试:

(tf) robot@robot-All-Series:~$ python
Python 3.7.11 (default, Jul 27 2021, 14:32:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
/home/robot/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])

tensorflow版本与numpy版本不匹配。

运行tensorflow代码出现dtypes.py:516: FutureWarning: Passing (type, 1) or '1type的解决方法_TanH.blog的博客-优快云博客

pip uninstall numpy  (conda uninstall numpy 失败)

再安装低版本的numpy:

conda install numpy==1.16.0

 

再测试tensorflow

(tf) robot@robot-All-Series:~$ python
Python 3.7.11 (default, Jul 27 2021, 14:32:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hellllo')
>>> se = tf.Session()
2022-03-22 14:51:18.028177: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcuda.so.1
2022-03-22 14:51:18.076529: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties: 
name: NVIDIA TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:05:00.0
2022-03-22 14:51:18.076872: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 1 with properties: 
name: NVIDIA TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:09:00.0
2022-03-22 14:51:18.077112: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 14:51:18.078664: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcublas.so.10
2022-03-22 14:51:18.080182: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcufft.so.10
2022-03-22 14:51:18.080425: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcurand.so.10
2022-03-22 14:51:18.082062: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusolver.so.10
2022-03-22 14:51:18.082934: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusparse.so.10
2022-03-22 14:51:18.086484: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudnn.so.7
2022-03-22 14:51:18.087523: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0, 1
2022-03-22 14:51:18.087881: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2022-03-22 14:51:18.093333: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3598195000 Hz
2022-03-22 14:51:18.093815: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5648ea47a380 executing computations on platform Host. Devices:
2022-03-22 14:51:18.093837: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
2022-03-22 14:51:18.409987: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties: 
name: NVIDIA TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:05:00.0
2022-03-22 14:51:18.410173: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 1 with properties: 
name: NVIDIA TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:09:00.0
2022-03-22 14:51:18.410209: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 14:51:18.410224: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcublas.so.10
2022-03-22 14:51:18.410237: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcufft.so.10
2022-03-22 14:51:18.410249: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcurand.so.10
2022-03-22 14:51:18.410262: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusolver.so.10
2022-03-22 14:51:18.410273: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcusparse.so.10
2022-03-22 14:51:18.410286: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudnn.so.7
2022-03-22 14:51:18.410886: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0, 1
2022-03-22 14:51:18.410923: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.1
2022-03-22 14:51:18.411292: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2022-03-22 14:51:18.411309: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187]      0 1 
2022-03-22 14:51:18.411316: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0:   N Y 
2022-03-22 14:51:18.411322: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 1:   Y N 
2022-03-22 14:51:18.411985: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 11158 MB memory) -> physical GPU (device: 0, name: NVIDIA TITAN Xp, pci bus id: 0000:05:00.0, compute capability: 6.1)
2022-03-22 14:51:18.412570: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 11435 MB memory) -> physical GPU (device: 1, name: NVIDIA TITAN Xp, pci bus id: 0000:09:00.0, compute capability: 6.1)
2022-03-22 14:51:18.414187: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5648ecb68fa0 executing computations on platform CUDA. Devices:
2022-03-22 14:51:18.414207: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): NVIDIA TITAN Xp, Compute Capability 6.1
2022-03-22 14:51:18.414216: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (1): NVIDIA TITAN Xp, Compute Capability 6.1
>>> print(se.run(hello))
b'Hellllo'

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

### 如何在不同环境下安装 TensorFlow 和 PyTorch #### 创建虚拟环境并配置 Python 版本 为了确保 TensorFlow 和 PyTorch 的兼容性和稳定性,通常建议为每个框架单独创建一个虚拟环境。以下是具体操作方法: 1. **创建虚拟环境** 使用 `conda` 工具来创建一个新的虚拟环境,并指定所需的 Python 版本。例如,要创建名为 `LprTorTens` 并使用 Python 3.8 的虚拟环境,可以运行以下命令: ```bash conda create -n LprTorTens python=3.8 ``` 2. **激活虚拟环境** 激活新创建的虚拟环境以便在其内部进行软件包的安装和其他操作: ```bash conda activate LprTorTens ``` 3. **切换至虚拟环境所在目录(可选)** 如果需要查看或修改该虚拟环境中的文件,可以通过以下方式进入其路径: ```bash cd D:\MySoft\AnaVirEnv\envs\LprTorTens ``` #### 安装 TensorFlow 对于 TensorFlow 的 GPU 支持版本 (如 `tensorflow-gpu==2.7.0`),需先确认 CUDA 和 cuDNN 的版本满足依赖条件[^1]。 1. **安装 TensorFlow-GPU** 运行以下命令以从清华大学镜像源安装特定版本的 TensorFlow: ```bash pip install tensorflow-gpu==2.7.0 -i https://pypi.mirrors.ustc.edu.cn/simple ``` 2. **验证安装成功与否** 启动 Python 解释器并通过导入模块测试是否正常工作: ```python import tensorflow as tf print(tf.__version__) ``` #### 安装 PyTorch PyTorch 提供了一个交互式的工具帮助选择合适的安装选项,基于操作系统、CUDA 配置等因素决定最佳组合[^2]。 1. **访问官方页面获取安装指令** 前往 [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/) 输入所需参数后复制推荐命令执行即可。假设目标是支持 CUDA 11.5,则可能得到如下形式的结果: ```bash pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu115 ``` 2. **检查安装状态** 类似于 TensorFlow 的检测流程,尝试加载库并打印版本号作为初步检验手段: ```python import torch print(torch.__version__) print(torch.cuda.is_available()) ``` #### 虚拟环境隔离的原因分析 尽管 Anaconda Base 环境能够容纳多个第三方扩展程序,但由于深度学习框架间可能存在冲突或者资源竞争现象,因此推荐针对每种主要技术栈设立独立的工作区[^3]。这样做不仅有助于减少潜在错误发生概率,还便于管理各自的依赖项集合以及更新策略。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值