Spacy: GPU ops are not getting built for thinc : No module named 'thinc.neural.gpu_ops'

Created on 20 Dec 2017  Â·  16Comments  Â·  Source: explosion/spaCy

So I was following the guide to install spacy with gpu support : https://spacy.io/usage/
I already have cuda installed with CUDA_HOME variable set as mentioned in the above link
I ran the following command. I have both python2.7 and python3 (-> python3.6)

sudo pip3 install spacy
python3 -c "import thinc.neural.gpu_ops"  

I got the following error,

Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'thinc.neural.gpu_ops'

I have successfully installed cupy from Chainer as well. Then uninstalled thinc and again installed thinc. But same error.

I uninstalled thinc and then installed it again with specifying the install log file.
sudo pip3 install thinc --log thinclogs.txt --no-cache-dir

From the logs, it seems that it is unable to find nvcc. But I can clearly access nvcc with nvcc -V command on the terminal.
Here are the relevant logs.

Downloading thinc-6.10.2.tar.gz (1.2MB)
Downloading from URL https://pypi.python.org/packages/55/fd/e9f36081e6f53699943381858848f3b4d759e0dd03c43b98807dde34c252/thinc-6.10.2.tar.gz#md5=41f4cd26d3e894600cdd36e3cd074239 (from https://pypi.python.org/simple/thinc/)
Running setup.py (path:/tmp/pip-build-xmgkus0e/thinc/setup.py) egg_info for package thinc
Running command python setup.py egg_info
Warning: The nvcc binary could not be located in your $PATH. For GPU capability, either add it to your path, or set $CUDA_HOME
running egg_info
creating pip-egg-info/thinc.egg-info
writing pip-egg-info/thinc.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/thinc.egg-info/dependency_links.txt
writing requirements to pip-egg-info/thinc.egg-info/requires.txt
writing top-level names to pip-egg-info/thinc.egg-info/top_level.txt
writing manifest file 'pip-egg-info/thinc.egg-info/SOURCES.txt'
reading manifest file 'pip-egg-info/thinc.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.cpp' under directory 'include'
warning: no files found matching 'buildbot.json'
writing manifest file 'pip-egg-info/thinc.egg-info/SOURCES.txt'

Your Environment

  • spaCy version: 2.0.5
  • Platform: Linux-4.13.0-19-generic-x86_64-with-Ubuntu-17.10-artful
  • Python version: 3.6.3
  • Environment Information: I have Cuda 8 with gtx 1080
gpu install 🔮 thinc

Most helpful comment

Hey, just managed to solve that problem for me: (ubuntu, python3, pip3, and cuda8)

sudo pip3 uninstall spacy thinc cupy
sudo pip3 install --no-cache-dir cupy
sudo CUDA_HOME=/usr/local/cuda-8.0 pip3 install --no-cache-dir thinc 
sudo pip3 install spacy
python3 -c "import thinc.neural.gpu_ops" 

Setting the CUDA_HOME for sudo is very important as it's often using env variables without CUDA one!

Hope that helps someone.

(based on https://github.com/explosion/spaCy/issues/1530)

All 16 comments

I have this issue too

I have this same issue, If I copy nvcc.exe and rename it as nvcc. The warning will change to:

Warning: The CUDA lib64 path could not be located in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib64

spacy: 2.0.5
thinc: 6.10.1
Platform: Windows 10 x64
Python version: 3.6.3
CUDA 8 Install Location: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\

I did the same as @pratik-shivarkar, then I've copied C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64 to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib64,

but now I get this error:

building 'thinc.neural.gpu_ops' extension
creating build\temp.win-amd64-3.6\Release\include
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-Ic:\program files\python36\include" -IC:\Users\Alex\AppData\Local\Temp\pip-build-sddrm1cv\thinc\include "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" "-Ic:\program files\python36\include" "-Ic:\program files\python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /EHsc /Tpthinc/neural/gpu_ops.cpp /Fobuild\temp.win-amd64-3.6\Release\thinc/neural/gpu_ops.obj /Ox /EHsc
gpu_ops.cpp
error: Don't know how to compile include/_cuda_shim.cu to build\temp.win-amd64-3.6\Release\include/_cuda_shim.obj

spacy: 2.0.7
thinc: 6.10.2
Platform: Windows 10 x64
Python version: 3.6.4
CUDA 8 Install Location: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\

Same issue -
spacy: 2.0.7
thinc: 6.10.2
Platform: Windows 10 x64
Python version: 3.6.3
CUDA 8 Install Location: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\
I think it wasn't expecting to be built on Windows.

I get the error error: Don't know how to compile include/_cuda_shim.cu to build\temp.win-amd64-3.6\Release\include/_cuda_shim.objwith CUDA9 after applying @pratik-shivarkar's fix
spacy: 2.0.7
thinc: 6.10.2
Platform: Windows 10 x64
Python version: 3.6.4

Same issue ImportError: No module named 'thinc.neural.gpu_ops'

spacy: 2.0.8
thinc: 6.10.2
Platform: Windows 10 x64
Python version: 3.5.4
CUDA 8 Install Location: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

Hey, just managed to solve that problem for me: (ubuntu, python3, pip3, and cuda8)

sudo pip3 uninstall spacy thinc cupy
sudo pip3 install --no-cache-dir cupy
sudo CUDA_HOME=/usr/local/cuda-8.0 pip3 install --no-cache-dir thinc 
sudo pip3 install spacy
python3 -c "import thinc.neural.gpu_ops" 

Setting the CUDA_HOME for sudo is very important as it's often using env variables without CUDA one!

Hope that helps someone.

(based on https://github.com/explosion/spaCy/issues/1530)

The solution by @several27 works like a charm, but may require a lower version of gcc/g++. It's done easily on Ubuntu, please refer to the SO thread for instructions: https://askubuntu.com/questions/1036108/install-gcc-4-9-at-ubuntu-18-04

Also found a useful GIST for the task, hope it helps: https://gist.github.com/SunnyRaj/788ca494db609a404c9dc4c88d47e775

I currently have the issue that when I install thinc, I get (after installing cupy)
Successfully installed thinc-6.11.2
And I can also successfully import the gpu_ops. However, when I then install spacy, my pip says:

Installing collected packages: thinc, spacy Found existing installation: thinc 6.11.2 Uninstalling thinc-6.11.2: Successfully uninstalled thinc-6.11.2 Successfully installed spacy-2.0.12 thinc-6.10.3

So, I could only solve this by afterwards installing thinc again. Which results in this uncomfortable warning of spacy 2.0.12 has requirement thinc<6.11.0,>=6.10.3, but you'll have thinc 6.11.2 which is incompatible.
this combination though still seems to work..

same here
cupy==4.5.0
cupy-cuda92==5.0.0rc1
thinc==6.12.0
thinc-gpu-ops==0.0.3
spacy==2.0.16

I have the same issue on Python 3.7. I've dug quite deep into this, and I've landed on Cython not being properly built for Python 3.7 as per https://github.com/scikit-learn-contrib/py-earth/issues/191, that's why thinc can't be built either with cupy. Anyone has any other solutions in mind?

I ended up using thick from py3.5. it shows warnings but works pretty well.

It is a bad hack, but already wasted on this two days

On Fri, Dec 7, 2018, 10:21 Ivan Bilan <[email protected] wrote:

I have the same issue on Python 3.7. I've dug quite deep into this, and
I've landed on Cython not being properly built for Python 3.7 as per
scikit-learn-contrib/py-earth#191
https://github.com/scikit-learn-contrib/py-earth/issues/191, that's why
thinc can't be built either with cupy. Anyone has any other solutions in
mind?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/explosion/spaCy/issues/1745#issuecomment-445171676,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABeALhntk3JmyaDKQYQfj8KnWxYhiY58ks5u2jMIgaJpZM4RIXEL
.

I ended up using thick from py3.5. it shows warnings but works pretty well. It is a bad hack, but already wasted on this two days
…
On Fri, Dec 7, 2018, 10:21 Ivan Bilan @.* wrote: I have the same issue on Python 3.7. I've dug quite deep into this, and I've landed on Cython not being properly built for Python 3.7 as per scikit-learn-contrib/py-earth#191 <scikit-learn-contrib/py-earth#191>, that's why thinc can't be built either with cupy. Anyone has any other solutions in mind? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1745 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeALhntk3JmyaDKQYQfj8KnWxYhiY58ks5u2jMIgaJpZM4RIXEL .

What do you mean? You installed thinc souce for Python 3.5 on Python 3.7? How did you do that?

I have conda with py35 and 36 installed (Data science machine VM on Azure)

installed thinc in py35 environment, and just copied binary to py36

On Fri, Dec 7, 2018, 11:37 Ivan Bilan <[email protected] wrote:

I ended up using thick from py3.5. it shows warnings but works pretty
well. It is a bad hack, but already wasted on this two days
… <#m_-7871010392534026959_>
On Fri, Dec 7, 2018, 10:21 Ivan Bilan @.* wrote: I have the same
issue on Python 3.7. I've dug quite deep into this, and I've landed on
Cython not being properly built for Python 3.7 as per
scikit-learn-contrib/py-earth#191
https://github.com/scikit-learn-contrib/py-earth/issues/191 <
scikit-learn-contrib/py-earth#191
https://github.com/scikit-learn-contrib/py-earth/issues/191>, that's
why thinc can't be built either with cupy. Anyone has any other solutions
in mind? — You are receiving this because you commented. Reply to this
email directly, view it on GitHub <#1745 (comment)
https://github.com/explosion/spaCy/issues/1745#issuecomment-445171676>,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABeALhntk3JmyaDKQYQfj8KnWxYhiY58ks5u2jMIgaJpZM4RIXEL
.

What do you mean? You installed thinc souce for Python 3.5 on Python 3.7?
How did you do that?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/explosion/spaCy/issues/1745#issuecomment-445192220,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABeALihtgPkYSC9A25I-V5YBe1IQsil2ks5u2kTtgaJpZM4RIXEL
.

Version 0.0.3 of thinc_gpu_ops had a problem where it wouldn't build on Python 3.7. Apologies for the delay on this -- we can't test the GPU with the CI systems, so it's hard to catch all the cross-platform problems that might occur. I've now uploaded v0.0.4 of thinc_gpu_ops, which should solve the problem.

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.

Was this page helpful?
0 / 5 - 0 ratings