即使我成功安装了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
答案 0 :(得分:0)
问题已解决:出现错误是因为程序代码在虚拟机(VMWare; OS:Ubuntu 18.04; Native System OS:Windows 10)内部运行。丢失(因为无法在虚拟机中安装图形驱动程序)。
此页面是在Ubuntu中安装cuda的良好指南:https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/