Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacy + GPU gives error: GPU is not accessible. Was the library installed correctly?

Tags:

gpu

spacy

cupy

The following code give error:

import spacy
spacy.require_gpu()

Traceback (most recent call last):
  File "/home/user/PycharmProjects/new_tsg/training/spacy_train_data/spacy_pipeline.py", line 39, in <module>
    spacy.require_gpu()
  File "/home/user/PycharmProjects/new_tsg/venv/lib/python3.6/site-packages/thinc/neural/util.py", line 87, in require_gpu
    raise ValueError("GPU is not accessible. Was the library installed correctly?")
ValueError: GPU is not accessible. Was the library installed correctly?

My configuration is:

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

GeForce RTX 2080 Driver Version: 418.39 

Spacy v 2.3.5 was installed with cuda 10.1 support by:

pip install --no-cache-dir spacy[cuda101]

What can I try to fix that?

like image 869
palandlom Avatar asked Oct 19 '25 02:10

palandlom


1 Answers

My mistake in this case was in using the CUDA version specified in by nvidia-smi instead of nvcc --version.

You should use the version specified in nvcc --version. I think nvidia-smi indicates the maximum possible cuda version supported by your GPU, rather than the actual version that you have installed.

So if nvcc says you have version 11.1, then you should install spacy with:

pip install -U spacy[cuda111]
like image 98
joe Avatar answered Oct 22 '25 05:10

joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!