Deep learning neural network - TensorFlow installation and tf2 connection server can not connect to the problem

Table of contents

1. Install TensorFlow

2. Problem: The tf2 connection server cannot connect to the problem 


1. Install TensorFlow

1. Set Tsinghua source: https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

2. Create a virtual environment in Anaconda prop:
       # First edit the tensorflow2.0.0.yml file with Notepad

The content of the file is as follows. If there is no file, you can open Notepad and save it by yourself: (save as tensorflow2.0.0.yml)

name: tf2
channels:
  - defaults
dependencies:
  - _tflow_select=2.2.0=eigen
  - absl-py=0.15.0=pyhd3eb1b0_0
  - aiohttp=3.7.4.post0=py36h2bbff1b_2
  - astor=0.8.1=py36haa95532_0
  - async-timeout=3.0.1=py36haa95532_0
  - attrs=21.4.0=pyhd3eb1b0_0
  - backcall=0.2.0=pyhd3eb1b0_0
  - blas=1.0=mkl
  - blinker=1.4=py36haa95532_0
  - brotlipy=0.7.0=py36h2bbff1b_1003
  - ca-certificates=2022.3.29=haa95532_0
  - cachetools=4.2.2=pyhd3eb1b0_0
  - certifi=2021.5.30=py36haa95532_0
  - cffi=1.14.6=py36h2bbff1b_0
  - chardet=4.0.0=py36haa95532_1003
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - click=8.0.3=pyhd3eb1b0_0
  - colorama=0.4.4=pyhd3eb1b0_0
  - cryptography=3.4.7=py36h71e12ea_0
  - cycler=0.11.0=pyhd3eb1b0_0
  - decorator=5.1.1=pyhd3eb1b0_0
  - entrypoints=0.3=py36_0
  - freetype=2.10.4=hd328e21_0
  - gast=0.2.2=py36_0
  - google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
  - google-pasta=0.2.0=pyhd3eb1b0_0
  - grpcio=1.35.0=py36hc60d5dd_0
  - h5py=2.10.0=py36h5e291fa_0
  - hdf5=1.10.4=h7ebc959_0
  - icc_rt=2019.0.0=h0cc432a_1
  - icu=58.2=ha925a31_3
  - idna=3.3=pyhd3eb1b0_0
  - idna_ssl=1.1.0=py36haa95532_0
  - importlib-metadata=4.8.1=py36haa95532_0
  - intel-openmp=2022.0.0=haa95532_3663
  - ipykernel=5.3.4=py36h5ca1d4c_0
  - ipython=7.16.1=py36h5ca1d4c_0
  - ipython_genutils=0.2.0=pyhd3eb1b0_1
  - jedi=0.17.0=py36_0
  - joblib=1.0.1=pyhd3eb1b0_0
  - jpeg=9d=h2bbff1b_0
  - jupyter_client=7.1.2=pyhd3eb1b0_0
  - jupyter_core=4.8.1=py36haa95532_0
  - keras-applications=1.0.8=py_1
  - keras-preprocessing=1.1.2=pyhd3eb1b0_0
  - kiwisolver=1.3.1=py36hd77b12b_0
  - libpng=1.6.37=h2a8f88b_0
  - libprotobuf=3.17.2=h23ce68f_1
  - libtiff=4.2.0=hd0e1b90_0
  - lz4-c=1.9.3=h2bbff1b_1
  - markdown=3.3.4=py36haa95532_0
  - matplotlib=3.3.4=py36haa95532_0
  - matplotlib-base=3.3.4=py36h49ac443_0
  - mkl=2020.2=256
  - mkl-service=2.3.0=py36h196d8e1_0
  - mkl_fft=1.3.0=py36h46781fe_0
  - mkl_random=1.1.1=py36h47e9c7a_0
  - multidict=5.1.0=py36h2bbff1b_2
  - nest-asyncio=1.5.1=pyhd3eb1b0_0
  - numpy=1.19.2=py36hadc3359_0
  - numpy-base=1.19.2=py36ha3acd2a_0
  - oauthlib=3.2.0=pyhd3eb1b0_0
  - olefile=0.46=py36_0
  - openssl=1.1.1n=h2bbff1b_0
  - opt_einsum=3.3.0=pyhd3eb1b0_1
  - pandas=1.1.5=py36hd77b12b_0
  - parso=0.8.3=pyhd3eb1b0_0
  - pickleshare=0.7.5=pyhd3eb1b0_1003
  - pillow=8.3.1=py36h4fa10fc_0
  - pip=21.2.2=py36haa95532_0
  - prompt-toolkit=3.0.20=pyhd3eb1b0_0
  - protobuf=3.17.2=py36hd77b12b_0
  - pyasn1=0.4.8=pyhd3eb1b0_0
  - pyasn1-modules=0.2.8=py_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pygments=2.11.2=pyhd3eb1b0_0
  - pyjwt=2.1.0=py36haa95532_0
  - pyopenssl=21.0.0=pyhd3eb1b0_1
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pyqt=5.9.2=py36h6538335_2
  - pyreadline=2.1=py36_1
  - pysocks=1.7.1=py36haa95532_0
  - python=3.6.5=h0c2934d_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - pytz=2021.3=pyhd3eb1b0_0
  - pywin32=228=py36hbaba5e8_1
  - pyzmq=22.2.1=py36hd77b12b_1
  - qt=5.9.7=vc14h73c81de_0
  - requests=2.27.1=pyhd3eb1b0_0
  - requests-oauthlib=1.3.0=py_0
  - rsa=4.7.2=pyhd3eb1b0_1
  - scikit-learn=0.24.1=py36hf11a4ad_0
  - scipy=1.5.2=py36h9439919_0
  - seaborn=0.11.2=pyhd3eb1b0_0
  - setuptools=58.0.4=py36haa95532_0
  - sip=4.19.8=py36h6538335_0
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.38.2=h2bbff1b_0
  - tensorboard=2.4.0=pyhc547734_0
  - tensorboard-plugin-wit=1.6.0=py_0
  - tensorflow=2.0.0=eigen_py36h457aea3_0
  - tensorflow-base=2.0.0=eigen_py36h01553b8_0
  - tensorflow-estimator=2.0.0=pyh2649769_0
  - termcolor=1.1.0=py36haa95532_1
  - threadpoolctl=2.2.0=pyh0d69192_0
  - tk=8.6.11=h2bbff1b_0
  - tornado=6.1=py36h2bbff1b_0
  - traitlets=4.3.3=py36haa95532_0
  - typing-extensions=4.1.1=hd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - urllib3=1.26.8=pyhd3eb1b0_0
  - vc=14.2=h21ff451_1
  - vs2015_runtime=14.27.29016=h5e58377_2
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - werkzeug=0.16.1=py_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - win_inet_pton=1.1.0=py36haa95532_0
  - wincertstore=0.2=py36h7fe50ca_0
  - wrapt=1.12.1=py36he774522_1
  - xz=5.2.5=h62dcd97_0
  - yarl=1.6.3=py36h2bbff1b_0
  - zipp=3.6.0=pyhd3eb1b0_0
#  - zlib=1.2.12=h8cc25b3_0
  - zstd=1.4.9=h19a0ad4_0
  - pip:
    - google-auth==1.35.0
prefix: C:\Users\86157\anaconda3\envs\tf2

Modify the last line in the file

prefix: C:\Users\86157\anaconda3\envs\tf2 is prefix: the path of the virtual environment you specified 

Open the anaconda prompt and enter the command:

conda env create -f tensorflow2.0.0.yml -n tf2

Note: After -f is the full file path of the TensorFlow2.0.0.yml file

After the environment is created, activate it and enter the tf2 virtual environment

Command: conda activate tf2


3. Enter the tf2 virtual environment and perform the following installation:

       # Set up for different virtual environments

conda install ipykernel  ​​​​​​​



       # Run the following command to make jupyter notebook recognize the environment
       python -m ipykernel install --user --name tf2 --display-name "tf2"

       Note: tf2 is the name of the current virtual environment "tf2" is the kernel name displayed in jupyter notebook

 At this point, the installation is complete. start jupyter notebook

 

2. Problem: The tf2 connection server cannot connect to the problem 

 Jupyter startup prompts This event loop is already running 

Solution:

conda activate tf2 #Switch to the tf2 virtual environment
conda list # Check yourself ipykernel is 4.6.1, due to a version problem, it cannot be connected due to a mismatch
pip install --ignore-installed ipykernel --upgrade # Forced update

 

 更新完成,此时可能会出现报错:ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.0.0 requires tensorboard<2.1.0,>=2.0.0, but you have tensorboard 2.4.0 which is incompatible.

 reason:

The tensorboard version does not match TensorFlow, the TensorFlow version we use is 2.0.0, and the tensorboard version is 2.4.0

Solution:

pip install tensorboard==2.0.0 # Update tensorboard version to 2.0.0

 Updated:

 restart jupyter notebook

View jupyter version information

!jupyter --version

View TensorFlow version and installation path:

import tensorflow as tf
tf.__version__ # This command is to get the installed tensorflow version
print(tf.__version__) # Output version
tf.__path__ #View tensorflow installation path
print(tf.__path__)

  

Guess you like

Origin blog.csdn.net/weixin_46474921/article/details/124614211