Tensorflow 2.3 GPU安装
以下 64 位系統(tǒng)支持 TensorFlow:
- Ubuntu 16.04 或更高版本
- Windows 7 或更高版本
- macOS 10.12.6(Sierra) 或更高版本(不支持GPU)
- Raspbian 9.0 或更高版本
安裝Python版本要求
Python 3.5 — 3.7下載 ANACONDA 對 Python版本和第三方庫進(jìn)行管理
Tensorflow GPU 版本安裝
- 安裝GPU版本必須有GPU硬件的支持。
- TensorFlow 對 NVIDIA 顯卡的支持較為完備
- 可以使用 conda 來安裝GPU 版本
對于 NVIDIA 顯卡,要求其 CUDA Compute Capability 不低于 3.5。
算力參考:https://developer.nvidia.com/cuda-gpus
驅(qū)動版本:NVIDIA驅(qū)動程序需 418.x 或更高版本。
可在命令行匯總執(zhí)行查看驅(qū)動版本:
(python37) C:\Users\78694>nvidia-smi
Fri Jan 21 00:31:07 2022
±----------------------------------------------------------------------------+
| NVIDIA-SMI 471.41 Driver Version: 471.41 CUDA Version: 11.4 |
|-------------------------------±---------------------±---------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce … WDDM | 00000000:01:00.0 On | N/A |
| 0% 27C P8 19W / 290W | 1823MiB / 8192MiB | 21% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
或者打開NVIDIA控制面板 在菜單欄→幫助 選擇 系統(tǒng)信息
可以查看到NVIDIA的硬件詳細(xì)信息
GPU版本有兩個(gè)依賴庫,對于 tensorflow2.3來說
- CUDA的版本需要是10.1
- cudnn版本號需要不小于 7.6
在安裝GPU版本的依賴庫時(shí),建議設(shè)置conda的國內(nèi)鏡像源,可以加速依賴庫的下載
anaconda prompt 命令行,執(zhí)行:
conda install cudatoolkit=10.1 conda install cudnn=7.6.5tensorflow安裝:
pip install tensorflow-gpu==2.3.0 -i https://pypi.douban.com/simple
在cmd中 輸入 python 進(jìn)入python 編譯環(huán)境后,輸入以下命令測試 tensorflow GPU版本是否安裝成功
注:
環(huán)境:顯卡3070Ti安裝
使用 ANACONDA 安裝Python3.7版本
conda create -n tensorflow python=3.7切換到 剛創(chuàng)建的 python3.7環(huán)境中
conda activate tensorflow查看 cudnn 和 cudatoolkit 可用的版本
conda search cudnn conda search cudatoolkitanaconda prompt 命令行,執(zhí)行:
conda install cudatoolkit=11.4.2 conda install cudnn=8.2.0.53查看 tensorflow-gpu 所有的版本
conda search tensorflow-gpu使用 conda 安裝Tensorflow 2.3
conda install tensorflow-gpu=2.3.0
在cmd中 輸入 python 進(jìn)入python 編譯環(huán)境后,輸入以下命令測試 tensorflow GPU版本是否安裝成功
(python37) C:\Users\78694>python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:35:01) [MSC v.1916 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “l(fā)icense” for more information.
>>> import tensorflow as tf
2022-01-21 12:51:00.487045: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
>>> tf.version
‘2.3.0’
>>>
>>> tf.config.list_physical_devices(‘GPU’)
2022-01-21 12:51:02.207078: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2022-01-21 12:51:02.229313: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: NVIDIA GeForce RTX 3070 Ti computeCapability: 8.6
coreClock: 1.77GHz coreCount: 48 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 566.30GiB/s
2022-01-21 12:51:02.233328: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2022-01-21 12:51:02.494197: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2022-01-21 12:51:02.692815: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2022-01-21 12:51:02.717066: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2022-01-21 12:51:02.861897: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2022-01-21 12:51:02.999753: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2022-01-21 12:51:03.150352: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2022-01-21 12:51:03.152222: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
[PhysicalDevice(name=’/physical_device:GPU:0’, device_type=‘GPU’)]
>>>
總結(jié)
以上是生活随笔為你收集整理的Tensorflow 2.3 GPU安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OpenCV 透视变换
- 下一篇: 在windows中对torch1.7.1