日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

conda安装tensorflow-gpu简洁版_win10 tensorflow2.2 安装注意事项

發布時間:2024/7/23 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 conda安装tensorflow-gpu简洁版_win10 tensorflow2.2 安装注意事项 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

學習新技術有兩座大山,一座是安裝配置環境,另一座是調試bug。

對于想學習人工智能開發的人來說,安裝配置tensorflow是必不可少的一步,這個過程對于初次接觸的人來說,到處都是火坑。下面大家跟我一起,看看都會踩到哪些雷!

一、安裝tensorflow

如果安裝tensorflow CPU版本,可以用這個命令:

pip install tensorflow

如果安裝tensorflow GPU版本,可以用這個命令:

pip install tensorflow-gpu

但這樣的話,因為訪問的是國外的網站,速度慢的會讓你懷疑人生!

所以我強烈建議大家用國內清華源的鏡像

如果安裝CPU版:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow

如果安裝GPU版:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu

但有時使用清華源的地址,網絡總是莫名其妙的中斷,碰到這種情況可以換豆瓣源的鏡像地址

https://pypi.douban.com/simple

試試,一般就OK了。

二、測試tensorflow安裝是否成功

打印一下版本號,看一下安裝是否成功

import tensorflow as tfprint(tf.__version__)

如果正常顯示tensorflow的版本號,則一切OK;但如果出現下面的錯誤提示:

Failed to load the native TensorFlow runtime.

Traceback (most recent call last):File "<ipython-input-6-64156d691fe5>", line 1, in <module>import tensorflow as tfFile "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflow__init__.py", line 24, in <module>from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-importFile "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflowpython__init__.py", line 49, in <module>from tensorflow.python import pywrap_tensorflowFile "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflowpythonpywrap_tensorflow.py", line 74, in <module>raise ImportError(msg)ImportError: Traceback (most recent call last):File "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>from tensorflow.python.pywrap_tensorflow_internal import *File "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>_pywrap_tensorflow_internal = swig_import_helper()File "C:UsersHonorVanAppDataRoamingPythonPython36site-packagestensorflowpythonpywrap_tensorflow_internal.py", line 24, in swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)File "D:ProgramDataAnaconda3libimp.py", line 243, in load_modulereturn load_dynamic(name, filename, file)File "D:ProgramDataAnaconda3libimp.py", line 343, in load_dynamicreturn _load(spec) ImportError: DLL load failed: 找不到指定的模塊。Failed to load the native TensorFlow runtime.See https://www.tensorflow.org/install/errorsfor some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

有人說是因為python版本和tensorflow版本不匹配,要么降低python版本,要么降低tensorflow版本。

如果不是python版本和tensorflow版本不匹配,比如我的當前環境為python3.6.5,安裝tensorflow的版本為2.2,win10 64位,pip 20.0,版本完全匹配呀~ 那是為什么呢?

如果你前面配置的是CPU版,可能是缺少類庫MSVCP140.DLL。

那么在這個地址https://www.microsoft.com/en-us/download/details.aspx?id=53587下載安裝即可。

這樣就能搞定CPU版的tensorflow。

三、搞定tensorflow GPU版的問題

如果你安裝的是GPU版,那么接著安裝cuda和cudnn,正常next就可以了,只需要注意環境變量path配一下,把cudnn的文件復制到cuda的目錄里就OK了。

但是tensorflow對cuda和cudnn的版本也有要求。

tensorflow2.2,通過官網了解只能對應裝10.1版本的cuda,10.0的還不行。

然后再找10.1cuda對應的cudnn7.6.5。這個顯卡加速庫就算是安裝成功了。

但如果報驅動和運行版本不對應的錯誤:

CUDA driver version is insufficient for CUDA runtime versionailed.

可能需要卸載工具包,再安裝對應的版本。

pip uninstall cudnn ; pip uninstall cudatoolkit

但在卸載前要先用pip list 命令看看有沒有這些東東。如果沒有,你可以嘗試更新顯卡驅動,到英偉達官網https://www.nvidia.cn/Download/index.aspx?lang=cn選擇對應的顯卡型號更新即可。

比如我的顯卡是老掉渣的GTX1060,最后顯示一切OK。

I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce GTX 1060 computeCapability: 6.1 coreClock: 1.6705GHz coreCount: 10 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 178.99GiB/s I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0 I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x22345614f70 initialized for platform Host (this does not guarantee that XLA will be used). Devices: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default VersionI tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce GTX 1060 computeCapability: 6.1 coreClock: 1.6705GHz coreCount: 10 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 178.99GiB/s I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0: N I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4700 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1) I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x223673b0e90 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce GTX 1060, Compute Capability 6.1

總的來說CPU版比較簡單,GPU版坑比較多。

總結

以上是生活随笔為你收集整理的conda安装tensorflow-gpu简洁版_win10 tensorflow2.2 安装注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。