-2

即使我成功安装了 torchvision 和 cuda,我也收到了这个错误:我在 VMWare(Ubuntu 18.04)中运行程序。

python3 ./decode/train_dataloader.py --img_data ./datasets/image_fmri --output ./tmp/feat_data
Traceback (most recent call last):
  File "./decode/train_dataloader.py", line 26, in <module>
    net = torchvision.models.vgg19_bn(pretrained=True).cuda()
  File "/home/home/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 260, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/home/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 187, in _apply
    module._apply(fn)
  File "/home/home/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 187, in _apply
    module._apply(fn)
  File "/home/home/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 193, in _apply
    param.data = fn(param.data)
  File "/home/home/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 260, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/home/home/.local/lib/python3.6/site-packages/torch/cuda/__init__.py", line 161, in _lazy_init
    _check_driver()
  File "/home/home/.local/lib/python3.6/site-packages/torch/cuda/__init__.py", line 75, in _check_driver
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
4

1 回答 1

0

问题解决:出现错误是因为程序代码在虚拟机(VMWare;操作系统:Ubuntu 18.04;本机系统操作系统:Windows 10)中运行,其中缺少图形驱动程序(因为无法安装图形驱动程序在虚拟机中)。

此页面是在 Ubuntu 中安装 cuda 的一个很好的指南:https ://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/

于 2019-02-08T13:35:10.347 回答