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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > pytorch >内容正文

pytorch

[环境搭建八] 深度学习环境搭建--常见问题解决方案汇总

發布時間:2023/12/29 pytorch 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [环境搭建八] 深度学习环境搭建--常见问题解决方案汇总 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.在windows系統下, IDLE啟動錯誤,spyer打不開,jupyter打不開,出現連接不上,python.exe,pythonw.exe已停止工作等錯誤。

法1:關閉Windows防火墻,若錯誤消失,說明防火墻阻止了程序啟動python.exe和pythonw.exe。
具體操作:控制面板-windows防火墻-允許程序或功能通過windows防火墻-允許運行另一程序-瀏覽-定位到python或Anaconda安裝目錄,選中python.exe,打開-添加-確定。同理把pythonw.exe也添加進去,spyter和jupyter也可以打開了。


2.jupyter不能自動打開瀏覽器,打開之后一直這樣,只能通過復制鏈接到瀏覽器打開。

解決辦法:
(1)首先打開Anoconda Prompt,輸入命令 jupyter notebook --generate-config,系統會自動產生一個名為jupyter_notebook_config.py的文件,并且Anoconda Prompt窗口中會給出文件的路徑。
(2)按著顯示的路徑找到jupyter_notebook_config.py文件,使用pycharm、記事本、Notepad等打開。
(3)找到c.NotebookApp.password =‘ ’,在下一行輸入:(其中C:\Program Files (x86)\Google\Chrome\Application\chrome.exe,這是你想要使用的瀏覽器路徑,可通過右鍵點擊瀏覽器快捷方式查看屬性得到,chrome是你的瀏覽器名稱,可修改,修改完成后保存。標點全部改為英文)
(4)特別注意用戶名稱不能為中文。

# 1.使用谷歌瀏覽器 import webbrowser webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\Program Files(x86)\Google\Chrome\Application\chrome.exe')) c.NotebookApp.browser = 'chrome' # 2.使用QQ瀏覽器 import webbrowser webbrowser.register('QQBrowser',None,webbrowser.GenericBrowser(u'D:\QQBrowser\QQBrowser.exe')) c.NotebookApp.browser = 'QQBrowser'


2.附:如果jupyter保存文件的路徑中含有中文,也會出現只閃一下黑屏,然后沒有反應的情況。
3.連接鏡像報錯:

一直報兩個錯誤Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypCould not find a version that satisfies the requirement scikit-learn==0.19.1 (from versions: )

解決方案:
使用國內的鏡像
pip install pymongo -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
其中,–trusted-host pypi.douban.com 這是為了獲得ssl證書的認證

4.安裝CPU版的tensorflow

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

檢驗:

import tensorflow as tf tf.__version__ 輸出:版本號 下面只適用于1.x: x=tf.constant(1) y=tf.constant(2) z=x+y sess=tf.Session() print(sess.run(z)) 輸出:3

5.安裝tensorflow成功,但是import導入時報錯:

import tensorflow D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint8 = np.dtype([("qint8", np.int8, 1)]) D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_quint8 = np.dtype([("quint8", np.uint8, 1)]) D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint16 = np.dtype([("qint16", np.int16, 1)]) D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_quint16 = np.dtype([("quint16", np.uint16, 1)]) D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:521: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint32 = np.dtype([("qint32", np.int32, 1)]) D:\Users\11247\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.np_resource = np.dtype([("resource", np.ubyte, 1)])

原因:tensorflow和numpy不兼容不兼容(最終版本tf1.7+numpy1.15)
解決:
查看numpy版本:pip show numpy
安裝新的numpy:pip install numpy==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
依次查找,最終找到合適的版本

6.導入tensorflow報錯:

解決:
重裝低版本的tensorflow,重新導入時出現 ModuleNotFoundError: No module named ‘gast’。
pip unstall gast
pip install gast
提示:您安裝的gast0.3.0和tensorflow版本不匹配,建議gast0.2.0
pip install gast==0.2.0

7.安裝CPU版本的pytorch

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/main/ conda config --set show_channel_urls yes conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda install pytorch torchvision cpuonly

8.更改jupyter保存文件路徑

第一步:找到配置文件
菜單中打開Anaconda Prompt
輸入命令 jupyter notebook --generate-config
根據上面運行處的路徑打開C:\Users\HS.jupyter\jupyter_notebook_config.py文件
第二步:更改配置
(1)找到 #c.NotebookApp.notebook_dir = ‘’,去掉該行前面的“#”;在打算存放文件的位置先新建一個文件夾(很重要,最好是英文的),然后將新的路徑設置在單引號中,保存配置文件。
(2)在開始菜單找到“Jupyte Notebook”快捷鍵,鼠標右擊 – 更多 – 打開文件位置
找到對應的“Jupyte Notebook”快捷圖標,鼠標右擊 – 屬性 – 目標,去掉后面的 “%USERPROFILE%/”(很重要),然后點擊“應用”,“確定” 。重新啟動Jupyte Notebook即可。



9.安裝GPU的pytorch
(1)首先我們要確定本機是否有獨立顯卡。在計算機-管理-設備管理器-顯示適配器中,查看是否有獨立顯卡。進網站搜索查找是否支持。
(2)查找電腦支持的CUDA:控制面板->搜索NVIDIA->雙擊進入NVIDIA控制面板:點擊幫助->系統信息->組件:或者直接win+q搜索。

(3)選擇CUDA進行安裝:地址

(4)安裝CUDA
雙擊打開,顯示臨時解壓目錄,不需要改變,默認就好。
選擇自定義的安裝方式,并將VS勾給去掉,便可以正常安裝了,至于CUDA的安裝目錄,大家默認安裝在C盤即可。

(5)配置環境變量

(6)測試
cmd中輸入:nvcc -V

(7)CUDNN的下載及配置。地址。選擇的CUDNN的版本要跟CUDA版本一致。
下載之后,解壓縮,將CUDNN壓縮包里面的bin、clude、lib文件直接復制到CUDA的安裝目錄下,直接覆蓋安裝即可。

(8) 安裝torch和torchvision

conda install pytorch torchvision cudatoolkit=10.0

(9)檢驗

import torch import torchvision as tv print(torch.__version__) print(tv.__version__) print(torch.cuda.is_available())

10.anaconda創建虛擬環境失敗,CondaHTTPError問題
conda httperror http none none for url none Anaconda

方法1: 在conda安裝好之后,默認的鏡像是官方的,由于官網的鏡像在境外,訪問太慢或者不能訪問,為了能夠加快訪問的速度,這里選擇了清華的的鏡像。在命令行中運行(設置清華的鏡像)

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

然后,找到C:user/.condarc文件,刪除-defaults一行。

方法2: 如果仍然錯誤的話,將channels:下的鏈接更新為https://mirror.tuna.tsinghua.edu.cn/help/anaconda/連接下的anconda源,比如:

conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/' conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/' conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/' conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

11.anaconda下安裝網上爬蟲selenium庫,并配置環境
(1)安裝selenium庫。

conda install selenium

(2)下載谷歌瀏覽器和驅動
谷歌瀏覽器:https://www.google.cn/chrome/
查看谷歌瀏覽器版本:雙擊打開谷歌,右上角設置,選擇幫助,關于谷歌,查看版本。
安裝對應版本的驅動:http://npm.taobao.org/mirrors/chromedriver/(只需要大類相同就行,win32位的驅動也適合64位系統)
(3)將解壓后的chromedriver文件夾下的exe,直接復制到anconda的安裝目錄下。
(4)打開編輯器測試一下,如果可以正常打開網頁說明,安裝成功。

import selenium print(selenium.__version__)#用 Chrome 瀏覽器來測試 from selenium import webdriver browser = webdriver.Chrome() browser.get('http://www.baidu.com/')

總結

以上是生活随笔為你收集整理的[环境搭建八] 深度学习环境搭建--常见问题解决方案汇总的全部內容,希望文章能夠幫你解決所遇到的問題。

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