Tensorflow安装过程
- 查看安装的软件版本anaconda/python/conda等 c o n d a i n f o conda \ info conda info
- 安装py为3.9.7使用命令$conda\ create\ --name\ py38\ python==3.8.5 $
- 进入py39这个环境变量 c o n d a a c t i v a t e p y 39 conda\ activate\ py39 conda activate py39
- 安装gpu配套应用,注意python和cuda,cudnn版本号要一一对应 c o n d a i n s t a l l c u d a t o o l k i t = 10.1 c u d n n = 7.6.5 conda \ install \ cudat oolkit=10.1 \ cudnn=7.6.5 conda install cudatoolkit=10.1 cudnn=7.6.5
- 安装GPU和keras p i p i n s t a l l t e n s o r f l o w − g p u = = 2.5.0 pip\ install\ tensorflow-gpu==2.5.0 pip install tensorflow−gpu==2.5.0之前的版本是分开安装。但是在此之后两个在一起了
- 安装常用工具 pip install opencv-python pillow matplotlib scipy pandas scikit-learn tqdm scikit-image imutils PyYAML seaborn easydict seaborn ipython imageio xlrd jieba tensorboard
- 打开anaconda安装相应IDE
安装cpu版本
pip install --ignore-installed --upgrade tensorflow
打开资源管理器-性能,然后程序运行python程序查看gpu使用情况
import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1).astype(‘float32’)
x_test = x_test.reshape(x_test.shape[0], 28, 28, 1).astype(‘float32’)
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(filters=6, kernel_size=(5, 5), activation=‘sigmoid’, input_shape=(28, 28, 1)),
tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2),
tf.keras.layers.Conv2D(filters=16, kernel_size=(5, 5), activation=‘sigmoid’),
tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(120, activation=‘sigmoid’),
tf.keras.layers.Dense(84, activation=‘sigmoid’),
tf.keras.layers.Dense(10, activation=‘softmax’),
])
model.compile(optimizer=‘adam’, loss=‘sparse_categorical_crossentropy’, metrics=[‘accuracy’])
model.fit(x_train, y_train, epochs=10)
model.evaluate(x_test, y_test)
安装过程中查询的网址
python版本查看
https://www.python.org/downloads/
cudatoolkit版本号
https://developer.nvidia.com/cuda-toolkit-archive
cudatoolkit和显卡对应关系
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
cudnn版本号
https://docs.nvidia.com/deeplearning/cudnn/release-notes/
cudnn和cudatoolkit对应关系
https://developer.nvidia.com/rdp/cudnn-archive#a-collapse742-10
tensorflow和cuda对应版本
https://tensorflow.google.cn/install/source#gpu
tensorflow和kares对应关系
https://blog.csdn.net/ysk2931/article/details/121132257?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-2-121132257.pc_agg_new_rank&utm_term=keras%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC&spm=1000.2123.3001.4430