Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Ubuntu 18.04(在VMWare内部运行)中运行程序时,我收到以下错误:AssertionError:Torch未在启用CUDA的情况下编译_Python_Vmware_Ubuntu 18.04_Torchvision - Fatal编程技术网

Python 在Ubuntu 18.04(在VMWare内部运行)中运行程序时,我收到以下错误:AssertionError:Torch未在启用CUDA的情况下编译

Python 在Ubuntu 18.04(在VMWare内部运行)中运行程序时,我收到以下错误:AssertionError:Torch未在启用CUDA的情况下编译,python,vmware,ubuntu-18.04,torchvision,Python,Vmware,Ubuntu 18.04,Torchvision,尽管我成功地安装了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 <

尽管我成功地安装了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
问题解决:出现错误的原因是,程序代码在虚拟机VMWare中运行;操作系统:Ubuntu 18.04;本机系统OS:Windows 10,其中缺少图形驱动程序,因为无法在虚拟机中安装图形驱动程序


本页是在Ubuntu中安装cuda的好指南:

您是如何安装torch的?你必须指定CUDA在哪里吗?安装是否拾取了它?@tayfun我使用以下命令安装了torch:pip3 install-no cache dir torchvision。目前的pip版本是:19.0.1。