PyTorch v1.0.0稳定版在2018年12月8日发布, 在此之前提前7个月宣布。
我想获得针对我的IPython内核运行的硬件进行优化的版本。
我该如何在Google Colab上获取此版本?
PyTorch v1.0.0稳定版在2018年12月8日发布, 在此之前提前7个月宣布。
我想获得针对我的IPython内核运行的硬件进行优化的版本。
我该如何在Google Colab上获取此版本?
尝试以下代码片段(无论是否使用GPU运行时均有效)
!pip install -q torch==1.0.0 torchvision
检查版本号
import torch
print(torch.__version__)
这里是版本1.0.0。
更新
!pip install torch
现在正常运作,因为最稳定的版本是1.0.0
从版本1.0.0开始,PyTorch将下载URL格式更改为:
https://download.pytorch.org/whl/cu92/torch-1.0.0-cp36-cp36m-linux_x86_64.whl
to
https://download.pytorch.org/whl/cu90/torch-1.0.0-cp36-cp36m-linux_x86_64.whl
(变化发生在CUDA版本部分,其中cu92
变成了cu90
。)
为了以编程方式生成该URL,我使用了以下代码:
from os.path import exists
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
cuda_output = !ldconfig -p|grep cudart.so|sed -e 's/.*\.\([0-9]*\)\.\([0-9]*\)$/cu\10/'
accelerator = cuda_output[0] if exists('/dev/nvidia0') else 'cpu'
torch_url=f"http://download.pytorch.org/whl/{accelerator}/torch-{version}-{platform}-linux_x86_64.whl"
version='1.0.0'
!pip install -U {torch_url} torchvision
随着更新版本的发布,您可以根据需要更改version
变量。
import torch
无需额外安装。
!pip install -q torch==1.1.0 torchvision
对我很有效,你可以试试
!pip install torch
!pip install torchvision
!pip install mxnet-cu101
这是安装PyTorch的代码。您可以将其更改为所需版本。
!pip3 install http://download.pytorch.org/whl/cu92/torch-1.0.0-cp36-cp36m-linux_x86_64.whl
torch.backends.cudnn.version()
,输出结果是7401
,而且torch.backends.cudnn.enabled == True
的输出结果是true
。我使用的是Colab GPU运行时。 - ashunigioncu90
,我也得到了7410
。 - Tom Hale