欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡(jiǎn)單利用conda安裝tensorflow-gpu=2.2.0的過程及問題解決

 更新時(shí)間:2023年01月04日 11:12:23   作者:愛聽許嵩歌  
這篇文章主要介紹了簡(jiǎn)單利用conda安裝tensorflow-gpu=2.2.0,本文給大家詳細(xì)分享問題記錄及錯(cuò)誤問題解決方案,需要的朋友可以參考下

網(wǎng)上安裝tensorflow-gpu=2.2.0什么的一大推,而且最后還報(bào)錯(cuò),一般問題出現(xiàn)在:
一、安裝下載慢
二、cuda和cudnn版本不對(duì)

我最后實(shí)驗(yàn)了,很好解決上面的問題。

2021年1月26日更新,python版本最好是3.7,3.8版本安裝有可能有問題,大概是conda沒有完全匹配好。

2021年8月10號(hào)更新,上面的問題官方解決了,首先使用conda命令安裝tensorflow-gpu=2.2.0,注意(需要已經(jīng)換成清華源了)
清華源命令:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --set show_channel_urls yes	   

安裝命令:

conda install tensorflow-gpu==2.2.0

如果上面方式不行,就按下面方法來。
一、安裝tensorflow-gpu=2.2.0使用清華源安裝,代碼如下:

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

這樣下載速度飛起!

二、什么去官網(wǎng)下載cuda版本配置路徑,感覺都不靠譜,我實(shí)驗(yàn)了,一個(gè)命令搞定,我的是1080Ti顯卡,先通過GeForce Experience把驅(qū)動(dòng)更新到最新,我的cuda信息如下:

在這里插入圖片描述

我cuda的是11.0,這不重要,一般需要cuda是10.1或者以上就可以了。
然后一句代碼安裝:

conda install cudatoolkit=10.1 cudnn=7.6.5

注意:不要改上面的版本,不然安裝成功了,使用時(shí)報(bào)錯(cuò),這里就是個(gè)坑,我試過很多,這兩個(gè)版本才是對(duì)應(yīng)的,不管tensorflow-gpu=2.0/2.1/2.2,都適用
tensorflow-gpu對(duì)應(yīng)的cuda版本網(wǎng)址:https://tensorflow.google.cn/install/source_windows

2021年5月18日更新,安裝tensorflow-gpu=2.4.0,使用python版本為3.7或者3.8,cudatoolkit=11.0,cudnn=8.0

在這里插入圖片描述

安裝好后測(cè)試下,測(cè)試代碼;

import tensorflow as tf
import timeit
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 代碼用于忽略級(jí)別 2 及以下的消息(級(jí)別 1 是提示,級(jí)別 2 是警告,級(jí)別 3 是錯(cuò)誤)。

with tf.device('/cpu:0'):
    cpu_a = tf.random.normal([10000, 1000])
    cpu_b = tf.random.normal([1000, 2000])
    print(cpu_a.device, cpu_b.device)

with tf.device('/gpu:0'):
    gpu_a = tf.random.normal([10000, 1000])
    gpu_b = tf.random.normal([1000, 2000])
    print(gpu_a.device, gpu_b.device)
def cpu_run():
    with tf.device('/cpu:0'):
        c = tf.matmul(cpu_a, cpu_b)
    return c
def gpu_run():
    with tf.device('/gpu:0'):
        c = tf.matmul(gpu_a, gpu_b)
    return c
# warm up
cpu_time = timeit.timeit(cpu_run, number=10)
gpu_time = timeit.timeit(gpu_run, number=10)
print('warmup:', cpu_time, gpu_time)

cpu_time = timeit.timeit(cpu_run, number=10)
gpu_time = timeit.timeit(gpu_run, number=10)
print('run time:', cpu_time, gpu_time)

print('GPU', tf.test.is_gpu_available())

結(jié)果為:

warmup: 1.1624844 1.8189751
run time: 1.1631149999999995 0.0005907000000000551
GPU True

這樣就安裝成功了!
另外推薦個(gè)自動(dòng)補(bǔ)全插件,很好用,TabNine,安裝方法鏈接如下:
https://www.tabnine.com/

2020年10月11號(hào)更新
最近可能出現(xiàn)的版本問題報(bào)錯(cuò),例如:
AttributeError: module ‘tensorflow’ has no attribute ‘compat’
解決方案:如下所示:

報(bào)錯(cuò):AttributeError: module ‘tensorflow’ has no attribute ‘compat’
找了半天錯(cuò)誤,發(fā)現(xiàn)問題了,如下:

在這里插入圖片描述

2020年10月5號(hào)更新
tensorflow==2.1.0版本也出現(xiàn)了這個(gè)問題,也用相同方法改正,注意版本就行了!?。?br />個(gè)是2.2版本,所以你要裝2.0.0版本的:

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

或者

conda install tensorflow-estimator==2.0.0

這樣就解決問題了。這個(gè)安裝估計(jì)是個(gè)bug,以前沒這個(gè)版本錯(cuò)誤的,只是最近出現(xiàn)的。

到此這篇關(guān)于簡(jiǎn)單利用conda安裝tensorflow-gpu=2.2.0的文章就介紹到這了,更多相關(guān)conda安裝tensorflow-gpu內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論