下载与cuda版本对应的pytorch、torchvision、torchaudio

在安装torch之后,可能遇到以下的问题:

RuntimeError: CUDA error: no kernel image is available for execution on the device CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

这个时候很有可能是torch的版本和cuda,不一致,可以测试:

>>> torch.cuda.is_available()
True
>>> a=torch.Tensor([2,6])
>>> a=a.cuda()
>>> a
tensor([2., 6.], device='cuda:0')

如果不是上述结果,就需要重新安装torch啦,先使用pip uninstall把所有与torch相关的卸载了,然后重新安装。

可以直接在下列链接找到与cuda版本对应的pytorch、torchvision、torchaudio

Previous PyTorch Versions | PyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.icon-default.png?t=N7T8https://pytorch.org/get-started/previous-versions/里面的结构如下图所示,选取对应的命令即可(linux、windows、osx均有),支持pip和conda两种方式。

cuda11.2可以下:

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

或者

pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html

如果运行的时候,报错:“OSError: libtorch_hip.so: cannot open shared object file: No such file or directory”

则给torchaudio后加上cuda版本,即torchaudio==0.10.0+cu111

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值