目录
一、安装TensorFlow
二、问题:tf2连接服务器连接不到的问题?
一、安装TensorFlow
1.设置清华源:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
2.Anaconda?propt中创建虚拟环境: ???????#?先用Notepad?编辑tensorflow2.0.0.yml文件
文件内容为如下,没有文件可以打开记事本自行输入保存一下:(保存为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
修改文件中最后一行
prefix: C:\Users\86157\anaconda3\envs\tf2? ? ? 为prefix:?你指定的虚拟环境的路径?
打开anaconda?prompt?输入命令 :
conda?env?create?-f?tensorflow2.0.0.yml?-n?tf2
注意:-f后为TensorFlow2.0.0.yml文件的完整文件路径
环境创建好后进行激活,进入tf2虚拟环境
命令:conda?activate?tf2
3.????进入tf2虚拟环境执行如下安装:
???????#?为不同的虚拟环境设置
conda?install?ipykernel?????????
???????#?运行如下命令使?jupyter?notebook?能够识别到环境 ???????python?-m?ipykernel?install?--user?--name?tf2?--display-name?"tf2"
???????注:?tf2为当前虚拟环境名称???"tf2"为jupyter?notebook中显示的内核名称
?到此,安装完成。启动jupyter?notebook
?
二、问题:tf2连接服务器连接不到的问题?
?jupyter?启动提示This?event?loop?is?already?running?
解决办法:
conda?activate?tf2???#?切换到tf2虚拟环境 conda?list??#?查看一下自己?ipykernel?为4.6.1,由于版本问题造成不匹配无法连接 pip?install?--ignore-installed?ipykernel?--upgrade?????#?进行强制更新
?
?更新完成,此时可能会出现报错: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.
?原因:
tensorboard版本不匹配与TensorFlow,我们使用的TensorFlow版本为2.0.0,而tensorboard版本为2.4.0
解决办法:
pip?install?tensorboard==2.0.0?????#?将tensorboard版本更新为2.0.0
?更新后:
?重新启动jupyter?notebook
查看jupyter版本信息
!jupyter --version
查看TensorFlow版本及安装路径:
import tensorflow as tf tf.__version__ ? ? ? ?# 此命令为获取安装的tensorflow版本 print(tf.__version__) # 输出版本 tf.__path__ ? #查看tensorflow安装路径 print(tf.__path__)
??
|