How to install PyTorch such that can use GPUs
EDIT: I use net.cuda() and this seems to work. However when I try to run my script I get this error: (If I do not try to run net.cuda() my script works find on the CPU).
Kalamaya
NgPDat
Kalamaya
Nevermind, I think it works now: I had forgotten to do the same for the labels as well. Thanks!
Kalamaya
Hi, <SCODE>python translate.py -model ../onmt-model/onmt_model_en_fr_b1M-261c69a7.pt -src ../test.txt -output ../test.tok
<ECODE> , but failed with the following error: <SCODE>Traceback (most recent call last):
  File "translate.py", line 116, in <module>
    main()
  File "translate.py", line 55, in main
    translator = onmt.Translator(opt)
  File "/root/OpenNMT-py/onmt/Translator.py", line 11, in __init__
    checkpoint = torch.load(opt.model)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/serialization.py", line 222, in load
    return _load(f, map_location, pickle_module)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/serialization.py", line 355, in _load
    return legacy_load(f)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/serialization.py", line 300, in legacy_load
    obj = restore_location(obj, location)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/serialization.py", line 85, in default_restore_location
    result = fn(storage, location)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/serialization.py", line 67, in _cuda_deserialize
    return obj.cuda(device_id)
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/_utils.py", line 56, in _cuda
    with torch.cuda.device(device):
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/cuda/__init__.py", line 136, in __enter__
    _lazy_init()
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/cuda/__init__.py", line 96, in _lazy_init
    _check_driver()
  File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/cuda/__init__.py", line 70, in _check_driver
    http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx
<ECODE> It looks having no GPU support. Yes, I’m using a VM, so don’t have GPU. Is this right? <SCODE>Traceback (most recent call last):
  File "translate.py", line 123, in <module>
    main()
  File "translate.py", line 56, in main
    translator = onmt.Translator(opt)
  File "/root/OpenNMT-py/onmt/Translator.py", line 12, in __init__
    checkpoint = torch.load(opt.model)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 229, in load
    return _load(f, map_location, pickle_module)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 362, in _load
    return legacy_load(f)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 307, in legacy_load
    obj = restore_location(obj, location)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 85, in default_restore_location
    result = fn(storage, location)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 67, in _cuda_deserialize
    return obj.cuda(device_id)
  File "/root/anaconda3/lib/python3.6/site-packages/torch/_utils.py", line 57, in _cuda
    with torch.cuda.device(device):
  File "/root/anaconda3/lib/python3.6/site-packages/torch/cuda/__init__.py", line 129, in __enter__
    _lazy_init()
  File "/root/anaconda3/lib/python3.6/site-packages/torch/cuda/__init__.py", line 89, in _lazy_init
    _check_driver()
  File "/root/anaconda3/lib/python3.6/site-packages/torch/cuda/__init__.py", line 56, in _check_driver
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
<ECODE> Could anyone help? Thanks a lot!
lifengd
smth
@smth Hi Smth, Do you mean the Python edition of OpenNMT require GPU? Not ok with CPU only on VM? And seems there is no such a control flag from the command help: translate.py Thanks!
lifengd