东方耀AI技术分享

标题: ubuntu18.04上安装cuda10.1后的tf与pytorch的版本选择问题 [打印本页]

作者: 东方耀    时间: 2021-1-29 09:30
标题: ubuntu18.04上安装cuda10.1后的tf与pytorch的版本选择问题



ubuntu18.04上安装cuda10.1后的tf与pytorch的版本选择问题

本机系统:nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
安装的是 cuda 10.1

如需了解可用于旧版 TensorFlow 的 CUDA® 和 cuDNN 版本,请参阅经过测试的构建配置

则tensorflow-gpu必须是 tensorflow-2.1.0
参考官网:https://tensorflow.google.cn/install/source#linux


pip3 install tensorflow==2.1.0
pip3 install keras==2.3.1


pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html






通过tf看的:tf.test.is_gpu_available()
physical GPU (device: 0, name: GeForce GT 730, pci bus id: 0000:01:00.0, compute capability: 3.5)


physical GPU (device: 0, name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)


Python 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch as T
>>> T.__version__
'1.7.1+cu101'
>>> T.cuda.is_available()
True

大功告成!






作者: 东方耀    时间: 2021-1-29 10:26
RuntimeError: CUDA error: no kernel image is available for execution on the device


问题在于硬件的支持情况,对于算力3.0的显卡来说,如果安装了9.0的CUDA就会出现这个问题,解决的办法是退回CUDA8.0,或者更换更加高端的显卡
作者: 东方耀    时间: 2021-1-29 10:32
东方耀 发表于 2021-1-29 10:26
RuntimeError: CUDA error: no kernel image is available for execution on the device

看看这个有没有报错:
  1. a = torch.Tensor(5,3)
  2. a=a.cuda()
  3. print(a)
复制代码

作者: 东方耀    时间: 2021-2-2 10:13
新增的东东:音频啥的
Installing collected packages: dataclasses, torch, torchvision, torchaudio
Successfully installed dataclasses-0.8 torch-1.7.1+cu101 torchaudio-0.7.2 torchvision-0.8.2+cu101




欢迎光临 东方耀AI技术分享 (http://www.ai111.vip/) Powered by Discuz! X3.4