环境搭配 TensorFlow GPU

 

 

 

 

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

显示 python,TensorFlow,CUDA,cuDNN, GPU 等版本型号

 

import os, sys
print(sys.executable) #
print(sys.version) ## python
print(sys.version_info)

import tensorflow as tf
print(tf. __version__) ## tensorflow

 

进入anaconda环境

1. 查看torch版本

python -c \”import torch; print(torch.__version__)\”

2. 查看cuda版本

python -c \”import torch; print(torch.version.cuda)\”

 

import torch
print(torch.version.cuda)

 

import torch
print(torch.backends.cudnn.version())

查看cudnn_version.h文件

include\cudnn.h
cudnn的include里有cudnn_version.h的情况:
locate cudnn_version.h 

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

cudnn版本在8.0以前
locate cudnn.h 

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

    1

cudnn版本在8.0以前,这个命令会输出。但是8.0版本后就没有输出,需要用下面的命令。
cudnn版本在8.0以后

在8.0版本之后用上面的命令就没有输出了。因为这个头文件内容变了。用下面的命令可以看到

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
————————————————
版权声明:本文为CSDN博主「巴啦啦魔仙变!!」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41726670/article/details/124764498

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

Keras is included in TensorFlow 2.0 above. So

  • remove import keras and
  • replace from keras.module.module import class statement to --> from tensorflow.keras.module.module import class
  • Maybe your GPU memory is filled. So use allow growth = True in GPU option. This is deprecated now. But use this below code snippet after imports may solve your problem.
import tensorflow as tf
from tensorflow.compat.v1.keras.backend import set_session
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True  # dynamically grow the memory used on the GPU
config.log_device_placement = True  # to log device placement (on which device the operation ran)
sess = tf.compat.v1.Session(config=config)
set_session(sess)

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

环境搭配

python: 3.6.4.

Tensorflow Version: 1.12.0.

Keras Version: 2.2.4.

CUDA: V10.0.

cuDNN: V7.4.1.5.

NVIDIA GeForce GTX 1080.

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

环境搭配

 

posted @ 2023-10-09 22:29  emanlee  阅读(4)  评论(0编辑  收藏  举报