基本环境
C:\Users\Administrator>pip list
Package Version
---------------------------------- ------------
- nsorflow-gpu
-ensorflow-gpu 1.14.0
absl-py 0.9.0
alabaster 0.7.11
altgraph 0.17
anaconda-client 1.7.2
anaconda-navigator 1.9.2
anaconda-project 0.8.2
appdirs 1.4.3
asgiref 3.3.1
asn1crypto 0.24.0
astor 0.8.1
astroid 2.0.4
astropy 3.0.4
astunparse 1.6.3
atomicwrites 1.2.1
attrs 18.2.0
Automat 0.7.0
Babel 2.6.0
backcall 0.1.0
backports.shutil-get-terminal-size 1.0.0
beautifulsoup4 4.6.3
bitarray 0.8.3
bkcharts 0.2
blaze 0.11.3
bleach 2.1.4
bokeh 0.13.0
boto 2.49.0
Bottleneck 1.2.1
cachetools 4.1.1
certifi 2020.6.20
cffi 1.11.5
chardet 3.0.4
cityscapesScripts 2.1.7
click 6.7
cloudpickle 1.6.0
clyent 1.2.2
colorama 0.3.9
coloredlogs 15.0
comtypes 1.1.7
conda 4.8.4
conda-build 3.15.1
conda-package-handling 1.7.0
constantly 15.1.0
contextlib2 0.5.5
cryptography 2.9.2
cycler 0.10.0
Cython 0.28.5
cytoolz 0.9.0.1
dask 0.19.1
datashape 0.5.4
decorator 4.3.0
defusedxml 0.5.0
Deprecated 1.2.10
deprecation 2.1.0
distributed 1.23.1
Django 3.1.3
dlib 19.21.0
docutils 0.14
entrypoints 0.2.3
et-xmlfile 1.0.1
ExifRead 2.1.2
eyeD3 0.9.5
fastcache 1.0.2
filelock 3.0.8
filetype 1.0.7
Flask 1.0.2
Flask-Cors 3.0.6
future 0.18.2
gast 0.3.3
GDAL 3.1.3
geographiclib 1.50
geopy 1.22.0
gevent 1.3.6
gitdb 4.0.5
GitPython 3.1.8
glob2 0.6
google-auth 1.20.1
google-auth-oauthlib 0.4.1
google-pasta 0.2.0
greenlet 0.4.15
grpcio 1.31.0
gym 0.17.3
gym-super-mario-bros 7.3.2
h5py 2.10.0
heapdict 1.0.0
html5lib 1.0.1
humanfriendly 9.1
hyperlink 18.0.0
idna 2.7
image 1.5.33
imageio 2.4.1
imagesize 1.1.0
imgaug 0.4.0
imgviz 1.2.2
importlib-metadata 1.7.0
incremental 17.5.0
ipykernel 4.10.0
ipython 6.5.0
ipython-genutils 0.2.0
ipywidgets 7.4.1
isort 4.3.4
itchat 1.3.10
itsdangerous 0.24
jdcal 1.4
jedi 0.12.1
Jinja2 2.10
jsonschema 2.6.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
jupyterlab 0.34.9
jupyterlab-launcher 0.13.1
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
keyring 13.2.1
kiwisolver 1.0.1
labelImg 1.8.3
labelme 4.2.9
lazy-object-proxy 1.3.1
llvmlite 0.24.0
locket 0.2.0
lxml 4.2.5
Markdown 3.2.2
MarkupSafe 1.0
matplotlib 2.2.3
mccabe 0.6.1
menuinst 1.4.14
mistune 0.8.3
mkl-fft 1.0.4
mkl-random 1.0.1
mock 4.0.2
more-itertools 4.3.0
mpmath 1.0.0
msgpack 0.5.6
multipledispatch 0.6.0
mysql-connector 2.2.9
navigator-updater 0.2.1
nbconvert 5.4.0
nbformat 4.4.0
nes-py 8.1.6
netaddr 0.8.0
networkx 2.1
nltk 3.3
nose 1.3.7
notebook 5.6.0
numba 0.39.0
numexpr 2.6.8
numpy 1.16.0
numpydoc 0.8.0
oauthlib 3.1.0
object-detection 0.1
odo 0.5.1
ogr 0.14.0
olefile 0.46
opencv-python 4.1.1.26
openpyxl 2.5.6
opt-einsum 3.3.0
OSR 0.0.1
packaging 17.1
pandas 0.23.4
pandocfilters 1.4.2
parso 0.3.1
partd 0.3.8
path.py 11.1.0
pathlib2 2.3.2
patsy 0.5.0
pefile 2019.4.18
pep8 1.7.1
pickleshare 0.7.4
Pillow 7.2.0
pip 21.0.1
pkginfo 1.4.2
pluggy 0.7.1
ply 3.11
prometheus-client 0.3.1
prompt-toolkit 1.0.15
protobuf 3.12.4
psutil 5.4.7
psycopg2 2.8.5
py 1.6.0
pyasn1 0.4.4
pyasn1-modules 0.2.2
pycodestyle 2.4.0
pycosat 0.6.3
pycparser 2.18
pycrypto 2.6.1
pycurl 7.43.0.5
pyflakes 2.0.0
PyGithub 1.53
pyglet 1.5.0
Pygments 2.2.0
PyInstaller 3.6
PyJWT 1.7.1
pylint 2.1.1
pyodbc 4.0.24
pyOpenSSL 18.0.0
pyparsing 2.2.0
pypng 0.0.20
PyQRCode 1.2.1
PyQt5 5.15.1
PyQt5-sip 12.8.1
pyquaternion 0.9.9
pyreadline 2.1
PySocks 1.6.8
pytest 3.8.0
pytest-arraydiff 0.2
pytest-astropy 0.4.0
pytest-doctestplus 0.1.3
pytest-openfiles 0.3.0
pytest-remotedata 0.3.0
python-dateutil 2.7.3
python-gitlab 2.5.0
pytz 2018.5
PyWavelets 1.0.0
pywin32 223
pywin32-ctypes 0.2.0
pywinpty 0.5.4
PyYAML 3.13
pyzmq 17.1.2
QtAwesome 0.4.4
qtconsole 4.4.1
QtPy 1.5.0
requests 2.24.0
requests-oauthlib 1.3.0
rope 0.11.0
rsa 4.6
ruamel-yaml 0.15.46
scikit-image 0.16.2
scikit-learn 0.19.2
scipy 1.4.1
seaborn 0.9.0
Send2Trash 1.5.0
service-identity 17.0.0
setuptools 49.3.2
Shapely 1.7.1
simplegeneric 0.8.1
simplejson 3.17.2
singledispatch 3.4.0.3
six 1.15.0
smmap 3.0.4
snowballstemmer 1.2.1
sortedcollections 1.0.1
sortedcontainers 2.0.5
Sphinx 1.7.9
sphinxcontrib-websupport 1.1.0
spyder 3.3.1
spyder-kernels 0.2.6
SQLAlchemy 1.2.11
sqlparse 0.4.1
statsmodels 0.9.0
sympy 1.1.1
tables 3.4.4
tblib 1.3.2
tensorboard 1.14.0
tensorboard-plugin-wit 1.7.0
tensorflow 1.14.0
tensorflow-estimator 1.14.0
tensorflow-gpu 1.14.0
tensorflow-gpu-estimator 2.3.0
termcolor 1.1.0
terminado 0.8.1
testpath 0.3.1
tf-slim 1.1.0
toolz 0.9.0
torch 1.6.0+cu101
torchvision 0.6.1+cu92
tornado 5.1
tqdm 4.56.0
traitlets 4.3.2
Twisted 18.7.0
typing 3.7.4.3
unicodecsv 0.14.1
urllib3 1.23
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.14.1
wheel 0.31.1
widgetsnbextension 3.4.1
win-inet-pton 1.0.1
win-unicode-console 0.5
wincertstore 0.2
wrapt 1.12.1
xlrd 1.1.0
XlsxWriter 1.1.0
xlwings 0.11.8
xlwt 1.3.0
you-get 0.4.1456
youtube-dl 2020.5.8
zict 0.1.3
zipp 3.1.0
zope.interface 4.5.0
tensorflow忽略提示设置
import os
import tensorflwo as tf
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
python下载模型方法
看了deeplabV3代码中的这个功能,从网上下载模型到指定路径下:
from six.moves import urllib#加载包
savepath = "D:/Project/pythonDemo/Seg/DeepLab/DownloadModel/deeplabv3_mnv2_pascal_train_aug_2018_01_29.tar.gz"#设置要保存的本地路径
download_path = "http://download.tensorflow.org/models/deeplabv3_mnv2_pascal_train_aug_2018_01_29.tar.gz"#要下载的路径
print('downloading model, this might take a while...')
urllib.request.urlretrieve(download_path ,savepath )#下载模型
print('download completed! loading DeepLab model...')
python打开tar压缩包
import tarfile#加载tar包
tarball_path = "D:/Project/pythonDemo/Seg/DeepLab/DownloadModel/deeplabv3_mnv2_pascal_train_aug_2018_01_29.tar.gz"#设置tar压缩包路径
graph_def = None#压缩包打开放到这变量里
# Extract frozen graph from tar archive.
tar_file = tarfile.open(tarball_path)#打开tar压缩包
for tar_info in tar_file.getmembers():
if self.FROZEN_GRAPH_NAME in os.path.basename(tar_info.name):
file_handle = tar_file.extractfile(tar_info)
graph_def = tf.GraphDef.FromString(file_handle.read())
break
tar_file.close()#关闭tar压缩包
if graph_def is None:#判断是否读取成功
raise RuntimeError('Cannot find inference graph in tar archive.')
查看GPU和CPU
主要有个毛病,明明装了CUDA,在cmd界面可以看到CUDA可用,但是在pycharm 中无法发现GPU
#查看运行设备有几个GPU和CPU
gpus = tf.config.experimental.list_physical_devices('GPU')
cpus = tf.config.experimental.list_physical_devices('CPU')
print(gpus, cpus)
allDevice = tf.config.experimental.list_physical_devices(device_type=None)#查看所有设备
print(allDevice)
测试tensorflow是否能用GPU训练
tf.test.is_gpu_available()#返回True则可以GPU,返回False则不能使用GPU