简体   繁体   中英

unable to train model using space on google colab gpu

How to reproduce the behaviour

follow the below instruction on google colab

pip install -U pip setuptools wheel
pip install -U 'spacy[cuda113,transformers,lookups]'
python -m spacy download en_core_web_sm

While running below code~

!python3 -m spacy train /content/drive/MyDrive/config/config.cfg --gpu-id 0 --output /content/drive/MyDrive/trf_spacy_model --paths.train /content/drive/MyDrive/train_data-2 --paths.dev /content/drive/MyDrive/test_data-2

Got this error!!!!

ℹ Saving to output directory:
/content/drive/MyDrive/trf_spacy_model
ℹ Using GPU: 0
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/dist-packages/spacy/main.py", line 4, in 
setup_cli()
File "/usr/local/lib/python3.7/dist-packages/spacy/cli/_util.py", line 71, in setup_cli
command(prog_name=COMMAND)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 532, in wrapper
return callback(**use_params) # type: ignore
File "/usr/local/lib/python3.7/dist-packages/spacy/cli/train.py", line 45, in train_cli
train(config_path, output_path, use_gpu=use_gpu, overrides=overrides)
File "/usr/local/lib/python3.7/dist-packages/spacy/cli/train.py", line 67, in train
setup_gpu(use_gpu)
File "/usr/local/lib/python3.7/dist-packages/spacy/cli/_util.py", line 571, in setup_gpu
require_gpu(use_gpu)
File "/usr/local/lib/python3.7/dist-packages/thinc/util.py", line 195, in require_gpu
raise ValueError("No GPU devices detected")
ValueError: No GPU devices detected

Your Environment

Operating System: Python Version Used: spaCy Version Used: Environment Information: Info about spaCy

spaCy version: 3.4.0 Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic Python version: 3.7.13 Pipelines: en_core_web_trf (3.4.0), en_core_web_sm (3.3.0)

The problem seems to be that you're trying to train without having access to a GPU. You can either train without gpu (by omitting the --gpu-id 0 argument in your train script - Note: this will be very slow.!) Or by setting up your gpu.

To do this:

You should first check to see if your runtime is using a GPU.

Run !nvidia-smi -L on colab to see what GPU you have.

If there's no GPU there, go to runtime in Settings -> Change Runtime and select GPU.

That should change your runtime type and re-running the above command should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM