pytorch GPU版本安装 win10
我原先裝的是pytorch cpu版本,在復現(xiàn)論文源碼的時候提示AssertionError: Torch not compiled with CUDA enabled,查了一下資料,又看了一下電腦的pytorch版本,才發(fā)現(xiàn)原來裝的是cpu版本,應該裝成gpu版本。在win10環(huán)境下安裝pytorch gpu版本的步驟如下。
首先在cmd或者anaconda prompt中創(chuàng)建名為pytorch_gpu的環(huán)境,制定python版本,我用的是python3.7
繼續(xù)安裝:
Collecting package metadata (repodata.json): done Solving environment: done## Package Plan ##environment location: D:\Anaconda\envs\pytorch_gpuadded / updated specs:- pip- python=3.7The following packages will be downloaded:package | build---------------------------|-----------------python-3.7.6 | h60c2a47_2 18.3 MB defaultssetuptools-44.0.0 | py37_0 671 KB defaultsvc-14.1 | h21ff451_1 4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123vs2017_runtime-15.4.27004.2010| 1 1.6 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123------------------------------------------------------------Total: 20.6 MBThe following NEW packages will be INSTALLED:ca-certificates anaconda/pkgs/main/win-64::ca-certificates-2019.11.27-0certifi anaconda/pkgs/main/win-64::certifi-2019.11.28-py37_0openssl anaconda/pkgs/main/win-64::openssl-1.1.1d-he774522_3pip anaconda/pkgs/main/win-64::pip-19.3.1-py37_0python anaconda/pkgs/main/win-64::python-3.7.6-h60c2a47_2setuptools anaconda/pkgs/main/win-64::setuptools-44.0.0-py37_0sqlite anaconda/pkgs/main/win-64::sqlite-3.30.1-he774522_0vc anaconda/cloud/peterjc123/win-64::vc-14.1-h21ff451_1vs2015_runtime anaconda/pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1vs2017_runtime anaconda/cloud/peterjc123/win-64::vs2017_runtime-15.4.27004.2010-1wheel anaconda/pkgs/main/win-64::wheel-0.33.6-py37_0wincertstore anaconda/pkgs/main/win-64::wincertstore-0.2-py37_0Proceed ([y]/n)? y # 忽略中間一頓操作 ...done Executing transaction: done # # To activate this environment, use # # $ conda activate pytorch_gpu # # To deactivate an active environment, use # # $ conda deactivate激活pytorch_gpu環(huán)境,
conda activate pytorch_gpu按照pytorch官網(wǎng)上的提示,我們選擇合適版本進行安裝,我用的是cuda10.0和python3.7,其中cuda版本根據(jù)nvidia control panel(nvidia控制面板里面的系統(tǒng)信息里面有提示)具體而定。安裝指令:
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch但是安裝的時候提示以下問題:
Collecting package metadata (repodata.json): done Solving environment: done## Package Plan ##environment location: D:\Anaconda\envs\pytorch_gpuadded / updated specs:- cudatoolkit=10.0- pytorch- torchvisionThe following packages will be downloaded:package | build---------------------------|-----------------freetype-2.9.1 | ha9979f8_1 470 KB defaultsmkl-service-2.3.0 | py37hb782905_0 200 KB defaultsmkl_fft-1.0.15 | py37h14836fe_0 137 KB defaultsmkl_random-1.1.0 | py37h675688f_0 270 KB defaultsnumpy-1.17.4 | py37h4320e6b_0 5 KB defaultsnumpy-base-1.17.4 | py37hc3f5095_0 4.8 MB defaultsolefile-0.46 | py37_0 49 KB defaultspillow-7.0.0 | py37hcc1f983_0 726 KB defaultspytorch-1.2.0 |py3.7_cuda100_cudnn7_1 479.3 MB pytorchtk-8.6.8 | hfa6e2cd_0 3.8 MB defaultstorchvision-0.4.0 | py37_cu100 2.3 MB pytorch------------------------------------------------------------Total: 492.0 MBThe following NEW packages will be INSTALLED:blas anaconda/pkgs/main/win-64::blas-1.0-mklcffi anaconda/pkgs/main/win-64::cffi-1.13.2-py37h7a1dbc1_0cudatoolkit anaconda/pkgs/main/win-64::cudatoolkit-10.0.130-0freetype anaconda/pkgs/main/win-64::freetype-2.9.1-ha9979f8_1icc_rt anaconda/pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1intel-openmp anaconda/pkgs/main/win-64::intel-openmp-2019.4-245jpeg anaconda/pkgs/main/win-64::jpeg-9b-hb83a4c4_2libpng anaconda/pkgs/main/win-64::libpng-1.6.37-h2a8f88b_0libtiff anaconda/pkgs/main/win-64::libtiff-4.1.0-h56a325e_0mkl anaconda/pkgs/main/win-64::mkl-2019.4-245mkl-service anaconda/pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0mkl_fft anaconda/pkgs/main/win-64::mkl_fft-1.0.15-py37h14836fe_0mkl_random anaconda/pkgs/main/win-64::mkl_random-1.1.0-py37h675688f_0ninja anaconda/pkgs/main/win-64::ninja-1.9.0-py37h74a9793_0numpy anaconda/pkgs/main/win-64::numpy-1.17.4-py37h4320e6b_0numpy-base anaconda/pkgs/main/win-64::numpy-base-1.17.4-py37hc3f5095_0olefile anaconda/pkgs/main/win-64::olefile-0.46-py37_0pillow anaconda/pkgs/main/win-64::pillow-7.0.0-py37hcc1f983_0pycparser anaconda/pkgs/main/win-64::pycparser-2.19-py37_0pytorch pytorch/win-64::pytorch-1.2.0-py3.7_cuda100_cudnn7_1six anaconda/pkgs/main/win-64::six-1.13.0-py37_0tk anaconda/pkgs/main/win-64::tk-8.6.8-hfa6e2cd_0torchvision pytorch/win-64::torchvision-0.4.0-py37_cu100xz anaconda/pkgs/main/win-64::xz-5.2.4-h2fa13f4_4zlib anaconda/pkgs/main/win-64::zlib-1.2.11-h62dcd97_3zstd anaconda/pkgs/main/win-64::zstd-1.3.7-h508b16e_0Proceed ([y]/n)? yDownloading and Extracting Packages mkl_fft-1.0.15 | 137 KB | ############################################################################ | 100% numpy-1.17.4 | 5 KB | ############################################################################ | 100% mkl-service-2.3.0 | 200 KB | ############################################################################ | 100% torchvision-0.4.0 | 2.3 MB | ############################################################################ | 100% pillow-7.0.0 | 726 KB | ############################################################################ | 100% pytorch-1.2.0 | 479.3 MB | #############################################################1 | 80% numpy-base-1.17.4 | 4.8 MB | | 0% freetype-2.9.1 | 470 KB | | 0% olefile-0.46 | 49 KB | ############################################################################ | 100% mkl_random-1.1.0 | 270 KB | ############################################################################ | 100% tk-8.6.8 | 3.8 MB | ############################################################################ | 100%CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/pytorch-1.2.0-py3.7_cuda100_cudnn7_1.tar.bz2> Elapsed: -An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way.ProxyError: Conda cannot proceed due to an error in your proxy configuration. Check for typos and other configuration errors in any '.netrc' file in your home directory, any environment variables ending in '_PROXY', and any other system-wide proxy configuration settings.ProxyError: Conda cannot proceed due to an error in your proxy configuration. Check for typos and other configuration errors in any '.netrc' file in your home directory, any environment variables ending in '_PROXY', and any other system-wide proxy configuration settings.這是因為conda install pytorch torchvision cudatoolkit=10.1 -c pytorch,是默認到pytorch官網(wǎng)上下載的,下載特別慢,而且容易出現(xiàn)中途連接不上網(wǎng)頁、中斷下載的情況。為了能夠順利地安裝,不出現(xiàn)中斷、提升下載速度,要到其他的鏡像網(wǎng)址進行下載。清華鏡像網(wǎng)址從2019年開始不再更新維護了,我們選擇中科大的網(wǎng)址,在命令行中輸入以下指令:
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/pytorch/ conda config --set show_channel_urls yes conda install pytorch torchvision cudatoolkit=10.0 -c pytorch可以看到,能夠順利進行安裝
Collecting package metadata (repodata.json): done Solving environment: done## Package Plan ##environment location: D:\Anaconda\envs\pytorch_gpuadded / updated specs:- cudatoolkit=10.0- pytorch- torchvisionThe following packages will be downloaded:package | build---------------------------|-----------------freetype-2.9.1 | ha9979f8_1 470 KB defaultsnumpy-base-1.17.4 | py37hc3f5095_0 4.8 MB defaultspytorch-1.2.0 |py3.7_cuda100_cudnn7_1 479.3 MB pytorch------------------------------------------------------------Total: 484.5 MBThe following NEW packages will be INSTALLED:blas anaconda/pkgs/main/win-64::blas-1.0-mklcffi anaconda/pkgs/main/win-64::cffi-1.13.2-py37h7a1dbc1_0cudatoolkit anaconda/pkgs/main/win-64::cudatoolkit-10.0.130-0freetype anaconda/pkgs/main/win-64::freetype-2.9.1-ha9979f8_1icc_rt anaconda/pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1intel-openmp anaconda/pkgs/main/win-64::intel-openmp-2019.4-245jpeg anaconda/pkgs/main/win-64::jpeg-9b-hb83a4c4_2libpng anaconda/pkgs/main/win-64::libpng-1.6.37-h2a8f88b_0libtiff anaconda/pkgs/main/win-64::libtiff-4.1.0-h56a325e_0mkl anaconda/pkgs/main/win-64::mkl-2019.4-245mkl-service anaconda/pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0mkl_fft anaconda/pkgs/main/win-64::mkl_fft-1.0.15-py37h14836fe_0mkl_random anaconda/pkgs/main/win-64::mkl_random-1.1.0-py37h675688f_0ninja anaconda/pkgs/main/win-64::ninja-1.9.0-py37h74a9793_0numpy anaconda/pkgs/main/win-64::numpy-1.17.4-py37h4320e6b_0numpy-base anaconda/pkgs/main/win-64::numpy-base-1.17.4-py37hc3f5095_0olefile anaconda/pkgs/main/win-64::olefile-0.46-py37_0pillow anaconda/pkgs/main/win-64::pillow-7.0.0-py37hcc1f983_0pycparser anaconda/pkgs/main/win-64::pycparser-2.19-py37_0pytorch pytorch/win-64::pytorch-1.2.0-py3.7_cuda100_cudnn7_1six anaconda/pkgs/main/win-64::six-1.13.0-py37_0tk anaconda/pkgs/main/win-64::tk-8.6.8-hfa6e2cd_0torchvision pytorch/win-64::torchvision-0.4.0-py37_cu100xz anaconda/pkgs/main/win-64::xz-5.2.4-h2fa13f4_4zlib anaconda/pkgs/main/win-64::zlib-1.2.11-h62dcd97_3zstd anaconda/pkgs/main/win-64::zstd-1.3.7-h508b16e_0Proceed ([y]/n)? yDownloading and Extracting Packages numpy-base-1.17.4 | 4.8 MB | ############################################################################ | 100% pytorch-1.2.0 | 479.3 MB | ############################################################################ | 100% freetype-2.9.1 | 470 KB | ############################################################################ | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done總結
以上是生活随笔為你收集整理的pytorch GPU版本安装 win10的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安装模块时提示Collecting pa
- 下一篇: 北京大学药学院张亮仁教授/刘振明研究员课