Closed pythonBerg closed 5 years ago
A few things to check:
spacy[cuda92]
, not spacy[cuda9.2]
as you wrote. Did you typo this in your issue, or did you install the wrong package?LD_LIBRARY_PATH
to include your cuda installation? Default location will be /usr/local/cuda/lib64
. You might also need to set your PATH
so that /usr/local/cuda/bin
is on it.My bad on the spelling. The correct version was installed. I have both the bin and lib directories specified in my windows path. I can call nvcc from command line. I have cleaned out all old packages to give fresh install. No errors...Going into python terminal, all imports appear to be working.
On Tue, Oct 16, 2018 at 12:10 PM Matthew Honnibal notifications@github.com wrote:
A few things to check:
- The correct spelling is spacy[cuda92], not spacy[cuda9.2] as you wrote. Did you typo this in your issue, or did you install the wrong package?
- Have you set your LD_LIBRARY_PATH to include your cuda installation? Default location will be /usr/local/cuda/lib64. You might also need to set your PATH so that /usr/local/cuda/bin is on it.
- I believe there's another issue open about text classifier training on GPU. You should continue using the CPU to train the text classifier for now.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/explosion/spaCy/issues/2855#issuecomment-430298556, or mute the thread https://github.com/notifications/unsubscribe-auth/AV1XMQoQdCwFl2tK2fvAo4YiThX8rFtoks5ulgT9gaJpZM4Xeey8 .
Okay, thanks for the report. Wasn't able to test GPU on Windows unfortunately --- will investigate.
Hi, I have the same bug. Following is the details.
Ubuntu 16.04.4 LTS
9.1
, V9.1.853.5.2
2.0.16
import spacy
spacy.require_gpu() # True
nlp = spacy.load('en_core_web_sm')
text = 'spaCy is good.'
nlp(text) # AttributeError: module 'thinc_gpu_ops' has no attribute 'hash'
same bug here, the root of the bug is
from thinc_gpu_ops.gpu_ops import *
print (thinc_gpu_ops.__file__)
thinc_gpu_ops.hash(1,2,3)
/anaconda/envs/py36/lib/python3.6/site-packages/thinc_gpu_ops/gpu_ops.cpython-36m-x86_64-linux-gnu.so: undefined symbol: __cudaPopCallConfiguration
installed by spacy[cuda] to Azure Deeplearning VM
$LD_LIBRARY_PATH = /opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/lib/intel64_lin/gcc4.7:/opt/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2018.1.163/linux/mkl/lib/intel64_lin::/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64/:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64/
$PATH /anaconda/envs/py36/bin:/home/agradmin/bin:/home/agradmin/.local/bin:/anaconda/envs/py35/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/caffe/build/install/bin/:/usr/local/cuda/bin:/dsvm/tools/cntk/cntk/bin:/usr/local/cuda/bin:/dsvm/tools/cntk/cntk/bin:/dsvm/tools/spark/current/bin:/opt/mssql-tools/bin
cuda92,
@honnibal how do I debug thinc_gpu_ops so
I have it working in conda py3.5, but have __cudaPopCallConfiguration on py3.6 (same machine) Unfortunately I don't see any difference in CUDA related env. Could you please tell where to start?
Hi, I have the same bug. Following is the details.
Environments:
* Platform: `Ubuntu 16.04.4 LTS` * Cuda compilation tools, release `9.1`, V9.1.85 * Python version: `3.5.2` * spaCy version: `2.0.16` * Models: en
import spacy spacy.require_gpu() # True nlp = spacy.load('en_core_web_sm') text = 'spaCy is good.' nlp(text) # AttributeError: module 'thinc_gpu_ops' has no attribute 'hash'
I have exactly the same issue but on Ubuntu 16.04. Cuda 9.2 is installed correctly, all the path variables are set. Cupy works separately too. This is the only error I get. I am on Python 3.7, however.
Could you try again with the latest spacy-nightly
? Thanks.
On first look, same outcome...
Created blank 'en' model
Loading NER Training Data
Traceback (most recent call last):
File ".\modelTrainer.py", line 238, in
PS C:\home> pip list Package Version
absl-py 0.1.13 appdirs 1.4.3 asn1crypto 0.24.0 astor 0.6.2 atomicwrites 1.2.1 attrs 17.4.0 bcrypt 3.1.4 bleach 1.5.0 blis 0.2.2 certifi 2018.1.18 cffi 1.11.5 chainer 3.5.0 chardet 3.0.4 colorama 0.3.9 cryptography 2.3 cupy-cuda92 5.0.0 cymem 2.0.2 Cython 0.28.1 cytoolz 0.9.0.1 decorator 4.3.0 dill 0.2.7.1 Django 2.0.4 fabric 2.3.1 fastrlock 0.3 filelock 3.0.4 ftfy 4.4.3 gast 0.2.0 grpcio 1.10.0 html5lib 0.9999999 hypothesis 2.0.0 idna 2.6 invoke 1.1.1 jsonschema 2.6.0 Mako 1.0.7 Markdown 2.6.11 MarkupSafe 1.0 mock 2.0.0 more-itertools 4.1.0 msgpack 0.5.6 msgpack-numpy 0.4.1 msgpack-python 0.5.4 murmurhash 0.28.0 numpy 1.15.2 pandas 0.22.0 paramiko 2.4.1 pathlib 1.0.1 pbr 4.0.1 pip 18.1 plac 0.9.6 pluggy 0.8.0 preshed 2.0.1 protobuf 3.5.2.post1 psycopg2 2.7.4 py 1.5.3 pyasn1 0.4.4 pycparser 2.18 pycuda 2018.1 pyflakes 1.6.0 PyNaCl 1.2.1 pyreadline 2.1 pytest 3.10.1 python-dateutil 2.7.2 pytools 2018.5.2 pytz 2018.3 regex 2018.1.10 requests 2.18.4 rope 0.10.7 scikit-learn 0.19.1 scipy 1.0.1 setuptools 40.6.2 six 1.11.0 sklearn 0.0 spacy-nightly 2.1.0a4 srsly 0.0.5 tensorboard 1.7.0 tensorflow-gpu 1.7.0 termcolor 1.1.0 thinc 7.0.0.dev6 thinc-gpu-ops 0.0.4 toolz 0.9.0 tqdm 4.19.9 ujson 1.35 urllib3 1.22 wasabi 0.0.15 wcwidth 0.1.7 Werkzeug 0.14.1 wheel 0.31.0 wrapt 1.10.11
On Sat, Dec 29, 2018 at 10:27 AM Matthew Honnibal notifications@github.com wrote:
Could you try again with the latest spacy-nightly? Thanks.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/explosion/spaCy/issues/2855#issuecomment-450500164, or mute the thread https://github.com/notifications/unsubscribe-auth/AV1XMSxnx3B6wNJD0XKTamb1w5rUEVrBks5u94nXgaJpZM4Xeey8 .
Same output:
OS : Windows 10 pip install cupy-cuda92 pip install spacy[cuda92] pip install thinc_gpu_ops thinc[cuda92]
import spacy spacy.require_gpu() # True nlp = spacy.load('en_core_web_sm') text = 'spaCy is good.' nlp(text) # AttributeError: module 'thinc_gpu_ops' has no attribute 'hash'
I have the exact same issue. This is on a brand new machine. EDIT: We've also replicated this issue on other Windows 10 machines here. The issue does not present on RHEL 7 with CUDA v9.0.
OS: Windows 10 v1709 CUDA v10.0 2080 Ti The following commands replicate the issue.
pip install spacy[cuda100] spacy download en_core_web_lg
python import spacy spacy.require_gpu()
nlp = spacy.load('en_core_web_lg') text = 'SpaCy is great.' doc = nlp(text)
Traceback (most recent call last):
File "
i have the same issue on windows 10 you should also change the cuda version 101 to support it since cupy-cuda101 is available
i have the same bug on Mint 19:
module 'thinc_gpu_ops' has no attribute 'hash'
For Linux (Ubuntu), I had this problem because of different gcc versions (newer version of the nvidia driver and cuda will install gcc-8, but cupy and others dependices use nvcc, which only works with gcc7 or lower), When running builds, make sure CUDA_HOME is set and CUDA_HOME/bin is on your PATH.
I have the same issue.
Env: OS = Windows 10. Cuda = 9 SpaCy = 2.1.7 Python = 3.6.8 thinc_gpu_ops = 0.0.4
Error: ops.pyx in thinc.neural.ops.CupyOps.hash()
AttributeError: module 'thinc_gpu_ops' has no attribute 'hash'
Is there any additional update on thinc_gpu_ops
? I have not been able to correctly compile it for the past year, on Windows, specifically.
This is same as #3554. Lot's of people have hit a wall. Many have spent significant time trying to resolve with no published success
See https://github.com/explosion/thinc/issues/92#issuecomment-524538960 for a solution that has worked for me. Thanks to mtmiron
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
New clean install of spacy[cuda9.2]. Seeing several issues.
CYMEM warning submitted in #2852 generated in all operations.
When using ner training on new model...get error that thinc_gpu_ops has no function "hash".
In classifier, error is that "Only Cupy Arrays can be concatenated"
This script has worked without gpu for me for months (in ubuntu 18.04) and is slightly modified version of one posted in spacy examples
***ner training error * Created blank 'en' model Loading NER Training Data Traceback (most recent call last): File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\pdb.py", line 1667, in main pdb._runscript(mainpyfile) File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\pdb.py", line 1548, in _runscript self.run(statement) File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\bdb.py", line 434, in run exec(cmd, globals, locals) File "", line 1, in
File "c:\home\modeltrainer.py", line 10, in
Compatible with: spaCy v2.0.0+"""
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\plac_core.py", line 328, in call
cmd, result = parser.consume(arglist)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\plac_core.py", line 207, in consume
return cmd, self.func(*(args + varargs + extraopts), kwargs)
File "c:\home\modeltrainer.py", line 173, in main
losses=losses)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\language.py", line 421, in update
proc.update(docs, golds, drop=drop, sgd=get_grads, losses=losses)
File "nn_parser.pyx", line 565, in spacy.syntax.nn_parser.Parser.update
File "nn_parser.pyx", line 729, in spacy.syntax.nn_parser.Parser.get_batch_model
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 61, in begin_update
X, inc_layer_grad = layer.begin_update(X, drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 280, in begin_update
drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 61, in begin_update
X, inc_layer_grad = layer.begin_update(X, drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 374, in uniqued_fwd
Y_uniq, bp_Y_uniq = layer.begin_update(X_uniq, drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 61, in begin_update
X, inc_layer_grad = layer.begin_update(X, drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in begin_update
values = [fwd(X, *a, *k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in
values = [fwd(X, a, k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 258, in wrap
output = func(*args, kwargs)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in begin_update
values = [fwd(X, *a, *k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in
values = [fwd(X, a, k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 258, in wrap
output = func(*args, kwargs)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in begin_update
values = [fwd(X, *a, *k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in
values = [fwd(X, a, k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 258, in wrap
output = func(*args, kwargs)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\neural_classes\hash_embed.py", line 51, in begin_update
keys = self.ops.hash(ids, self.seed) % self.nV
File "ops.pyx", line 821, in thinc.neural.ops.CupyOps.hash
AttributeError: module 'thinc_gpu_ops' has no attribute 'hash'
*****classifier error *
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\plac_core.py", line 328, in call cmd, result = parser.consume(arglist) File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\plac_core.py", line 207, in consume return cmd, self.func(*(args + varargs + extraopts), kwargs) File "c:\home\modeltrainer.py", line 128, in main losses=losses) File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\language.py", line 421, in update proc.update(docs, golds, drop=drop, sgd=get_grads, losses=losses) File "pipeline.pyx", line 876, in spacy.pipeline.TextCategorizer.update File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 61, in begin_update X, inc_layer_grad = layer.begin_update(X, drop=drop) File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in begin_update values = [fwd(X, *a, *k) for fwd in forward] File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 176, in
values = [fwd(X, a, k) for fwd in forward]
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 258, in wrap
output = func(*args, kwargs)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\thinc\api.py", line 61, in begin_update
X, inc_layer_grad = layer.begin_update(X, drop=drop)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy_ml.py", line 102, in _preprocess_doc
keys = ops.xp.concatenate(keys)
File "c:\Users\MPC-LAPTOP01\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\manipulation\join.py", line 49, in concatenate
return core.concatenate_method(tup, axis)
File "cupy\core\core.pyx", line 2728, in cupy.core.core.concatenate_method
File "cupy\core\core.pyx", line 2741, in cupy.core.core.concatenate_method
TypeError: Only cupy arrays can be concatenated
**env ****
Windows10 Python 3.6 spacy 2.0.16 thinc 6.12.0 thinc-gpu-ops 0.0.3
****script***** from future import unicode_literals, print_function import plac import random import sys import os from pathlib import Path import thinc.extra.datasets import psycopg2 import spacy from spacy.util import minibatch, compounding import re import regex from collections import defaultdict spacy.prefer_gpu()
@plac.annotations( model=("Model name. Defaults to blank 'en' model.", "option", "m", str), output_dir=("Optional output directory", "option", "o", Path), n_texts=("Number of texts to train from", "option", "t", int), datatype=("Type of object to train", "option", "d", str), n_iter=("Number of training iterations", "option", "n", int))
def main(model=None, output_dir='/home/classify/section999', n_iter=30, n_texts=4000,datatype='all'): if not model and output_dir: model=output_dir if datatype is None: exit(1) else: try: nlp = spacy.load(model) # load existing spaCy model print("Loaded model '%s'" % model) except: nlp = spacy.blank('en') # create blank Language class print("Created blank 'en' model")
def load_ner_data(): train_data=[] annMaster = defaultdict(list) rc = cur.execute("select sub_document_id,model_field,token_start, token_end from new_annotation where status not in ('Deleted','Pending') and source not in ('section_classification','sub_classification') and current_version=1") anndata = cur.fetchall()
def evaluate(tokenizer, textcat, texts, cats): docs = (tokenizer(text) for text in texts) tp = 1e-8 # True positives fp = 1e-8 # False positives fn = 1e-8 # False negatives tn = 1e-8 # True negatives for i, doc in enumerate(textcat.pipe(docs)): gold = cats[i] for label, score in doc.cats.items(): if label not in gold: continue if score >= 0.5 and gold[label] >= 0.5: tp += 1. elif score >= 0.5 and gold[label] < 0.5: fp += 1. elif score < 0.5 and gold[label] < 0.5: tn += 1 elif score < 0.5 and gold[label] >= 0.5: fn += 1 precision = tp / (tp + fp) recall = tp / (tp + fn) f_score = 2 (precision recall) / (precision + recall) return {'textcat_p': precision, 'textcat_r': recall, 'textcat_f': f_score}
if name == 'main': plac.call(main)